Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-tooling-modules): windows support and performance improvements #1085

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/ui5-tooling-modules/lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ module.exports = async function ({ log, resources, options, middlewareUtil }) {
moduleName = moduleName.substring(0, moduleName.length - 3);
}

// check if the resource exists in node_modules
let resource = getResource(moduleName, { cwd, depPaths, isMiddleware: true });
let existsPackage;
if (!resource) {
// in some cases there is a request to a module of an NPM package and in this
// case we still need to trigger the bundle and watch process to create the
// bundle info from which we can extract the resource (e.g. webc libraries)
const npmPackage = getNpmPackageName(moduleName);
existsPackage = !!resolveModule(`${npmPackage}/package.json`, { cwd, depPaths, isMiddleware: true });
// in some cases there is a request to a module of an NPM package and in this
// case we still need to trigger the bundle and watch process to create the
// bundle info from which we can extract the resource (e.g. webc libraries)
const npmPackage = getNpmPackageName(moduleName);
const existsPackage = !!resolveModule(`${npmPackage}/package.json`, { cwd, depPaths, isMiddleware: true });
let resource;
if (existsPackage) {
// check if the resource exists in node_modules
resource = getResource(moduleName, { cwd, depPaths, isMiddleware: true });
}

// if a resource has been found in node_modules, we will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module.exports = function ({ log, resolveModule, framework, skip } = {}) {
let modulePath = resolveModule(source);
if (modulePath) {
modulePath = modulePath.substr(metadata.npmPackagePath.length + 1);
modulePath = modulePath.replace(/\\/g, "/");
const moduleName = `${npmPackage}/${modulePath}`;
const clazz = WebComponentRegistry.getClassDefinition(moduleName);
// TODO: base classes must be ignored as UI5Element is flagged as custom element although it is a base class
Expand Down Expand Up @@ -227,7 +228,7 @@ module.exports = function ({ log, resolveModule, framework, skip } = {}) {
designtime: `${ui5Metadata.namespace}/designtime/${clazz.name}.designtime`, // add a default designtime
});
const metadata = JSON.stringify(metadataObject, undefined, 2);
const webcClass = moduleInfo.attributes.absModulePath; // is the absolute path of the original Web Component class
const webcClass = moduleInfo.attributes.absModulePath.replace(/\\/g, "/"); // is the absolute path of the original Web Component class

// Determine the superclass UI5 module name and import it
let webcBaseClass = "sap/ui/core/webc/WebComponent";
Expand Down
4 changes: 3 additions & 1 deletion packages/ui5-tooling-modules/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ module.exports = function (log, projectInfo) {
*/
function resolveNodeModule(moduleName, cwd = process.cwd(), depPaths = []) {
let modulePath;
//let millis = Date.now();
const resolve = function (moduleName, options) {
try {
return require.resolve(moduleName, options);
Expand All @@ -270,6 +271,7 @@ module.exports = function (log, projectInfo) {
});
if (modulePath) break;
}
//console.log(`resolveNodeModule filter took ${Date.now() - millis}ms`, moduleName);
return modulePath;
}

Expand Down Expand Up @@ -710,7 +712,7 @@ module.exports = function (log, projectInfo) {
} else {
// derive the module path from the package.json entries browser, module or main
try {
const pkgJsonModuleName = path.join(moduleName, "package.json");
const pkgJsonModuleName = path.posix.join(moduleName, "package.json");
const pkgJson = require(pkgJsonModuleName);
const resolveModulePath = function (exports, fields) {
for (const field of fields) {
Expand Down
Loading