@ms-cloudpack/bundler-utilities 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Resolve the given modules relative to the calling package, and return a list of unique
3
+ * containing folders (usually `node_modules` folders) which webpack/rspack can use as module
4
+ * search paths in `config.resolveLoader.modules`.
5
+ * @param modules - The modules to resolve. Must be dependencies of this package.
6
+ * @param resolveFromImportMetaUrl - The `import.meta.url` of the calling file.
7
+ * @returns - Containing folders of the modules. (ie: `/path/to/node_modules/`)
8
+ */
9
+ export declare function getModuleSearchPaths(modules: string[], resolveFromImportMetaUrl: string): string[];
10
+ //# sourceMappingURL=getModuleSearchPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getModuleSearchPaths.d.ts","sourceRoot":"","sources":["../src/getModuleSearchPaths.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,wBAAwB,EAAE,MAAM,GAAG,MAAM,EAAE,CAelG"}
@@ -0,0 +1,29 @@
1
+ import { makeUrl } from '@ms-cloudpack/path-string-parsing';
2
+ import { findPackageRoot } from '@ms-cloudpack/path-utilities';
3
+ import { moduleResolve } from 'import-meta-resolve';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ const conditions = new Set(['node', 'require', 'import', 'default']);
7
+ /**
8
+ * Resolve the given modules relative to the calling package, and return a list of unique
9
+ * containing folders (usually `node_modules` folders) which webpack/rspack can use as module
10
+ * search paths in `config.resolveLoader.modules`.
11
+ * @param modules - The modules to resolve. Must be dependencies of this package.
12
+ * @param resolveFromImportMetaUrl - The `import.meta.url` of the calling file.
13
+ * @returns - Containing folders of the modules. (ie: `/path/to/node_modules/`)
14
+ */
15
+ export function getModuleSearchPaths(modules, resolveFromImportMetaUrl) {
16
+ const paths = new Set();
17
+ const resolveFrom = makeUrl(resolveFromImportMetaUrl);
18
+ for (const moduleName of modules) {
19
+ // Resolve the module path and find the package root from there.
20
+ // preserveSymlinks ensures we get the path where it's installed as a dependency, not from the store.
21
+ const modulePath = moduleResolve(moduleName, resolveFrom, conditions, true /*preserveSymlinks*/);
22
+ const packageRoot = findPackageRoot(fileURLToPath(modulePath));
23
+ if (packageRoot) {
24
+ paths.add(path.dirname(packageRoot));
25
+ }
26
+ }
27
+ return Array.from(paths);
28
+ }
29
+ //# sourceMappingURL=getModuleSearchPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getModuleSearchPaths.js","sourceRoot":"","sources":["../src/getModuleSearchPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAiB,EAAE,wBAAgC;IACtF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,WAAW,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAEtD,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,gEAAgE;QAChE,qGAAqG;QACrG,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjG,MAAM,WAAW,GAAG,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;QAC/D,IAAI,WAAW,EAAE,CAAC;YAChB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { findPackageRoot } from '@ms-cloudpack/path-utilities';\nimport { moduleResolve } from 'import-meta-resolve';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst conditions = new Set(['node', 'require', 'import', 'default']);\n\n/**\n * Resolve the given modules relative to the calling package, and return a list of unique\n * containing folders (usually `node_modules` folders) which webpack/rspack can use as module\n * search paths in `config.resolveLoader.modules`.\n * @param modules - The modules to resolve. Must be dependencies of this package.\n * @param resolveFromImportMetaUrl - The `import.meta.url` of the calling file.\n * @returns - Containing folders of the modules. (ie: `/path/to/node_modules/`)\n */\nexport function getModuleSearchPaths(modules: string[], resolveFromImportMetaUrl: string): string[] {\n const paths = new Set<string>();\n const resolveFrom = makeUrl(resolveFromImportMetaUrl);\n\n for (const moduleName of modules) {\n // Resolve the module path and find the package root from there.\n // preserveSymlinks ensures we get the path where it's installed as a dependency, not from the store.\n const modulePath = moduleResolve(moduleName, resolveFrom, conditions, true /*preserveSymlinks*/);\n const packageRoot = findPackageRoot(fileURLToPath(modulePath));\n if (packageRoot) {\n paths.add(path.dirname(packageRoot));\n }\n }\n\n return Array.from(paths);\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { defaultTargetSyntax, base64AssetExtensions } from './constants.js';
2
+ export { getModuleSearchPaths } from './getModuleSearchPaths.js';
2
3
  export { getSwcConfig } from './getSwcConfig.js';
3
4
  export { shouldExternalizePackage } from './shouldExternalizePackage.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { defaultTargetSyntax, base64AssetExtensions } from './constants.js';
2
+ export { getModuleSearchPaths } from './getModuleSearchPaths.js';
2
3
  export { getSwcConfig } from './getSwcConfig.js';
3
4
  export { shouldExternalizePackage } from './shouldExternalizePackage.js';
4
5
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["export { defaultTargetSyntax, base64AssetExtensions } from './constants.js';\nexport { getSwcConfig } from './getSwcConfig.js';\nexport { shouldExternalizePackage } from './shouldExternalizePackage.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["export { defaultTargetSyntax, base64AssetExtensions } from './constants.js';\nexport { getModuleSearchPaths } from './getModuleSearchPaths.js';\nexport { getSwcConfig } from './getSwcConfig.js';\nexport { shouldExternalizePackage } from './shouldExternalizePackage.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-utilities",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Utilities used by multiple bundlers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,9 +15,11 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@ms-cloudpack/json-utilities": "^0.1.10",
18
- "@ms-cloudpack/package-utilities": "^11.1.2",
18
+ "@ms-cloudpack/package-utilities": "^11.2.0",
19
19
  "@ms-cloudpack/path-string-parsing": "^1.2.6",
20
+ "@ms-cloudpack/path-utilities": "^2.8.4",
20
21
  "get-tsconfig": "^4.7.2",
22
+ "import-meta-resolve": "^4.0.0",
21
23
  "tsconfig-to-swcconfig": "^2.7.0"
22
24
  },
23
25
  "devDependencies": {