@ms-cloudpack/bundler-rspack 0.2.26 → 0.2.28

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;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
+ {"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,CAiNf"}
@@ -1,11 +1,15 @@
1
1
  import { getModuleSearchPaths, getSwcConfig, shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';
2
2
  import rspack from '@rspack/core';
3
+ import { isBuiltin } from 'module';
3
4
  import semver from 'semver';
4
5
  import { merge } from 'webpack-merge';
5
6
  export function getRspackConfiguration(params, context) {
6
7
  const { options, outputPath, newEntries } = params;
8
+ const { targetEnvironment } = options;
7
9
  const { unsafeDisableInlineSvg: _, ...bundlerOptions } = options.bundlerOptions || {};
8
- const isLibraryMode = context.config.mode === 'library';
10
+ const outputScriptExtension = targetEnvironment === 'node' ? 'mjs' : 'js';
11
+ // Currently, targetEnvironment: node forces production mode since we don't have Node import map support
12
+ const isLibraryMode = context.config.mode === 'library' && options.targetEnvironment !== 'node';
9
13
  const swcConfig = getSwcConfig({ packagePath: options.inputPath, sourcemap: options.sourcemap });
10
14
  const config = {
11
15
  mode: options.minify ? 'production' : 'development',
@@ -30,26 +34,36 @@ export function getRspackConfiguration(params, context) {
30
34
  ...getModuleSearchPaths(['css-loader', 'style-loader', 'sass-loader'], import.meta.url),
31
35
  ],
32
36
  },
33
- externals: isLibraryMode
34
- ? // These types can't be inferred due to use of zod types (which may be slightly incorrect too,
35
- // since they don't allow returning undefined from the async version).
37
+ externals:
38
+ // In production mode for browser bundles, we don't externalize anything.
39
+ !isLibraryMode && targetEnvironment === 'browser'
40
+ ? [] // These types can't be inferred due to use of zod types (which may be slightly incorrect too,
41
+ : // since they don't allow returning undefined from the async version).
36
42
  // Issue: https://github.com/web-infra-dev/rspack/issues/7979
37
43
  // There's discussion here of moving away from zod types: https://github.com/web-infra-dev/rspack/issues/4241
38
44
  // eslint-disable-next-line @typescript-eslint/require-await -- API signature uses a promise
39
45
  async (ctx) => {
40
- if (ctx.request &&
41
- !ctx.request.includes('!') && // webpack loader
42
- shouldExternalizePackage({
43
- id: ctx.request,
44
- inlined: options.inlined,
45
- external: options.external,
46
- shouldInlineNodeBuiltins: false,
47
- })) {
48
- return ctx.request;
46
+ const { request } = ctx;
47
+ // ! is a webpack loader prefix.
48
+ if (!request || request.includes('!')) {
49
+ return;
49
50
  }
50
- }
51
- : [],
52
- target: ['web', 'es2020'],
51
+ if (targetEnvironment === 'node') {
52
+ // It appears that with webpack `target: 'node'`, this must be manually added to built-ins
53
+ // (the setting `externalsType: 'module-import'` isn't respected).
54
+ // Otherwise webpack will load them with require...
55
+ return isBuiltin(request) ? `module-import ${request}` : undefined;
56
+ }
57
+ if (shouldExternalizePackage({
58
+ id: request,
59
+ inlined: options.inlined,
60
+ external: options.external,
61
+ shouldInlineNodeBuiltins: false,
62
+ })) {
63
+ return request;
64
+ }
65
+ },
66
+ target: [targetEnvironment === 'node' ? 'node18' : 'web', 'es2022'],
53
67
  //plugins: [new rspack.CssExtractRspackPlugin({})],
54
68
  module: {
55
69
  rules: [
@@ -148,8 +162,8 @@ export function getRspackConfiguration(params, context) {
148
162
  chunkLoading: 'import',
149
163
  path: outputPath,
150
164
  module: true,
151
- filename: '[name].js',
152
- chunkFilename: '[id].chunk.js',
165
+ filename: `[name].${outputScriptExtension}`,
166
+ chunkFilename: `[id].chunk.${outputScriptExtension}`,
153
167
  },
154
168
  experiments: {
155
169
  outputModule: true,
@@ -169,6 +183,8 @@ export function getRspackConfiguration(params, context) {
169
183
  ...(semver.gte(rspack.rspackVersion, '1.0.0-beta.4') && { usedExports: !isLibraryMode }),
170
184
  chunks: 'all',
171
185
  //name: '[id].chunk', //TODO: is this needed?
186
+ // webpack version:
187
+ // filename: `[id].chunk.${outputScriptExtension}`,
172
188
  // Production chunks should be at least 1000 bytes to prevent large numbers of file requests
173
189
  minSize: isLibraryMode ? 0 : 1000,
174
190
  cacheGroups: {
@@ -1 +1 @@
1
- {"version":3,"file":"getRspackConfiguration.js","sourceRoot":"","sources":["../src/getRspackConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAI/G,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,E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AAQ,EAAE,WAAW;YACrB,aAAa,EAAE,eAAe;SAC/B;QACD,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,GAAG,EAAE,KAAK;SACX;QACD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK;QAC/F,YAAY,EAAE;YACZ,YAAY,EAAE,QAAQ;YACtB,QAAQ,EAAE,OAAO,CAAC,MAAM;YACxB,aAAa,EAAE,KAAK;YACpB,WAAW,EAAE;gBACX,iFAAiF;gBACjF,YAAY,EAAE,IAAI;gBAElB,mFAAmF;gBACnF,4CAA4C;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 { 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.jsx,\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.tsx,\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
+ {"version":3,"file":"getRspackConfiguration.js","sourceRoot":"","sources":["../src/getRspackConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAI/G,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,UAAU,sBAAsB,CACpC,MAG2C,EAC3C,OAAsB;IAEtB,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACnD,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,sBAAsB,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;IACtF,MAAM,qBAAqB,GAAG,iBAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAE1E,wGAAwG;IACxG,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,KAA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B,YAAY,EAAE,QAAQ;YACtB,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,UAAU,qBAAqB,EAAE;YAC3C,aAAa,EAAE,cAAc,qBAAqB,EAAE;SACrD;QACD,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,GAAG,EAAE,KAAK;SACX;QACD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK;QAC/F,YAAY,EAAE;YACZ,YAAY,EAAE,QAAQ;YACtB,QAAQ,EAAE,OAAO,CAAC,MAAM;YACxB,aAAa,EAAE,KAAK;YACpB,WAAW,EAAE;gBACX,iFAAiF;gBACjF,YAAY,EAAE,IAAI;gBAElB,mFAAmF;gBACnF,4CAA4C;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;gBAC7C,mBAAmB;gBACnB,mDAAmD;gBAEnD,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 { 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 { isBuiltin } from 'module';\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 { targetEnvironment } = options;\n const { unsafeDisableInlineSvg: _, ...bundlerOptions } = options.bundlerOptions || {};\n const outputScriptExtension = targetEnvironment === 'node' ? 'mjs' : 'js';\n\n // Currently, targetEnvironment: node forces production mode since we don't have Node import map support\n const isLibraryMode = context.config.mode === 'library' && options.targetEnvironment !== 'node';\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:\n // In production mode for browser bundles, we don't externalize anything.\n !isLibraryMode && targetEnvironment === 'browser'\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 const { request } = ctx;\n // ! is a webpack loader prefix.\n if (!request || request.includes('!')) {\n return;\n }\n\n if (targetEnvironment === 'node') {\n // It appears that with webpack `target: 'node'`, this must be manually added to built-ins\n // (the setting `externalsType: 'module-import'` isn't respected).\n // Otherwise webpack will load them with require...\n return isBuiltin(request) ? `module-import ${request}` : undefined;\n }\n\n if (\n shouldExternalizePackage({\n id: request,\n inlined: options.inlined,\n external: options.external,\n shouldInlineNodeBuiltins: false,\n })\n ) {\n return request;\n }\n },\n target: [targetEnvironment === 'node' ? 'node18' : 'web', 'es2022'],\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.jsx,\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.tsx,\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].${outputScriptExtension}`,\n chunkFilename: `[id].chunk.${outputScriptExtension}`,\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 // webpack version:\n // filename: `[id].chunk.${outputScriptExtension}`,\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 +1 @@
1
- {"version":3,"file":"normalizeRspackOutput.d.ts","sourceRoot":"","sources":["../src/normalizeRspackOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,aAAa,EAAoB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAc,MAAM,cAAc,CAAC;AAEhF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,oBAAoB;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,uBAAuB;IACvB,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IACtD,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CAAC;CACrC,GAAG,aAAa,CAoDhB"}
1
+ {"version":3,"file":"normalizeRspackOutput.d.ts","sourceRoot":"","sources":["../src/normalizeRspackOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,aAAa,EAAoB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAc,MAAM,cAAc,CAAC;AAIhF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,oBAAoB;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,uBAAuB;IACvB,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IACtD,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CAAC;CACrC,GAAG,aAAa,CAoDhB"}
@@ -1,6 +1,7 @@
1
1
  import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
2
2
  import { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';
3
3
  import path from 'path';
4
+ const outExtRegex = /\.m?js$/;
4
5
  export function normalizeRspackOutput(params) {
5
6
  const { config, options: { entries, inputPath }, outputPath, stats, } = params;
6
7
  // Process the errors and warnings from the stats json.
@@ -12,8 +13,8 @@ export function normalizeRspackOutput(params) {
12
13
  outputPath: normalizeRelativePath(asset.name),
13
14
  };
14
15
  // Webpack doesn't include entry point info in the output, so add manually if applicable
15
- if (outFile.outputPath.endsWith('.js')) {
16
- const entryPoint = entries[outFile.outputPath.replace(/\.js$/, '')];
16
+ if (outExtRegex.test(outFile.outputPath)) {
17
+ const entryPoint = entries[outFile.outputPath.replace(outExtRegex, '')];
17
18
  if (entryPoint) {
18
19
  outFile.entryPoint = entryPoint;
19
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeRspackOutput.js","sourceRoot":"","sources":["../src/normalizeRspackOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,UAAU,qBAAqB,CAAC,MASrC;IACC,MAAM,EACJ,MAAM,EACN,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAC/B,UAAU,EACV,KAAK,GACN,GAAG,MAAM,CAAC;IAEX,uDAAuD;IACvD,2DAA2D;IAC3D,OAAO;QACL,UAAU;QACV,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAoB,EAAE;YACjE,MAAM,OAAO,GAAqB;gBAChC,UAAU,EAAE,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC;aAC9C,CAAC;YAEF,wFAAwF;YACxF,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;gBACpE,IAAI,UAAU,EAAE,CAAC;oBACf,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;gBAClC,CAAC;gBAED,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,iBAAiB,IAAI,EAAE,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AAU,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;gBAClC,CAAC;YACH,CAAC;YAED,aAAa,CAAC,QAAQ,GAAG;gBACvB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;oBAC7B,CAAC,CAAC,wBAAwB,CAAC,SAAS,EAAE,QAAQ,CAAC;oBAC/C,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC;gBACnC,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;gBACzD,MAAM,EAAE,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;aAC1D,CAAC;QACJ,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { BundleMessage, BundleOptions, BundleOutputFile, BundlerResult } from '@ms-cloudpack/common-types';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport type { Configuration, StatsCompilation, StatsError } from '@rspack/core';\n\nexport function normalizeRspackOutput(params: {\n /** Rspack config */\n config: Configuration;\n /** Original options */\n options: Pick<BundleOptions, 'entries' | 'inputPath'>;\n /** Absolute output path */\n outputPath: string;\n /** Stats from rspack callback */\n stats: StatsCompilation | undefined;\n}): BundlerResult {\n const {\n config,\n options: { entries, inputPath },\n outputPath,\n stats,\n } = params;\n\n // Process the errors and warnings from the stats json.\n // This provides more straightforward access to file paths.\n return {\n outputPath,\n outputFiles: (stats?.assets || []).map((asset): BundleOutputFile => {\n const outFile: BundleOutputFile = {\n outputPath: normalizeRelativePath(asset.name),\n };\n\n // Webpack doesn't include entry point info in the output, so add manually if applicable\n if (outFile.outputPath.endsWith('.js')) {\n const entryPoint = entries[outFile.outputPath.replace(/\\.js$/, '')];\n if (entryPoint) {\n outFile.entryPoint = entryPoint;\n }\n\n const [chunkName] = Object.entries(stats?.assetsByChunkName ?? {}).find(([_, value]) =>\n value.includes(asset.name),\n ) ?? [undefined];\n const relatedChunk = chunkName ? stats?.chunks?.find((chunk) => chunk.id === chunkName) : undefined;\n const relatedModule = relatedChunk?.modules?.find((module) => module.id === entryPoint);\n outFile.exports = relatedModule?.providedExports ?? undefined;\n\n for (const chunk of stats?.chunks || []) {\n // We don't have enough info to determine if a file is a worker\n if (!chunk.files || !chunk.modules || !chunk.files.includes(asset.name)) {\n continue;\n }\n\n // Check if the chunk has a worker\n if (chunk.modules.some(({ reasons = [] }) => reasons.some((reason) => reason.type === 'new Worker()'))) {\n // It is a worker!\n outFile.isWorker = true;\n }\n }\n }\n\n return outFile;\n }),\n errors: createBundleMessages(stats?.errors, inputPath),\n warnings: createBundleMessages(stats?.warnings, inputPath),\n rawInput: config as unknown as Record<string, unknown>,\n rawOutput: stats,\n };\n}\n\n/** Create BundleMessages from rspackErrors */\nfunction createBundleMessages(rspackErrors: StatsError[] | undefined, inputPath: string): BundleMessage[] {\n return (rspackErrors || []).map((error) => {\n const bundleMessage: BundleMessage = {\n text: error.message,\n source: 'rspack',\n };\n\n const filePath = error.file || error.moduleName;\n\n if (filePath) {\n let [, line, col] = error?.loc?.match(/^(\\d+):(\\d+)/) || [];\n if (!line) {\n // look for something like '[<file path>:<line>:<col>]'\n [, line, col] = error.message.match(/:(\\d+):(\\d+)\\]/) || [];\n }\n if (!line) {\n // rspack errors can look like this:\n // × HarmonyLinkingError: export 'foo' (reexported as 'foo') was not found in './bar.js' (possible exports: bar)\n // ╭────\n // 1 │ export { foo } from './bar.js';\n // · ───────────────────────────────\n // ╰────\n\n // × Module parse failed:\n // ╰─▶ × JavaScript parsing error: Expression expected\n // ╭────\n // 1 │ }export default function() { console.log('oops leading closing bracket'); }\n // · ─\n // ╰────\n // group 1: line number; group 2: length = column number (0-indexed)\n const errorMatch = error.message.match(/(\\d+) │ .*\\n +· ( *)─/);\n if (errorMatch) {\n line = errorMatch[1];\n col = `${errorMatch[2].length}`;\n }\n }\n\n bundleMessage.location = {\n file: path.isAbsolute(filePath)\n ? normalizedPathRelativeTo(inputPath, filePath)\n : normalizeRelativePath(filePath),\n line: typeof line === 'string' ? Number(line) : undefined,\n column: typeof col === 'string' ? Number(col) : undefined,\n };\n }\n\n return bundleMessage;\n });\n}\n"]}
1
+ {"version":3,"file":"normalizeRspackOutput.js","sourceRoot":"","sources":["../src/normalizeRspackOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B,MAAM,UAAU,qBAAqB,CAAC,MASrC;IACC,MAAM,EACJ,MAAM,EACN,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAC/B,UAAU,EACV,KAAK,GACN,GAAG,MAAM,CAAC;IAEX,uDAAuD;IACvD,2DAA2D;IAC3D,OAAO;QACL,UAAU;QACV,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAoB,EAAE;YACjE,MAAM,OAAO,GAAqB;gBAChC,UAAU,EAAE,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC;aAC9C,CAAC;YAEF,wFAAwF;YACxF,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;gBACzC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;gBACxE,IAAI,UAAU,EAAE,CAAC;oBACf,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;gBAClC,CAAC;gBAED,M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AAE,CAAC;oBACf,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;oBACrB,GAAG,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;gBAClC,CAAC;YACH,CAAC;YAED,aAAa,CAAC,QAAQ,GAAG;gBACvB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;oBAC7B,CAAC,CAAC,wBAAwB,CAAC,SAAS,EAAE,QAAQ,CAAC;oBAC/C,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC;gBACnC,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;gBACzD,MAAM,EAAE,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;aAC1D,CAAC;QACJ,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { BundleMessage, BundleOptions, BundleOutputFile, BundlerResult } from '@ms-cloudpack/common-types';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport type { Configuration, StatsCompilation, StatsError } from '@rspack/core';\n\nconst outExtRegex = /\\.m?js$/;\n\nexport function normalizeRspackOutput(params: {\n /** Rspack config */\n config: Configuration;\n /** Original options */\n options: Pick<BundleOptions, 'entries' | 'inputPath'>;\n /** Absolute output path */\n outputPath: string;\n /** Stats from rspack callback */\n stats: StatsCompilation | undefined;\n}): BundlerResult {\n const {\n config,\n options: { entries, inputPath },\n outputPath,\n stats,\n } = params;\n\n // Process the errors and warnings from the stats json.\n // This provides more straightforward access to file paths.\n return {\n outputPath,\n outputFiles: (stats?.assets || []).map((asset): BundleOutputFile => {\n const outFile: BundleOutputFile = {\n outputPath: normalizeRelativePath(asset.name),\n };\n\n // Webpack doesn't include entry point info in the output, so add manually if applicable\n if (outExtRegex.test(outFile.outputPath)) {\n const entryPoint = entries[outFile.outputPath.replace(outExtRegex, '')];\n if (entryPoint) {\n outFile.entryPoint = entryPoint;\n }\n\n const [chunkName] = Object.entries(stats?.assetsByChunkName ?? {}).find(([_, value]) =>\n value.includes(asset.name),\n ) ?? [undefined];\n const relatedChunk = chunkName ? stats?.chunks?.find((chunk) => chunk.id === chunkName) : undefined;\n const relatedModule = relatedChunk?.modules?.find((module) => module.id === entryPoint);\n outFile.exports = relatedModule?.providedExports ?? undefined;\n\n for (const chunk of stats?.chunks || []) {\n // We don't have enough info to determine if a file is a worker\n if (!chunk.files || !chunk.modules || !chunk.files.includes(asset.name)) {\n continue;\n }\n\n // Check if the chunk has a worker\n if (chunk.modules.some(({ reasons = [] }) => reasons.some((reason) => reason.type === 'new Worker()'))) {\n // It is a worker!\n outFile.isWorker = true;\n }\n }\n }\n\n return outFile;\n }),\n errors: createBundleMessages(stats?.errors, inputPath),\n warnings: createBundleMessages(stats?.warnings, inputPath),\n rawInput: config as unknown as Record<string, unknown>,\n rawOutput: stats,\n };\n}\n\n/** Create BundleMessages from rspackErrors */\nfunction createBundleMessages(rspackErrors: StatsError[] | undefined, inputPath: string): BundleMessage[] {\n return (rspackErrors || []).map((error) => {\n const bundleMessage: BundleMessage = {\n text: error.message,\n source: 'rspack',\n };\n\n const filePath = error.file || error.moduleName;\n\n if (filePath) {\n let [, line, col] = error?.loc?.match(/^(\\d+):(\\d+)/) || [];\n if (!line) {\n // look for something like '[<file path>:<line>:<col>]'\n [, line, col] = error.message.match(/:(\\d+):(\\d+)\\]/) || [];\n }\n if (!line) {\n // rspack errors can look like this:\n // × HarmonyLinkingError: export 'foo' (reexported as 'foo') was not found in './bar.js' (possible exports: bar)\n // ╭────\n // 1 │ export { foo } from './bar.js';\n // · ───────────────────────────────\n // ╰────\n\n // × Module parse failed:\n // ╰─▶ × JavaScript parsing error: Expression expected\n // ╭────\n // 1 │ }export default function() { console.log('oops leading closing bracket'); }\n // · ─\n // ╰────\n // group 1: line number; group 2: length = column number (0-indexed)\n const errorMatch = error.message.match(/(\\d+) │ .*\\n +· ( *)─/);\n if (errorMatch) {\n line = errorMatch[1];\n col = `${errorMatch[2].length}`;\n }\n }\n\n bundleMessage.location = {\n file: path.isAbsolute(filePath)\n ? normalizedPathRelativeTo(inputPath, filePath)\n : normalizeRelativePath(filePath),\n line: typeof line === 'string' ? Number(line) : undefined,\n column: typeof col === 'string' ? Number(col) : undefined,\n };\n }\n\n return bundleMessage;\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rspackCapabilities.d.ts","sourceRoot":"","sources":["../src/rspackCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,kBAAkB,EAAE,wCAAwC,CAAC,aAAa,CA2BtF,CAAC"}
1
+ {"version":3,"file":"rspackCapabilities.d.ts","sourceRoot":"","sources":["../src/rspackCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,kBAAkB,EAAE,wCAAwC,CAAC,aAAa,CAiCtF,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { webExtensions } from '@ms-cloudpack/bundler-capabilities';
1
2
  export const rspackCapabilities = {
2
3
  'asset-inline': (config, options) => {
3
4
  // Remove the leading dot from the extensions
@@ -23,6 +24,12 @@ export const rspackCapabilities = {
23
24
  config.externals.unshift(options);
24
25
  return config;
25
26
  },
27
+ 'resolve-web-extensions': (config) => {
28
+ config.resolve ??= {};
29
+ config.resolve.extensions ??= [];
30
+ config.resolve.extensions.unshift(...webExtensions);
31
+ return config;
32
+ },
26
33
  // This is a placeholder for the density capability. It doesn't do anything in the bundler.
27
34
  // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.
28
35
  density: (config) => config,
@@ -1 +1 @@
1
- {"version":3,"file":"rspackCapabilities.js","sourceRoot":"","sources":["../src/rspackCapabilities.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,kBAAkB,GAA4D;IACzF,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QAClC,6CAA6C;QAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/F,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;QACrB,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YACvB,IAAI,EAAE,IAAI,MAAM,CAAC,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;YACtD,IAAI,EAAE,cAAc;SACrB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACzB,qEAAqE;QACrE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;QACxB,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,MAAM,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;QACD,+DAA+D;QAC/D,qEAAqE;QACrE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,2FAA2F;IAC3F,qGAAqG;IACrG,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;CAC5B,CAAC","sourcesContent":["import type { InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';\nimport type { Configuration } from '@rspack/core';\n\nexport const rspackCapabilities: InternalBundlerCapabilityImplementations<Configuration> = {\n 'asset-inline': (config, options) => {\n // Remove the leading dot from the extensions\n const extensions = options.extensions.map((ext) => (ext.startsWith('.') ? ext.slice(1) : ext));\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: new RegExp(`\\\\.(${extensions.join('|')})$`, 'i'),\n type: 'asset/inline',\n });\n return config;\n },\n alias: (config, options) => {\n // Add aliases for externalized packages to the webpack configuration\n if (!config.externals) {\n config.externals = [];\n } else if (!Array.isArray(config.externals)) {\n config.externals = [config.externals];\n }\n // The aliased packaged must be the first element in the array,\n // so that it is resolved before all other packages are externalized.\n config.externals.unshift(options);\n return config;\n },\n // This is a placeholder for the density capability. It doesn't do anything in the bundler.\n // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.\n density: (config) => config,\n};\n"]}
1
+ {"version":3,"file":"rspackCapabilities.js","sourceRoot":"","sources":["../src/rspackCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAInE,MAAM,CAAC,MAAM,kBAAkB,GAA4D;IACzF,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QAClC,6CAA6C;QAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,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type { InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';\nimport type { Configuration } from '@rspack/core';\n\nexport const rspackCapabilities: InternalBundlerCapabilityImplementations<Configuration> = {\n 'asset-inline': (config, options) => {\n // Remove the leading dot from the extensions\n const extensions = options.extensions.map((ext) => (ext.startsWith('.') ? ext.slice(1) : ext));\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: new RegExp(`\\\\.(${extensions.join('|')})$`, 'i'),\n type: 'asset/inline',\n });\n return config;\n },\n alias: (config, options) => {\n // Add aliases for externalized packages to the webpack configuration\n if (!config.externals) {\n config.externals = [];\n } else if (!Array.isArray(config.externals)) {\n config.externals = [config.externals];\n }\n // The aliased packaged must be the first element in the array,\n // so that it is resolved before all other packages are externalized.\n config.externals.unshift(options);\n return config;\n },\n 'resolve-web-extensions': (config) => {\n config.resolve ??= {};\n config.resolve.extensions ??= [];\n config.resolve.extensions.unshift(...webExtensions);\n return config;\n },\n // This is a placeholder for the density capability. It doesn't do anything in the bundler.\n // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.\n density: (config) => config,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-rspack",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "A cloudpack plugin for abstracting rspack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,12 +14,12 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-capabilities": "^0.2.13",
18
- "@ms-cloudpack/bundler-utilities": "^0.2.2",
19
- "@ms-cloudpack/common-types": "^0.24.8",
20
- "@ms-cloudpack/esm-stub-utilities": "^0.14.9",
17
+ "@ms-cloudpack/bundler-capabilities": "^0.2.15",
18
+ "@ms-cloudpack/bundler-utilities": "^0.2.4",
19
+ "@ms-cloudpack/common-types": "^0.24.10",
20
+ "@ms-cloudpack/esm-stub-utilities": "^0.14.11",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.6",
22
- "@ms-cloudpack/path-utilities": "^3.0.5",
22
+ "@ms-cloudpack/path-utilities": "^3.0.7",
23
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",