@ms-cloudpack/bundler-rspack 0.2.18 → 0.2.20

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getRspackConfiguration.d.ts","sourceRoot":"","sources":["../src/getRspackConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAA+C,MAAM,cAAc,CAAC;AAM/F,wBAAgB,sBAAsB,CACpC,MAAM,EAAE;IACN,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC;IACvD,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,EAC3C,OAAO,EAAE,aAAa,GACrB,aAAa,CAgMf"}
1
+ {"version":3,"file":"getRspackConfiguration.d.ts","sourceRoot":"","sources":["../src/getRspackConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAA+C,MAAM,cAAc,CAAC;AAK/F,wBAAgB,sBAAsB,CACpC,MAAM,EAAE;IACN,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC;IACvD,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,EAC3C,OAAO,EAAE,aAAa,GACrB,aAAa,CAgMf"}
@@ -1,8 +1,7 @@
1
- import { getSwcConfig, shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';
1
+ import { getModuleSearchPaths, getSwcConfig, shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';
2
2
  import rspack from '@rspack/core';
3
3
  import semver from 'semver';
4
4
  import { merge } from 'webpack-merge';
5
- import { getPathsOfModules } from './getPathsOfModules.js';
6
5
  export function getRspackConfiguration(params, context) {
7
6
  const { options, outputPath, newEntries } = params;
8
7
  const { unsafeDisableInlineSvg: _, ...bundlerOptions } = options.bundlerOptions || {};
@@ -28,7 +27,7 @@ export function getRspackConfiguration(params, context) {
28
27
  // Resolve loaders from the package's node_modules
29
28
  'node_modules',
30
29
  // Cloudpack provided loaders
31
- ...getPathsOfModules(['css-loader', 'style-loader', 'sass-loader']),
30
+ ...getModuleSearchPaths(['css-loader', 'style-loader', 'sass-loader'], import.meta.url),
32
31
  ],
33
32
  },
34
33
  externals: isLibraryMode
@@ -1 +1 @@
1
- {"version":3,"file":"getRspackConfiguration.js","sourceRoot":"","sources":["../src/getRspackConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAIzF,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,UAAU,sBAAsB,CACpC,MAG2C,EAC3C,OAAsB;IAEtB,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACnD,MAAM,EAAE,sBAAsB,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;IAEtF,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;IAExD,MAAM,SAAS,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,SAAS,E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CAA4C;gBAC5C,wCAAwC;gBACxC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,aAAa,EAAE,CAAC;gBAExF,MAAM,EAAE,KAAK;gBAEb,6CAA6C;gBAE7C,4FAA4F;gBAC5F,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;gBAEjC,WAAW,EAAE;oBACX,cAAc,EAAE,KAAK;iBACtB;aACF;SACF;KACF,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { getSwcConfig, shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleContext, BundleOptions } from '@ms-cloudpack/common-types';\nimport type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';\nimport type { Configuration, ExternalItemFunctionData, ExternalItemValue } from '@rspack/core';\nimport rspack from '@rspack/core';\nimport semver from 'semver';\nimport { merge } from 'webpack-merge';\nimport { getPathsOfModules } from './getPathsOfModules.js';\n\nexport function getRspackConfiguration(\n params: {\n options: Omit<BundleOptions, 'entries' | 'outputPath'>;\n outputPath: string;\n } & Pick<WriteESMStubsResult, 'newEntries'>,\n context: BundleContext,\n): Configuration {\n const { options, outputPath, newEntries } = params;\n const { unsafeDisableInlineSvg: _, ...bundlerOptions } = options.bundlerOptions || {};\n\n const isLibraryMode = context.config.mode === 'library';\n\n const swcConfig = getSwcConfig({ packagePath: options.inputPath, sourcemap: options.sourcemap });\n\n const config: Configuration = {\n mode: options.minify ? 'production' : 'development',\n // For Rspack, it looks like this following is still needed as unit tests fail without removing the './'.\n // Webpack (at least older versions) expects entry keys without a leading `./`.\n // (The leading `./` seems to be okay with the latest version, but in older versions, it appears\n // to cause the runtime chunk runtime.js to be generated with an incorrect relative path?)\n entry: Object.fromEntries(Object.entries(newEntries).map(([key, value]) => [key.replace(/^\\.\\//, ''), value])),\n context: options.inputPath,\n resolve: {\n extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json'],\n extensionAlias: {\n '.js': ['.ts', '.js', '.tsx', '.jsx'],\n '.mjs': ['.mts', '.mjs'],\n },\n },\n resolveLoader: {\n modules: [\n // Resolve loaders from the package's node_modules\n 'node_modules',\n\n // Cloudpack provided loaders\n ...getPathsOfModules(['css-loader', 'style-loader', 'sass-loader']),\n ],\n },\n externals: isLibraryMode\n ? // These types can't be inferred due to use of zod types (which may be slightly incorrect too,\n // since they don't allow returning undefined from the async version).\n // Issue: https://github.com/web-infra-dev/rspack/issues/7979\n // There's discussion here of moving away from zod types: https://github.com/web-infra-dev/rspack/issues/4241\n // eslint-disable-next-line @typescript-eslint/require-await -- API signature uses a promise\n async (ctx: ExternalItemFunctionData): Promise<ExternalItemValue | undefined> => {\n if (\n ctx.request &&\n !ctx.request.includes('!') && // webpack loader\n shouldExternalizePackage({\n id: ctx.request,\n inlined: options.inlined,\n external: options.external,\n shouldInlineNodeBuiltins: false,\n })\n ) {\n return ctx.request;\n }\n }\n : [],\n target: ['web', 'es2020'],\n //plugins: [new rspack.CssExtractRspackPlugin({})],\n module: {\n rules: [\n {\n oneOf: [\n // Rule for global CSS files\n {\n test: /\\.global\\.css$/,\n use: [\n 'style-loader',\n {\n loader: 'css-loader',\n options: {\n modules: {\n localIdentName: '[local]', // Use the local name for global CSS\n },\n },\n },\n ],\n },\n // Rule for CSS Modules files\n {\n test: /\\.module\\.css$/,\n use: [\n 'style-loader',\n {\n loader: 'css-loader',\n options: {\n modules: true, // Enable CSS Modules\n },\n },\n ],\n },\n // Rule for regular CSS files\n {\n test: /\\.css$/,\n exclude: /\\.module\\.css$/, // Exclude CSS Modules files\n use: [\n 'style-loader',\n 'css-loader', // Use css-loader without CSS Modules for regular CSS\n ],\n },\n ],\n },\n {\n test: /\\.json$/,\n type: 'json',\n sideEffects: false,\n },\n {\n test: /\\.ejs$/,\n loader: 'ejs-loader',\n options: {\n variable: 'data',\n esModule: true,\n },\n resolve: {\n fullySpecified: false,\n },\n },\n {\n // transform internal jsx files\n test: /\\.[cm]?jsx$/,\n loader: 'builtin:swc-loader',\n exclude: [/node_modules/],\n options: swcConfig.js,\n type: 'javascript/auto',\n },\n {\n // transform internal ts files\n test: /\\.[cm]?tsx?$/,\n loader: 'builtin:swc-loader',\n exclude: [/node_modules/],\n options: swcConfig.ts,\n type: 'javascript/auto',\n },\n {\n test: /\\.s[ac]ss$/i,\n use: ['style-loader', 'css-loader', 'sass-loader'],\n },\n {\n test: /\\.worker\\.js$/,\n use: { loader: 'worker-rspack-loader' },\n },\n {\n test: /\\.wasm$/i,\n type: 'asset/resource',\n },\n ],\n },\n output: {\n library: {\n type: 'module',\n },\n chunkFormat: 'module',\n chunkLoading: 'import',\n path: outputPath,\n module: true,\n filename: '[name].js',\n chunkFilename: '[id].chunk.js',\n },\n experiments: {\n outputModule: true,\n css: false,\n },\n devtool: options.sourcemap ? (isLibraryMode ? 'cheap-module-source-map' : 'source-map') : false,\n optimization: {\n runtimeChunk: 'single',\n minimize: options.minify,\n mangleExports: false,\n splitChunks: {\n // Prevents exposing path info when creating names for parts splitted by maxSize.\n hidePathInfo: true,\n\n // Figure out which exports are used by modules to mangle export names, omit unused\n // exports and generate more efficient code.\n // This option was added in 1.0.0-beta.4\n ...(semver.gte(rspack.rspackVersion, '1.0.0-beta.4') && { usedExports: !isLibraryMode }),\n\n chunks: 'all',\n\n //name: '[id].chunk', //TODO: is this needed?\n\n // Production chunks should be at least 1000 bytes to prevent large numbers of file requests\n minSize: isLibraryMode ? 0 : 1000,\n\n cacheGroups: {\n defaultVendors: false,\n },\n },\n },\n };\n\n if (Object.keys(bundlerOptions).length) {\n return merge(config, bundlerOptions);\n }\n\n return config;\n}\n"]}
1
+ {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["import { getModuleSearchPaths, getSwcConfig, shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleContext, BundleOptions } from '@ms-cloudpack/common-types';\nimport type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';\nimport type { Configuration, ExternalItemFunctionData, ExternalItemValue } from '@rspack/core';\nimport rspack from '@rspack/core';\nimport semver from 'semver';\nimport { merge } from 'webpack-merge';\n\nexport function getRspackConfiguration(\n params: {\n options: Omit<BundleOptions, 'entries' | 'outputPath'>;\n outputPath: string;\n } & Pick<WriteESMStubsResult, 'newEntries'>,\n context: BundleContext,\n): Configuration {\n const { options, outputPath, newEntries } = params;\n const { unsafeDisableInlineSvg: _, ...bundlerOptions } = options.bundlerOptions || {};\n\n const isLibraryMode = context.config.mode === 'library';\n\n const swcConfig = getSwcConfig({ packagePath: options.inputPath, sourcemap: options.sourcemap });\n\n const config: Configuration = {\n mode: options.minify ? 'production' : 'development',\n // For Rspack, it looks like this following is still needed as unit tests fail without removing the './'.\n // Webpack (at least older versions) expects entry keys without a leading `./`.\n // (The leading `./` seems to be okay with the latest version, but in older versions, it appears\n // to cause the runtime chunk runtime.js to be generated with an incorrect relative path?)\n entry: Object.fromEntries(Object.entries(newEntries).map(([key, value]) => [key.replace(/^\\.\\//, ''), value])),\n context: options.inputPath,\n resolve: {\n extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json'],\n extensionAlias: {\n '.js': ['.ts', '.js', '.tsx', '.jsx'],\n '.mjs': ['.mts', '.mjs'],\n },\n },\n resolveLoader: {\n modules: [\n // Resolve loaders from the package's node_modules\n 'node_modules',\n\n // Cloudpack provided loaders\n ...getModuleSearchPaths(['css-loader', 'style-loader', 'sass-loader'], import.meta.url),\n ],\n },\n externals: isLibraryMode\n ? // These types can't be inferred due to use of zod types (which may be slightly incorrect too,\n // since they don't allow returning undefined from the async version).\n // Issue: https://github.com/web-infra-dev/rspack/issues/7979\n // There's discussion here of moving away from zod types: https://github.com/web-infra-dev/rspack/issues/4241\n // eslint-disable-next-line @typescript-eslint/require-await -- API signature uses a promise\n async (ctx: ExternalItemFunctionData): Promise<ExternalItemValue | undefined> => {\n if (\n ctx.request &&\n !ctx.request.includes('!') && // webpack loader\n shouldExternalizePackage({\n id: ctx.request,\n inlined: options.inlined,\n external: options.external,\n shouldInlineNodeBuiltins: false,\n })\n ) {\n return ctx.request;\n }\n }\n : [],\n target: ['web', 'es2020'],\n //plugins: [new rspack.CssExtractRspackPlugin({})],\n module: {\n rules: [\n {\n oneOf: [\n // Rule for global CSS files\n {\n test: /\\.global\\.css$/,\n use: [\n 'style-loader',\n {\n loader: 'css-loader',\n options: {\n modules: {\n localIdentName: '[local]', // Use the local name for global CSS\n },\n },\n },\n ],\n },\n // Rule for CSS Modules files\n {\n test: /\\.module\\.css$/,\n use: [\n 'style-loader',\n {\n loader: 'css-loader',\n options: {\n modules: true, // Enable CSS Modules\n },\n },\n ],\n },\n // Rule for regular CSS files\n {\n test: /\\.css$/,\n exclude: /\\.module\\.css$/, // Exclude CSS Modules files\n use: [\n 'style-loader',\n 'css-loader', // Use css-loader without CSS Modules for regular CSS\n ],\n },\n ],\n },\n {\n test: /\\.json$/,\n type: 'json',\n sideEffects: false,\n },\n {\n test: /\\.ejs$/,\n loader: 'ejs-loader',\n options: {\n variable: 'data',\n esModule: true,\n },\n resolve: {\n fullySpecified: false,\n },\n },\n {\n // transform internal jsx files\n test: /\\.[cm]?jsx$/,\n loader: 'builtin:swc-loader',\n exclude: [/node_modules/],\n options: swcConfig.js,\n type: 'javascript/auto',\n },\n {\n // transform internal ts files\n test: /\\.[cm]?tsx?$/,\n loader: 'builtin:swc-loader',\n exclude: [/node_modules/],\n options: swcConfig.ts,\n type: 'javascript/auto',\n },\n {\n test: /\\.s[ac]ss$/i,\n use: ['style-loader', 'css-loader', 'sass-loader'],\n },\n {\n test: /\\.worker\\.js$/,\n use: { loader: 'worker-rspack-loader' },\n },\n {\n test: /\\.wasm$/i,\n type: 'asset/resource',\n },\n ],\n },\n output: {\n library: {\n type: 'module',\n },\n chunkFormat: 'module',\n chunkLoading: 'import',\n path: outputPath,\n module: true,\n filename: '[name].js',\n chunkFilename: '[id].chunk.js',\n },\n experiments: {\n outputModule: true,\n css: false,\n },\n devtool: options.sourcemap ? (isLibraryMode ? 'cheap-module-source-map' : 'source-map') : false,\n optimization: {\n runtimeChunk: 'single',\n minimize: options.minify,\n mangleExports: false,\n splitChunks: {\n // Prevents exposing path info when creating names for parts splitted by maxSize.\n hidePathInfo: true,\n\n // Figure out which exports are used by modules to mangle export names, omit unused\n // exports and generate more efficient code.\n // This option was added in 1.0.0-beta.4\n ...(semver.gte(rspack.rspackVersion, '1.0.0-beta.4') && { usedExports: !isLibraryMode }),\n\n chunks: 'all',\n\n //name: '[id].chunk', //TODO: is this needed?\n\n // Production chunks should be at least 1000 bytes to prevent large numbers of file requests\n minSize: isLibraryMode ? 0 : 1000,\n\n cacheGroups: {\n defaultVendors: false,\n },\n },\n },\n };\n\n if (Object.keys(bundlerOptions).length) {\n return merge(config, bundlerOptions);\n }\n\n return config;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-rspack",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "A cloudpack plugin for abstracting rspack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,17 +14,16 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-capabilities": "^0.2.7",
18
- "@ms-cloudpack/bundler-utilities": "^0.1.21",
19
- "@ms-cloudpack/common-types": "^0.24.2",
20
- "@ms-cloudpack/esm-stub-utilities": "^0.14.2",
17
+ "@ms-cloudpack/bundler-capabilities": "^0.2.8",
18
+ "@ms-cloudpack/bundler-utilities": "^0.1.22",
19
+ "@ms-cloudpack/common-types": "^0.24.3",
20
+ "@ms-cloudpack/esm-stub-utilities": "^0.14.3",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.6",
22
- "@ms-cloudpack/path-utilities": "^2.8.3",
23
- "@rspack/core": "^1.1.8",
22
+ "@ms-cloudpack/path-utilities": "^2.8.4",
23
+ "@rspack/core": "^1.1.8 || ^1.1.8-beta.0",
24
24
  "@swc/core": "^1.3.0",
25
25
  "css-loader": "^6.0.0",
26
26
  "ejs-loader": "^0.5.0",
27
- "import-meta-resolve": "^4.0.0",
28
27
  "sass": "^1.0.0",
29
28
  "sass-loader": "^14.0.0",
30
29
  "semver": "^7.6.0",
@@ -1,8 +0,0 @@
1
- /**
2
- * Resolves the paths of the provided modules relative to the bundler-webpack package,
3
- * and returns a list of unique containing folders which webpack can use as module search paths.
4
- * @param modules - The modules to resolve. Must be dependencies of this package.
5
- * @returns - Containing folders of the modules. (ie: /path/to/node_modules/)
6
- */
7
- export declare function getPathsOfModules(modules: string[]): string[];
8
- //# sourceMappingURL=getPathsOfModules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getPathsOfModules.d.ts","sourceRoot":"","sources":["../src/getPathsOfModules.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAc7D"}
@@ -1,28 +0,0 @@
1
- // temporarily duplicated from bundler-webpck
2
- import { makeUrl } from '@ms-cloudpack/path-string-parsing';
3
- import { findPackageRoot } from '@ms-cloudpack/path-utilities';
4
- import { moduleResolve } from 'import-meta-resolve';
5
- import path from 'path';
6
- import { fileURLToPath } from 'url';
7
- const conditions = new Set(['node', 'require', 'import', 'default']);
8
- const resolveFrom = makeUrl(import.meta.url);
9
- /**
10
- * Resolves the paths of the provided modules relative to the bundler-webpack package,
11
- * and returns a list of unique containing folders which webpack can use as module search paths.
12
- * @param modules - The modules to resolve. Must be dependencies of this package.
13
- * @returns - Containing folders of the modules. (ie: /path/to/node_modules/)
14
- */
15
- export function getPathsOfModules(modules) {
16
- const paths = new Set();
17
- for (const moduleName of modules) {
18
- // Resolve the module path and find the package root from there.
19
- // preserveSymlinks ensures we get the path where it's installed as a dependency, not from the store.
20
- const modulePath = moduleResolve(moduleName, resolveFrom, conditions, true /*preserveSymlinks*/);
21
- const packageRoot = findPackageRoot(fileURLToPath(modulePath));
22
- if (packageRoot) {
23
- paths.add(path.dirname(packageRoot));
24
- }
25
- }
26
- return Array.from(paths);
27
- }
28
- //# sourceMappingURL=getPathsOfModules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getPathsOfModules.js","sourceRoot":"","sources":["../src/getPathsOfModules.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,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;AACrE,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAiB;IACjD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,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":["// temporarily duplicated from bundler-webpck\nimport { 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']);\nconst resolveFrom = makeUrl(import.meta.url);\n\n/**\n * Resolves the paths of the provided modules relative to the bundler-webpack package,\n * and returns a list of unique containing folders which webpack can use as module search paths.\n * @param modules - The modules to resolve. Must be dependencies of this package.\n * @returns - Containing folders of the modules. (ie: /path/to/node_modules/)\n */\nexport function getPathsOfModules(modules: string[]): string[] {\n const paths = new Set<string>();\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"]}