diff --git a/packages/ui5-tooling-modules/lib/middleware.js b/packages/ui5-tooling-modules/lib/middleware.js index e927e9d8..3817695a 100644 --- a/packages/ui5-tooling-modules/lib/middleware.js +++ b/packages/ui5-tooling-modules/lib/middleware.js @@ -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 diff --git a/packages/ui5-tooling-modules/lib/rollup-plugin-webcomponents.js b/packages/ui5-tooling-modules/lib/rollup-plugin-webcomponents.js index d0866e40..c4807ad5 100644 --- a/packages/ui5-tooling-modules/lib/rollup-plugin-webcomponents.js +++ b/packages/ui5-tooling-modules/lib/rollup-plugin-webcomponents.js @@ -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 @@ -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"; diff --git a/packages/ui5-tooling-modules/lib/util.js b/packages/ui5-tooling-modules/lib/util.js index 2a5ce434..7f4b51c3 100755 --- a/packages/ui5-tooling-modules/lib/util.js +++ b/packages/ui5-tooling-modules/lib/util.js @@ -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); @@ -270,6 +271,7 @@ module.exports = function (log, projectInfo) { }); if (modulePath) break; } + //console.log(`resolveNodeModule filter took ${Date.now() - millis}ms`, moduleName); return modulePath; } @@ -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) {