diff --git a/packages/rspack/etc/core.api.md b/packages/rspack/etc/core.api.md index bb9f357f131a..1999bd97f2d9 100644 --- a/packages/rspack/etc/core.api.md +++ b/packages/rspack/etc/core.api.md @@ -2673,7 +2673,7 @@ export type ExternalItemUmdValue = { // @public export type ExternalItemValue = string | boolean | string[] | ExternalItemUmdValue /** -* when libraryTarget and externalsType is not 'umd' +* when library.type and externalsType is not 'umd' */ | ExternalItemObjectValue; @@ -5543,10 +5543,6 @@ export type Output = { chunkLoadingGlobal?: ChunkLoadingGlobal; enabledLibraryTypes?: EnabledLibraryTypes; library?: Library; - libraryExport?: LibraryExport; - libraryTarget?: LibraryType; - umdNamedDefine?: UmdNamedDefine; - auxiliaryComment?: AuxiliaryComment; module?: OutputModule; strictModuleExceptionHandling?: StrictModuleExceptionHandling; strictModuleErrorHandling?: StrictModuleErrorHandling; diff --git a/packages/rspack/scripts/check-documentation-coverage.ts b/packages/rspack/scripts/check-documentation-coverage.ts index 6f64f9098b71..3ce976e84c8a 100644 --- a/packages/rspack/scripts/check-documentation-coverage.ts +++ b/packages/rspack/scripts/check-documentation-coverage.ts @@ -236,10 +236,6 @@ function checkConfigsDocumentationCoverage() { // "output.workerWasmLoading", // "output.workerPublicPath", // "output.strictModuleExceptionHandling", - // "output.auxiliaryComment.amd", - // "output.auxiliaryComment.commonjs", - // "output.auxiliaryComment.commonjs2", - // "output.auxiliaryComment.root", // "stats", // "optimization.splitChunks", // "optimization.removeAvailableModules", diff --git a/packages/rspack/src/config/defaults.ts b/packages/rspack/src/config/defaults.ts index 9e5a0caf002e..4c4007d8ef1d 100644 --- a/packages/rspack/src/config/defaults.ts +++ b/packages/rspack/src/config/defaults.ts @@ -39,6 +39,7 @@ import type { JavascriptParserOptions, JsonGeneratorOptions, Library, + LibraryOptions, Loader, Mode, ModuleOptions, @@ -550,11 +551,8 @@ const applyOutputDefaults = ( ) => { const getLibraryName = (library: Library): string => { const libraryName = - typeof library === 'object' && - library && - !Array.isArray(library) && - 'type' in library - ? library.name + typeof library === 'object' && library && !Array.isArray(library) + ? (library as LibraryOptions).name : library; if (Array.isArray(libraryName)) { return libraryName.join('.'); diff --git a/packages/rspack/src/config/normalization.ts b/packages/rspack/src/config/normalization.ts index bfea91437f79..a33ae89337f2 100644 --- a/packages/rspack/src/config/normalization.ts +++ b/packages/rspack/src/config/normalization.ts @@ -152,12 +152,9 @@ export const getNormalizedRspackOptions = ( const { library } = output; const libraryAsName = library; const libraryBase = - typeof library === 'object' && - library && - !Array.isArray(library) && - 'type' in library - ? library - : libraryAsName || output.libraryTarget + typeof library === 'object' && library && !Array.isArray(library) + ? (library as LibraryOptions) + : libraryAsName ? ({ name: libraryAsName, } as LibraryOptions) @@ -197,26 +194,7 @@ export const getNormalizedRspackOptions = ( iife: output.iife, module: output.module, sourceMapFilename: output.sourceMapFilename, - library: libraryBase && { - type: - output.libraryTarget !== undefined - ? output.libraryTarget - : libraryBase.type, - auxiliaryComment: - output.auxiliaryComment !== undefined - ? output.auxiliaryComment - : libraryBase.auxiliaryComment, - amdContainer: libraryBase.amdContainer, - export: - output.libraryExport !== undefined - ? output.libraryExport - : libraryBase.export, - name: libraryBase.name, - umdNamedDefine: - output.umdNamedDefine !== undefined - ? output.umdNamedDefine - : libraryBase.umdNamedDefine, - }, + library: libraryBase, strictModuleErrorHandling: output.strictModuleErrorHandling ?? output.strictModuleExceptionHandling, diff --git a/packages/rspack/src/config/types.ts b/packages/rspack/src/config/types.ts index 03a9ce148210..83f7f68467b1 100644 --- a/packages/rspack/src/config/types.ts +++ b/packages/rspack/src/config/types.ts @@ -529,30 +529,6 @@ export type Output = { /** Output a library exposing the exports of your entry point. */ library?: Library; - /** - * Specify which export should be exposed as a library. - * @deprecated We might drop support for this, so prefer to use output.library.export - * */ - libraryExport?: LibraryExport; - - /** - * Configure how the library will be exposed. - * @deprecated Use output.library.type instead as we might drop support for output.libraryTarget in the future. - * */ - libraryTarget?: LibraryType; - - /** - * When using output.library.type: "umd", setting output.umdNamedDefine to true will name the AMD module of the UMD build. - * @deprecated Use output.library.umdNamedDefine instead. - */ - umdNamedDefine?: UmdNamedDefine; - - /** - * Add a comment in the UMD wrapper. - * @deprecated use output.library.auxiliaryComment instead. - * */ - auxiliaryComment?: AuxiliaryComment; - /** * Output JavaScript files as module type. * Disabled by default as it's an experimental feature. To use it, you must set experiments.outputModule to true. @@ -1492,7 +1468,7 @@ export type Target = false | AllowTarget | AllowTarget[]; //#region ExternalsType /** * Specify the default type of externals. - * `amd`, `umd`, `system` and `jsonp` externals depend on the `output.libraryTarget` being set to the same value e.g. you can only consume amd externals within an amd library. + * `amd`, `umd`, `system` and `jsonp` externals depend on the `output.library.type` being set to the same value e.g. you can only consume amd externals within an amd library. * @default 'var' */ export type ExternalsType = @@ -1524,7 +1500,7 @@ export type ExternalsType = //#region Externals /** - * External item object when both libraryTarget and externalsType is 'umd' + * External item object when both library.type and externalsType is 'umd' */ export type ExternalItemUmdValue = { root: string | string[]; @@ -1547,7 +1523,7 @@ export type ExternalItemValue = | string[] | ExternalItemUmdValue /** - * when libraryTarget and externalsType is not 'umd' + * when library.type and externalsType is not 'umd' */ | ExternalItemObjectValue; diff --git a/packages/rspack/src/lib/DllPlugin.ts b/packages/rspack/src/lib/DllPlugin.ts index f8bfa8956220..31658458c67c 100644 --- a/packages/rspack/src/lib/DllPlugin.ts +++ b/packages/rspack/src/lib/DllPlugin.ts @@ -41,7 +41,7 @@ export type DllPluginOptions = { path: string; /** - * Type of the dll bundle (external type, use value of 'output.libraryTarget'). + * Type of the dll bundle (external type, use value of 'output.library.type'). */ type?: string; }; diff --git a/packages/rspack/src/lib/DllReferencePlugin.ts b/packages/rspack/src/lib/DllReferencePlugin.ts index a79730f8deec..d13cfe3990cf 100644 --- a/packages/rspack/src/lib/DllReferencePlugin.ts +++ b/packages/rspack/src/lib/DllReferencePlugin.ts @@ -37,7 +37,7 @@ export type DllReferencePluginOptions = */ scope?: string; /** - * How the dll is exposed (libraryTarget, defaults to manifest.type). + * How the dll is exposed (library.type, defaults to manifest.type). */ sourceType?: DllReferencePluginOptionsSourceType; /** @@ -67,7 +67,7 @@ export type DllReferencePluginOptions = */ scope?: string; /** - * How the dll is exposed (libraryTarget). + * How the dll is exposed (library.type). */ sourceType?: DllReferencePluginOptionsSourceType; /** diff --git a/packages/rspack/src/util/validateConfig.ts b/packages/rspack/src/util/validateConfig.ts index af841531aafe..904d5cb873fa 100644 --- a/packages/rspack/src/util/validateConfig.ts +++ b/packages/rspack/src/util/validateConfig.ts @@ -45,7 +45,7 @@ const validateExternalUmd = ({ if (typeof library === 'object' && 'type' in library) { isLibraryUmd = library.type === 'umd'; } else { - isLibraryUmd = output?.libraryTarget === 'umd'; + isLibraryUmd = false; } if ( diff --git a/tests/rspack-test/configCases/concatenate-modules/issue-13022/rspack.config.js b/tests/rspack-test/configCases/concatenate-modules/issue-13022/rspack.config.js index 7eee21d45f4b..6a8752639931 100644 --- a/tests/rspack-test/configCases/concatenate-modules/issue-13022/rspack.config.js +++ b/tests/rspack-test/configCases/concatenate-modules/issue-13022/rspack.config.js @@ -7,8 +7,10 @@ module.exports = [ index: path.resolve(__dirname, "./index.js") }, output: { - library: "[name]", - libraryExport: "default" + library: { + name: "[name]", + export: "default", + }, }, optimization: { concatenateModules: true @@ -19,8 +21,10 @@ module.exports = [ index: path.resolve(__dirname, "./index.js") }, output: { - library: "[name]_doc", - libraryExport: "default" + library: { + name: "[name]_doc", + export: "default" + }, }, optimization: { concatenateModules: true diff --git a/tests/rspack-test/configCases/container-1-5/module-federation/rspack.config.js b/tests/rspack-test/configCases/container-1-5/module-federation/rspack.config.js index 226046fe7517..f5de89607f1d 100644 --- a/tests/rspack-test/configCases/container-1-5/module-federation/rspack.config.js +++ b/tests/rspack-test/configCases/container-1-5/module-federation/rspack.config.js @@ -3,7 +3,7 @@ const { ModuleFederationPlugin } = require("@rspack/core").container; function createConfig() { return { output: { - libraryTarget: "system" + library: { type: "system" } }, plugins: [ new ModuleFederationPlugin({ @@ -11,7 +11,7 @@ function createConfig() { filename: "container.js", library: { type: "system" }, exposes: ["./other", "./self", "./dep"], - manifest:false, + manifest: false, remotes: { abc: "ABC", def: "DEF", @@ -23,7 +23,7 @@ function createConfig() { name: "container2", filename: "container2.js", library: { type: "system" }, - manifest:false, + manifest: false, exposes: ["./other", "./self", "./dep"], remotes: { abc: "ABC", diff --git a/tests/rspack-test/configCases/externals/async-externals/rspack.config.js b/tests/rspack-test/configCases/externals/async-externals/rspack.config.js index cf882dbc8cc6..3db72a597f5d 100644 --- a/tests/rspack-test/configCases/externals/async-externals/rspack.config.js +++ b/tests/rspack-test/configCases/externals/async-externals/rspack.config.js @@ -1,6 +1,6 @@ module.exports = { output: { - libraryTarget: "commonjs-module", + library: { type: "commonjs-module" }, importFunctionName: "((name) => Promise.resolve({ request: name }))" }, externals: { diff --git a/tests/rspack-test/configCases/externals/external-module-in-main-chunk-amd/rspack.config.js b/tests/rspack-test/configCases/externals/external-module-in-main-chunk-amd/rspack.config.js index 69fd010d1bd5..7b6197fb976c 100644 --- a/tests/rspack-test/configCases/externals/external-module-in-main-chunk-amd/rspack.config.js +++ b/tests/rspack-test/configCases/externals/external-module-in-main-chunk-amd/rspack.config.js @@ -2,7 +2,7 @@ const { rspack } = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "amd" + library: { type: "amd" } }, externals: { external: "external" diff --git a/tests/rspack-test/configCases/externals/externals-array/rspack.config.js b/tests/rspack-test/configCases/externals/externals-array/rspack.config.js index 8298a3fe7ffb..780852ae1ca3 100644 --- a/tests/rspack-test/configCases/externals/externals-array/rspack.config.js +++ b/tests/rspack-test/configCases/externals/externals-array/rspack.config.js @@ -3,7 +3,7 @@ const webpack = require("@rspack/core"); module.exports = [ { output: { - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, externals: { external: ["@rspack/core", "version"] diff --git a/tests/rspack-test/configCases/externals/externals-system-custom/rspack.config.js b/tests/rspack-test/configCases/externals/externals-system-custom/rspack.config.js index 12869ba488b1..2f077f2f6b3e 100644 --- a/tests/rspack-test/configCases/externals/externals-system-custom/rspack.config.js +++ b/tests/rspack-test/configCases/externals/externals-system-custom/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "system" + library: { type: "system" } }, target: "web", node: { diff --git a/tests/rspack-test/configCases/externals/externals-system/rspack.config.js b/tests/rspack-test/configCases/externals/externals-system/rspack.config.js index c9f0f878a229..ddc9949695a1 100644 --- a/tests/rspack-test/configCases/externals/externals-system/rspack.config.js +++ b/tests/rspack-test/configCases/externals/externals-system/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "system" + library: { type: "system" } }, externals: { external1: "external1", diff --git a/tests/rspack-test/configCases/externals/node-require/rspack.config.js b/tests/rspack-test/configCases/externals/node-require/rspack.config.js index 3e91e071b85b..18cfdf17bae4 100644 --- a/tests/rspack-test/configCases/externals/node-require/rspack.config.js +++ b/tests/rspack-test/configCases/externals/node-require/rspack.config.js @@ -5,7 +5,7 @@ const webpack = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, externals: { external: ["webpack", "version"] diff --git a/tests/rspack-test/configCases/externals/non-amd-externals-amd/rspack.config.js b/tests/rspack-test/configCases/externals/non-amd-externals-amd/rspack.config.js index 305eba340fd1..3303333e499d 100644 --- a/tests/rspack-test/configCases/externals/non-amd-externals-amd/rspack.config.js +++ b/tests/rspack-test/configCases/externals/non-amd-externals-amd/rspack.config.js @@ -2,7 +2,7 @@ const webpack = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "amd" + library: { type: "amd" } }, externals: { external0: "external0", diff --git a/tests/rspack-test/configCases/externals/non-umd-externals-umd/rspack.config.js b/tests/rspack-test/configCases/externals/non-umd-externals-umd/rspack.config.js index 9a9c0ae44bde..6c7d682c6353 100644 --- a/tests/rspack-test/configCases/externals/non-umd-externals-umd/rspack.config.js +++ b/tests/rspack-test/configCases/externals/non-umd-externals-umd/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd" + library: { type: "umd" } }, externals: { external0: "external0", diff --git a/tests/rspack-test/configCases/externals/non-umd-externals-umd2/rspack.config.js b/tests/rspack-test/configCases/externals/non-umd-externals-umd2/rspack.config.js index 641354ee2610..dbbcfbc4e79a 100644 --- a/tests/rspack-test/configCases/externals/non-umd-externals-umd2/rspack.config.js +++ b/tests/rspack-test/configCases/externals/non-umd-externals-umd2/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd2" + library: { type: "umd2" } }, externals: { external0: "external0", diff --git a/tests/rspack-test/configCases/externals/optional-externals-cjs/rspack.config.js b/tests/rspack-test/configCases/externals/optional-externals-cjs/rspack.config.js index 1cb6c78e67e9..a3bf855a396e 100644 --- a/tests/rspack-test/configCases/externals/optional-externals-cjs/rspack.config.js +++ b/tests/rspack-test/configCases/externals/optional-externals-cjs/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, externals: { external: "external" diff --git a/tests/rspack-test/configCases/externals/optional-externals-umd/rspack.config.js b/tests/rspack-test/configCases/externals/optional-externals-umd/rspack.config.js index 272cc423eaf2..cb34a8b4cafc 100644 --- a/tests/rspack-test/configCases/externals/optional-externals-umd/rspack.config.js +++ b/tests/rspack-test/configCases/externals/optional-externals-umd/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd" + library: { type: "umd" } }, externals: { external: "external" diff --git a/tests/rspack-test/configCases/externals/optional-externals-umd2-mixed/rspack.config.js b/tests/rspack-test/configCases/externals/optional-externals-umd2-mixed/rspack.config.js index d63de1e20dc7..aa3a9332ec31 100644 --- a/tests/rspack-test/configCases/externals/optional-externals-umd2-mixed/rspack.config.js +++ b/tests/rspack-test/configCases/externals/optional-externals-umd2-mixed/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd2" + library: { type: "umd2" } }, externals: { external: "external", diff --git a/tests/rspack-test/configCases/externals/optional-externals-umd2/rspack.config.js b/tests/rspack-test/configCases/externals/optional-externals-umd2/rspack.config.js index df32c5f83e7a..386e9b5ffca4 100644 --- a/tests/rspack-test/configCases/externals/optional-externals-umd2/rspack.config.js +++ b/tests/rspack-test/configCases/externals/optional-externals-umd2/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd2" + library: { type: "umd2" } }, externals: { external: "external" diff --git a/tests/rspack-test/configCases/externals/umd-array-externals/rspack.config.js b/tests/rspack-test/configCases/externals/umd-array-externals/rspack.config.js index 2682eff51ff0..74bab3c337ea 100644 --- a/tests/rspack-test/configCases/externals/umd-array-externals/rspack.config.js +++ b/tests/rspack-test/configCases/externals/umd-array-externals/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd" + library: { type: "umd" } }, externals: { external: { diff --git a/tests/rspack-test/configCases/externals/umd-validation-failed-no-externals-type/rspack.config.js b/tests/rspack-test/configCases/externals/umd-validation-failed-no-externals-type/rspack.config.js index 211079b16a11..c6bf5c03f31f 100644 --- a/tests/rspack-test/configCases/externals/umd-validation-failed-no-externals-type/rspack.config.js +++ b/tests/rspack-test/configCases/externals/umd-validation-failed-no-externals-type/rspack.config.js @@ -4,7 +4,7 @@ const { CopyRspackPlugin } = require("@rspack/core"); module.exports = { entry: "./index.js", output: { - libraryTarget: "umd" + library: { type: "umd" } }, externals: { lodash: { diff --git a/tests/rspack-test/configCases/externals/umd-validation-with-external-type/rspack.config.js b/tests/rspack-test/configCases/externals/umd-validation-with-external-type/rspack.config.js index e2186d8a8f40..cc7e8a015494 100644 --- a/tests/rspack-test/configCases/externals/umd-validation-with-external-type/rspack.config.js +++ b/tests/rspack-test/configCases/externals/umd-validation-with-external-type/rspack.config.js @@ -4,7 +4,7 @@ const { CopyRspackPlugin } = require("@rspack/core"); module.exports = { entry: "./index.js", output: { - libraryTarget: "umd" + library: { type: "umd" } }, externals: { lodash: { diff --git a/tests/rspack-test/configCases/filename-template/split-chunks-filename/rspack.config.js b/tests/rspack-test/configCases/filename-template/split-chunks-filename/rspack.config.js index acb77af36d56..b07832198a3e 100644 --- a/tests/rspack-test/configCases/filename-template/split-chunks-filename/rspack.config.js +++ b/tests/rspack-test/configCases/filename-template/split-chunks-filename/rspack.config.js @@ -6,7 +6,7 @@ module.exports = { __filename: false }, output: { - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { splitChunks: { diff --git a/tests/rspack-test/configCases/issues/issue-12993/rspack.config.js b/tests/rspack-test/configCases/issues/issue-12993/rspack.config.js index f462f7e496f3..6532a95df2dc 100644 --- a/tests/rspack-test/configCases/issues/issue-12993/rspack.config.js +++ b/tests/rspack-test/configCases/issues/issue-12993/rspack.config.js @@ -2,16 +2,20 @@ module.exports = [ { mode: "development", output: { - library: "lib", - libraryTarget: "global" + library: { + name: "lib", + type: "global" + } } }, { mode: "development", devtool: false, output: { - library: "lib", - libraryTarget: "global" + library: { + name: "lib", + type: "global" + } } } ]; diff --git a/tests/rspack-test/configCases/library/_amd-require/rspack.config.js b/tests/rspack-test/configCases/library/_amd-require/rspack.config.js index 415b7b7736fc..2ba3c03a326c 100644 --- a/tests/rspack-test/configCases/library/_amd-require/rspack.config.js +++ b/tests/rspack-test/configCases/library/_amd-require/rspack.config.js @@ -1,6 +1,6 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "amd-require" + library: { type: "amd-require" } } }; diff --git a/tests/rspack-test/configCases/library/a/rspack.config.js b/tests/rspack-test/configCases/library/a/rspack.config.js index 5149057ac5d1..dddf507a658e 100644 --- a/tests/rspack-test/configCases/library/a/rspack.config.js +++ b/tests/rspack-test/configCases/library/a/rspack.config.js @@ -1,6 +1,6 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "this" + library: { type: "this" } } }; diff --git a/tests/rspack-test/configCases/library/amd-named/rspack.config.js b/tests/rspack-test/configCases/library/amd-named/rspack.config.js index 58054dab298e..280cf7696ba7 100644 --- a/tests/rspack-test/configCases/library/amd-named/rspack.config.js +++ b/tests/rspack-test/configCases/library/amd-named/rspack.config.js @@ -2,8 +2,7 @@ const { rspack } = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: "NamedLibrary", - libraryTarget: "amd" + library: { type: "amd", name: "NamedLibrary" } }, plugins: [ new rspack.BannerPlugin({ diff --git a/tests/rspack-test/configCases/library/amd-unnamed/rspack.config.js b/tests/rspack-test/configCases/library/amd-unnamed/rspack.config.js index 9a8b64f8a9ec..809c79abcba6 100644 --- a/tests/rspack-test/configCases/library/amd-unnamed/rspack.config.js +++ b/tests/rspack-test/configCases/library/amd-unnamed/rspack.config.js @@ -2,7 +2,7 @@ const { rspack } = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "amd" + library: { type: "amd" } }, plugins: [ new rspack.BannerPlugin({ diff --git a/tests/rspack-test/configCases/library/array-this/rspack.config.js b/tests/rspack-test/configCases/library/array-this/rspack.config.js index a76cc6e582b8..58ade47dd956 100644 --- a/tests/rspack-test/configCases/library/array-this/rspack.config.js +++ b/tests/rspack-test/configCases/library/array-this/rspack.config.js @@ -2,8 +2,7 @@ module.exports = { target: "web", output: { - library: ["a", "b"], - libraryTarget: "this", + library: { type: "this", name: ["a", "b"] }, environment: { arrowFunction: false } diff --git a/tests/rspack-test/configCases/library/array-window/rspack.config.js b/tests/rspack-test/configCases/library/array-window/rspack.config.js index 946f310d1b9d..fd3b4f83623e 100644 --- a/tests/rspack-test/configCases/library/array-window/rspack.config.js +++ b/tests/rspack-test/configCases/library/array-window/rspack.config.js @@ -2,7 +2,6 @@ module.exports = { target: "web", output: { - library: ["a", "b"], - libraryTarget: "window" + library: { type: "window", name: ["a", "b"] } } }; diff --git a/tests/rspack-test/configCases/library/assign-properties/rspack.config.js b/tests/rspack-test/configCases/library/assign-properties/rspack.config.js index 30fd013f1763..5a784770abdb 100644 --- a/tests/rspack-test/configCases/library/assign-properties/rspack.config.js +++ b/tests/rspack-test/configCases/library/assign-properties/rspack.config.js @@ -1,7 +1,6 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: ["process", "env"], - libraryTarget: "assign-properties" + library: { type: "assign-properties", name: ["process", "env"] } } }; diff --git a/tests/rspack-test/configCases/library/b/rspack.config.js b/tests/rspack-test/configCases/library/b/rspack.config.js index 176814cd4cdc..b2ff8321db99 100644 --- a/tests/rspack-test/configCases/library/b/rspack.config.js +++ b/tests/rspack-test/configCases/library/b/rspack.config.js @@ -1,6 +1,6 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "global" + library: { type: "global" } } }; diff --git a/tests/rspack-test/configCases/library/commonjs/rspack.config.js b/tests/rspack-test/configCases/library/commonjs/rspack.config.js index eee51071e841..371f63bb0db1 100644 --- a/tests/rspack-test/configCases/library/commonjs/rspack.config.js +++ b/tests/rspack-test/configCases/library/commonjs/rspack.config.js @@ -1,6 +1,6 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "commonjs" + library: { type: "commonjs" } } }; diff --git a/tests/rspack-test/configCases/library/esm-external/rspack.config.js b/tests/rspack-test/configCases/library/esm-external/rspack.config.js index 3aca832bd8b8..b7e836e6d3f6 100644 --- a/tests/rspack-test/configCases/library/esm-external/rspack.config.js +++ b/tests/rspack-test/configCases/library/esm-external/rspack.config.js @@ -2,7 +2,7 @@ module.exports = { mode: "development", output: { - libraryTarget: "module", + library: { type: "module" }, iife: false, chunkFormat: "module", filename: "bundle0.mjs" diff --git a/tests/rspack-test/configCases/library/esmodule/rspack.config.js b/tests/rspack-test/configCases/library/esmodule/rspack.config.js index d9299672742c..fbc3e38f597d 100644 --- a/tests/rspack-test/configCases/library/esmodule/rspack.config.js +++ b/tests/rspack-test/configCases/library/esmodule/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "module", + library: { type: "module" }, iife: false, chunkFormat: "module", filename: "bundle0.mjs" diff --git a/tests/rspack-test/configCases/library/modern-module-export-char/rspack.config.js b/tests/rspack-test/configCases/library/modern-module-export-char/rspack.config.js index c8b2663ad54d..d0816bb54366 100644 --- a/tests/rspack-test/configCases/library/modern-module-export-char/rspack.config.js +++ b/tests/rspack-test/configCases/library/modern-module-export-char/rspack.config.js @@ -6,7 +6,7 @@ module.exports = { output: { filename: `[name].js`, module: true, - libraryTarget: "modern-module", + library: { type: "modern-module" }, iife: false, chunkFormat: "module" }, diff --git a/tests/rspack-test/configCases/library/modern-module-force-concaten/rspack.config.js b/tests/rspack-test/configCases/library/modern-module-force-concaten/rspack.config.js index 691752d9500f..89d20e28bbe0 100644 --- a/tests/rspack-test/configCases/library/modern-module-force-concaten/rspack.config.js +++ b/tests/rspack-test/configCases/library/modern-module-force-concaten/rspack.config.js @@ -26,7 +26,7 @@ module.exports = { output: { filename: `[name].js`, module: true, - libraryTarget: "modern-module", + library: { type: "modern-module" }, iife: false, chunkFormat: "module" }, diff --git a/tests/rspack-test/configCases/library/umd-array/rspack.config.js b/tests/rspack-test/configCases/library/umd-array/rspack.config.js index d894c55151fd..f14488b57b2e 100644 --- a/tests/rspack-test/configCases/library/umd-array/rspack.config.js +++ b/tests/rspack-test/configCases/library/umd-array/rspack.config.js @@ -1,8 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd", - library: { + library: { type: "umd", root: ["test", "library"], amd: "test-library", commonjs: "test-library" diff --git a/tests/rspack-test/configCases/library/umd-external/rspack.config.js b/tests/rspack-test/configCases/library/umd-external/rspack.config.js index 3986a5ef7afd..59974dd096b3 100644 --- a/tests/rspack-test/configCases/library/umd-external/rspack.config.js +++ b/tests/rspack-test/configCases/library/umd-external/rspack.config.js @@ -1,8 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd", - library: { + library: { type: "umd", root: "testLibrary[name]", amd: "test-library", commonjs: "test-library-[name]" diff --git a/tests/rspack-test/configCases/library/umd-named-define-runtime-chunk/rspack.config.js b/tests/rspack-test/configCases/library/umd-named-define-runtime-chunk/rspack.config.js index 36493684289f..640e076df394 100644 --- a/tests/rspack-test/configCases/library/umd-named-define-runtime-chunk/rspack.config.js +++ b/tests/rspack-test/configCases/library/umd-named-define-runtime-chunk/rspack.config.js @@ -8,13 +8,13 @@ module.exports = { }, output: { filename: "[name].js", - libraryTarget: "umd", library: { + type: "umd", root: "testLibrary[name]", amd: "test-library-[name]", - commonjs: "test-library-[name]" + commonjs: "test-library-[name]", + umdNamedDefine: true }, - umdNamedDefine: true }, externals: "module" }; diff --git a/tests/rspack-test/configCases/library/umd-named-define/rspack.config.js b/tests/rspack-test/configCases/library/umd-named-define/rspack.config.js index 40ec26482713..4b6ba4505786 100644 --- a/tests/rspack-test/configCases/library/umd-named-define/rspack.config.js +++ b/tests/rspack-test/configCases/library/umd-named-define/rspack.config.js @@ -1,13 +1,14 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd", library: { + type: "umd", root: "testLibrary[name]", amd: "test-library-[name]", - commonjs: "test-library-[name]" + commonjs: "test-library-[name]", + umdNamedDefine: true }, - umdNamedDefine: true + }, externals: "module" }; diff --git a/tests/rspack-test/configCases/library/umd/rspack.config.js b/tests/rspack-test/configCases/library/umd/rspack.config.js index 624d61e69889..2113c90e772d 100644 --- a/tests/rspack-test/configCases/library/umd/rspack.config.js +++ b/tests/rspack-test/configCases/library/umd/rspack.config.js @@ -1,8 +1,8 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "umd", library: { + type: "umd", root: "testLibrary", amd: "test-library", commonjs: "test-library" diff --git a/tests/rspack-test/configCases/module/issue-16040/rspack.config.js b/tests/rspack-test/configCases/module/issue-16040/rspack.config.js index 2aaf6ed686dd..fb549c7e4b2a 100644 --- a/tests/rspack-test/configCases/module/issue-16040/rspack.config.js +++ b/tests/rspack-test/configCases/module/issue-16040/rspack.config.js @@ -15,7 +15,7 @@ module.exports = { chunkFilename: "[name].chunk.js", assetModuleFilename: "[hash][ext][query]", module: true, - libraryTarget: "module", + library: { type: "module" }, chunkFormat: "module", chunkLoading: "import", environment: { diff --git a/tests/rspack-test/configCases/output-module/issue-16040/rspack.config.js b/tests/rspack-test/configCases/output-module/issue-16040/rspack.config.js index ff1de07bbb0b..03925659f6df 100644 --- a/tests/rspack-test/configCases/output-module/issue-16040/rspack.config.js +++ b/tests/rspack-test/configCases/output-module/issue-16040/rspack.config.js @@ -13,7 +13,7 @@ module.exports = { chunkFilename: "[name].chunk.js", assetModuleFilename: "[hash][ext][query]", module: true, - libraryTarget: "module", + library: { type: "module" }, chunkFormat: "module", chunkLoading: "import", environment: { diff --git a/tests/rspack-test/configCases/output/inner-dirs-entries/rspack.config.js b/tests/rspack-test/configCases/output/inner-dirs-entries/rspack.config.js index f712976bf021..f4310d42ab62 100644 --- a/tests/rspack-test/configCases/output/inner-dirs-entries/rspack.config.js +++ b/tests/rspack-test/configCases/output/inner-dirs-entries/rspack.config.js @@ -8,7 +8,7 @@ module.exports = { }, target: "node", output: { - libraryTarget: "commonjs2", + library: { type: "commonjs2" }, pathinfo: true, filename: "[name].js", chunkFilename: "[name].chunk.min.js" diff --git a/tests/rspack-test/configCases/source-map/array-as-output-library-in-object-output/rspack.config.js b/tests/rspack-test/configCases/source-map/array-as-output-library-in-object-output/rspack.config.js index b4ff1ac0e27e..48d9e9a508cf 100644 --- a/tests/rspack-test/configCases/source-map/array-as-output-library-in-object-output/rspack.config.js +++ b/tests/rspack-test/configCases/source-map/array-as-output-library-in-object-output/rspack.config.js @@ -7,6 +7,6 @@ module.exports = { amd: "[name]", commonjs: "[name]" }, - libraryTarget: "umd" + library: { type: "umd" } } }; diff --git a/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval-source-map/rspack.config.js b/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval-source-map/rspack.config.js index 5346a0c9fbfa..017ec257e1e0 100644 --- a/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval-source-map/rspack.config.js +++ b/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval-source-map/rspack.config.js @@ -10,8 +10,7 @@ module.exports = { output: { filename: "[name]-bundle.js", - library: "library-[name]", - libraryTarget: "commonjs", + library: { type: "commonjs", name: "library-[name]" }, devtoolNamespace: "library-[name]" }, devtool: "eval-source-map" diff --git a/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval/rspack.config.js b/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval/rspack.config.js index 87345d12fac9..b7333aa6fece 100644 --- a/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval/rspack.config.js +++ b/tests/rspack-test/configCases/source-map/devtool-namespace-with-eval/rspack.config.js @@ -10,8 +10,7 @@ module.exports = { output: { filename: "[name]-bundle.js", - library: "library-[name]", - libraryTarget: "commonjs", + library: { type: "commonjs", name: "library-[name]" }, devtoolNamespace: "library-[name]" }, devtool: "eval" diff --git a/tests/rspack-test/configCases/source-map/devtool-namespace-with-source-map/rspack.config.js b/tests/rspack-test/configCases/source-map/devtool-namespace-with-source-map/rspack.config.js index 47f7c1d14471..fb37a8fb0dfd 100644 --- a/tests/rspack-test/configCases/source-map/devtool-namespace-with-source-map/rspack.config.js +++ b/tests/rspack-test/configCases/source-map/devtool-namespace-with-source-map/rspack.config.js @@ -10,8 +10,7 @@ module.exports = { output: { filename: "[name]-bundle.js", - library: "library-[name]", - libraryTarget: "commonjs", + library: { type: "commonjs", name: "library-[name]" }, devtoolNamespace: "library-[name]" }, devtool: "source-map" diff --git a/tests/rspack-test/configCases/source-map/object-as-output-library/rspack.config.js b/tests/rspack-test/configCases/source-map/object-as-output-library/rspack.config.js index 48c27f005e09..773227c833bd 100644 --- a/tests/rspack-test/configCases/source-map/object-as-output-library/rspack.config.js +++ b/tests/rspack-test/configCases/source-map/object-as-output-library/rspack.config.js @@ -7,6 +7,6 @@ module.exports = { amd: "[name]", commonjs: "[name]" }, - libraryTarget: "umd" + library: { type: "umd" } } }; diff --git a/tests/rspack-test/configCases/split-chunks-common/_library/rspack.config.js b/tests/rspack-test/configCases/split-chunks-common/_library/rspack.config.js index 4838ed42fe43..006d63416226 100644 --- a/tests/rspack-test/configCases/split-chunks-common/_library/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks-common/_library/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { target: "web", output: { filename: "[name].js", - libraryTarget: "umd" + library: { type: "umd" } }, externals: ["external0", "external1", "external2", "fs", "path"], optimization: { diff --git a/tests/rspack-test/configCases/split-chunks-common/library/rspack.config.js b/tests/rspack-test/configCases/split-chunks-common/library/rspack.config.js index 4838ed42fe43..006d63416226 100644 --- a/tests/rspack-test/configCases/split-chunks-common/library/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks-common/library/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { target: "web", output: { filename: "[name].js", - libraryTarget: "umd" + library: { type: "umd" } }, externals: ["external0", "external1", "external2", "fs", "path"], optimization: { diff --git a/tests/rspack-test/configCases/split-chunks-common/rspack-issue-4376/rspack.config.js b/tests/rspack-test/configCases/split-chunks-common/rspack-issue-4376/rspack.config.js index 6250381c3930..55ba154700ef 100644 --- a/tests/rspack-test/configCases/split-chunks-common/rspack-issue-4376/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks-common/rspack-issue-4376/rspack.config.js @@ -6,7 +6,7 @@ module.exports = [ target: "node", output: { filename: "default-[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { splitChunks: { @@ -21,7 +21,7 @@ module.exports = [ target: "node", output: { filename: "many-vendors-[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { splitChunks: { diff --git a/tests/rspack-test/configCases/split-chunks-common/target-node/rspack.config.js b/tests/rspack-test/configCases/split-chunks-common/target-node/rspack.config.js index 4b9cee8bc063..13e72a6aad50 100644 --- a/tests/rspack-test/configCases/split-chunks-common/target-node/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks-common/target-node/rspack.config.js @@ -6,7 +6,7 @@ module.exports = [ target: "node", output: { filename: "default-[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { splitChunks: { @@ -21,7 +21,7 @@ module.exports = [ target: "node", output: { filename: "many-vendors-[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { splitChunks: { diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-contenthash/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-contenthash/rspack.config.js index 4ef2b1641dfe..5a79d8ed75ab 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-contenthash/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-contenthash/rspack.config.js @@ -6,7 +6,7 @@ module.exports = { }, output: { filename: "c-[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-fullhash/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-fullhash/rspack.config.js index d1ddcd02f038..b07b73d281c0 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-fullhash/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-fullhash/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { }, output: { filename: "c-[name].js", - libraryTarget: "commonjs2", + library: { type: "commonjs2" }, // TODO: // here is a webpack bug and also in rspack // if do not set chunkFilename and hash diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-id/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-id/rspack.config.js index 0bd9fb7f3c05..4aa6d7ff4459 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-id/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module-id/rspack.config.js @@ -6,7 +6,7 @@ module.exports = { }, output: { filename: "c-[id].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module/rspack.config.js index 18086eddec58..0f994188258a 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-chunkname-runtime-module/rspack.config.js @@ -6,7 +6,7 @@ module.exports = { }, output: { filename: "c-[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-function/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-function/rspack.config.js index 56121f7deb85..7d54e773b642 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-function/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-function/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { }, output: { filename: "[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-many-custom/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-many-custom/rspack.config.js index 12877300fa70..79623b16810c 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-many-custom/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-many-custom/rspack.config.js @@ -6,7 +6,7 @@ module.exports = { }, output: { filename: "[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-no-reuse-chunk/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-no-reuse-chunk/rspack.config.js index 7ec2b0e88fa7..a22624d7581c 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-no-reuse-chunk/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-no-reuse-chunk/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { }, output: { filename: "[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename-overall/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename-overall/rspack.config.js index fbc02f7c5521..92b22778af59 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename-overall/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename-overall/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { }, output: { filename: "[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/split-chunks/custom-filename/rspack.config.js b/tests/rspack-test/configCases/split-chunks/custom-filename/rspack.config.js index 0ead1e6228f0..744cf2605bd0 100644 --- a/tests/rspack-test/configCases/split-chunks/custom-filename/rspack.config.js +++ b/tests/rspack-test/configCases/split-chunks/custom-filename/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { }, output: { filename: "[name].js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, optimization: { chunkIds: "named", diff --git a/tests/rspack-test/configCases/target/amd-named/rspack.config.js b/tests/rspack-test/configCases/target/amd-named/rspack.config.js index a799d5a18ead..93b483916fa5 100644 --- a/tests/rspack-test/configCases/target/amd-named/rspack.config.js +++ b/tests/rspack-test/configCases/target/amd-named/rspack.config.js @@ -2,8 +2,7 @@ const webpack = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: "NamedLibrary", - libraryTarget: "amd" + library: { type: "amd", name: "NamedLibrary" } }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/amd-require/rspack.config.js b/tests/rspack-test/configCases/target/amd-require/rspack.config.js index e9f3715e7d80..211664dfaf44 100644 --- a/tests/rspack-test/configCases/target/amd-require/rspack.config.js +++ b/tests/rspack-test/configCases/target/amd-require/rspack.config.js @@ -2,7 +2,7 @@ const webpack = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "amd-require" + library: { type: "amd-require" } }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/amd-unnamed/rspack.config.js b/tests/rspack-test/configCases/target/amd-unnamed/rspack.config.js index 260ebfbf2e7a..120864df80ae 100644 --- a/tests/rspack-test/configCases/target/amd-unnamed/rspack.config.js +++ b/tests/rspack-test/configCases/target/amd-unnamed/rspack.config.js @@ -2,7 +2,7 @@ const webpack = require("@rspack/core"); /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "amd" + library: { type: "amd" } }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/system-export/rspack.config.js b/tests/rspack-test/configCases/target/system-export/rspack.config.js index e15a22ebd8a6..27cf3c700e30 100644 --- a/tests/rspack-test/configCases/target/system-export/rspack.config.js +++ b/tests/rspack-test/configCases/target/system-export/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "system" + library: { type: "system" } }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/system-named-assets-path/rspack.config.js b/tests/rspack-test/configCases/target/system-named-assets-path/rspack.config.js index 244073ebc7ea..9f47c7954e07 100644 --- a/tests/rspack-test/configCases/target/system-named-assets-path/rspack.config.js +++ b/tests/rspack-test/configCases/target/system-named-assets-path/rspack.config.js @@ -1,8 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: "named-system-module-[name]", - libraryTarget: "system" + library: { type: "system", name: "named-system-module-[name]" } }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/system-named/rspack.config.js b/tests/rspack-test/configCases/target/system-named/rspack.config.js index 0c190c9811a3..8a0800349c9b 100644 --- a/tests/rspack-test/configCases/target/system-named/rspack.config.js +++ b/tests/rspack-test/configCases/target/system-named/rspack.config.js @@ -1,8 +1,10 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: "named-system-module", - libraryTarget: "system" + library: { + name: "named-system-module", + type: "system" + } }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/system-unnamed/rspack.config.js b/tests/rspack-test/configCases/target/system-unnamed/rspack.config.js index e15a22ebd8a6..27cf3c700e30 100644 --- a/tests/rspack-test/configCases/target/system-unnamed/rspack.config.js +++ b/tests/rspack-test/configCases/target/system-unnamed/rspack.config.js @@ -1,7 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - libraryTarget: "system" + library: { type: "system" } }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/umd-auxiliary-comments-object/rspack.config.js b/tests/rspack-test/configCases/target/umd-auxiliary-comments-object/rspack.config.js index f702ef264303..9be4a04adab0 100644 --- a/tests/rspack-test/configCases/target/umd-auxiliary-comments-object/rspack.config.js +++ b/tests/rspack-test/configCases/target/umd-auxiliary-comments-object/rspack.config.js @@ -1,15 +1,15 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: "NamedLibrary", - libraryTarget: "umd", - umdNamedDefine: true, - auxiliaryComment: { - commonjs: "test comment commonjs", - commonjs2: "test comment commonjs2", - amd: "test comment amd", - root: "test comment root" - } + library: { + type: "umd", name: "NamedLibrary", umdNamedDefine: true, + auxiliaryComment: { + commonjs: "test comment commonjs", + commonjs2: "test comment commonjs2", + amd: "test comment amd", + root: "test comment root" + } + }, }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/umd-auxiliary-comments-string/rspack.config.js b/tests/rspack-test/configCases/target/umd-auxiliary-comments-string/rspack.config.js index e7545b906c94..b67f9a2b2ab5 100644 --- a/tests/rspack-test/configCases/target/umd-auxiliary-comments-string/rspack.config.js +++ b/tests/rspack-test/configCases/target/umd-auxiliary-comments-string/rspack.config.js @@ -1,10 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: "NamedLibrary", - libraryTarget: "umd", - umdNamedDefine: true, - auxiliaryComment: "test comment" + library: { type: "umd", name: "NamedLibrary", umdNamedDefine: true, auxiliaryComment: "test comment" }, }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/target/umd-named-define/rspack.config.js b/tests/rspack-test/configCases/target/umd-named-define/rspack.config.js index 13e33cc4a7c4..8b8991c3f371 100644 --- a/tests/rspack-test/configCases/target/umd-named-define/rspack.config.js +++ b/tests/rspack-test/configCases/target/umd-named-define/rspack.config.js @@ -1,9 +1,7 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { output: { - library: "NamedLibrary", - libraryTarget: "umd", - umdNamedDefine: true + library: { type: "umd", name: "NamedLibrary", umdNamedDefine: true }, }, node: { __dirname: false, diff --git a/tests/rspack-test/configCases/umd/issue-15545/rspack.config.js b/tests/rspack-test/configCases/umd/issue-15545/rspack.config.js index 742def00c4cb..fd63f1353f24 100644 --- a/tests/rspack-test/configCases/umd/issue-15545/rspack.config.js +++ b/tests/rspack-test/configCases/umd/issue-15545/rspack.config.js @@ -6,8 +6,7 @@ module.exports = { }, output: { filename: "[name].js", - library: "MyLibrary", - libraryTarget: "umd", + library: { type: "umd", name: "MyLibrary" }, chunkLoading: "jsonp", chunkFormat: "array-push", globalObject: "this" diff --git a/tests/rspack-test/defaultsCases/library/library.js b/tests/rspack-test/defaultsCases/library/library.js index ea6f47893f18..3fedfc49ddda 100644 --- a/tests/rspack-test/defaultsCases/library/library.js +++ b/tests/rspack-test/defaultsCases/library/library.js @@ -27,15 +27,11 @@ module.exports = { @@ ... @@ - "library": undefined, + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, + "name": Array [ + "myLib", + "awesome", + ], + "type": "var", - + "umdNamedDefine": undefined, + }, @@ ... @@ - "uniqueName": "@rspack/tests", diff --git a/tests/rspack-test/defaultsCases/library/name-placeholder.js b/tests/rspack-test/defaultsCases/library/name-placeholder.js index 71f52974a895..6ea92c752d24 100644 --- a/tests/rspack-test/defaultsCases/library/name-placeholder.js +++ b/tests/rspack-test/defaultsCases/library/name-placeholder.js @@ -34,16 +34,12 @@ module.exports = { @@ ... @@ - "library": undefined, + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, + "name": Array [ + "my[name]Lib", + "[name]", + "lib", + ], + "type": "var", - + "umdNamedDefine": undefined, + }, @@ ... @@ - "uniqueName": "@rspack/tests", diff --git a/tests/rspack-test/defaultsCases/library/name-root-placeholder.js b/tests/rspack-test/defaultsCases/library/name-root-placeholder.js index 514a028d2dbe..d7b8f51e1a34 100644 --- a/tests/rspack-test/defaultsCases/library/name-root-placeholder.js +++ b/tests/rspack-test/defaultsCases/library/name-root-placeholder.js @@ -26,19 +26,17 @@ module.exports = { - "devtoolNamespace": "@rspack/tests", + "devtoolNamespace": "[name].my[name]Lib.[name]", @@ ... @@ - - "enabledLibraryTypes": Array [], + + ], + "enabledLibraryTypes": Array [ + "var", - + ], + @@ ... @@ + - "enabledLibraryTypes": Array [], @@ ... @@ - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", + "hotUpdateGlobal": "webpackHotUpdate_name_my_name_Lib_name_", @@ ... @@ - "library": undefined, + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, + "name": Object { + "root": Array [ + "[\\\\name\\\\]", @@ -47,7 +45,6 @@ module.exports = { + ], + }, + "type": "var", - + "umdNamedDefine": undefined, + }, @@ ... @@ - "uniqueName": "@rspack/tests", diff --git a/tests/rspack-test/defaultsCases/library/placeholder.js b/tests/rspack-test/defaultsCases/library/placeholder.js index 3a8a7fae8078..27d84d324c3c 100644 --- a/tests/rspack-test/defaultsCases/library/placeholder.js +++ b/tests/rspack-test/defaultsCases/library/placeholder.js @@ -31,15 +31,11 @@ module.exports = { @@ ... @@ - "library": undefined, + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, + "name": Array [ + "myLib", + "[name]", + ], + "type": "var", - + "umdNamedDefine": undefined, + }, @@ ... @@ - "uniqueName": "@rspack/tests", diff --git a/tests/rspack-test/defaultsCases/library/root-placeholder.js b/tests/rspack-test/defaultsCases/library/root-placeholder.js index 77c17681da30..3280f4564353 100644 --- a/tests/rspack-test/defaultsCases/library/root-placeholder.js +++ b/tests/rspack-test/defaultsCases/library/root-placeholder.js @@ -26,19 +26,17 @@ module.exports = { - "devtoolNamespace": "@rspack/tests", + "devtoolNamespace": "myLib", @@ ... @@ - - "enabledLibraryTypes": Array [], + + ], + "enabledLibraryTypes": Array [ + "var", - + ], + @@ ... @@ + - "enabledLibraryTypes": Array [], @@ ... @@ - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", + "hotUpdateGlobal": "webpackHotUpdatemyLib", @@ ... @@ - "library": undefined, + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, + "name": Object { + "root": Array [ + "[name]", @@ -46,7 +44,6 @@ module.exports = { + ], + }, + "type": "var", - + "umdNamedDefine": undefined, + }, @@ ... @@ - "uniqueName": "@rspack/tests", diff --git a/tests/rspack-test/errorCases/error-library.js b/tests/rspack-test/errorCases/error-library.js index a913c7498929..edb71f29cd3b 100644 --- a/tests/rspack-test/errorCases/error-library.js +++ b/tests/rspack-test/errorCases/error-library.js @@ -5,7 +5,7 @@ module.exports = { return { entry: "./file", output: { - libraryTarget: "var" + library: { type: "var" } } }; }, diff --git a/tests/rspack-test/exampleCases/externals/rspack.config.js b/tests/rspack-test/exampleCases/externals/rspack.config.js index 6a9400effbde..561fd5347a94 100644 --- a/tests/rspack-test/exampleCases/externals/rspack.config.js +++ b/tests/rspack-test/exampleCases/externals/rspack.config.js @@ -1,7 +1,7 @@ module.exports = { // mode: "development" || "production", output: { - libraryTarget: "umd" + library: { type: "umd" } }, externals: [ "add", diff --git a/tests/rspack-test/exampleCases/harmony-library/rspack.config.js b/tests/rspack-test/exampleCases/harmony-library/rspack.config.js index a88f40e0fc99..d0d20ce2d6a9 100644 --- a/tests/rspack-test/exampleCases/harmony-library/rspack.config.js +++ b/tests/rspack-test/exampleCases/harmony-library/rspack.config.js @@ -5,7 +5,6 @@ module.exports = { output: { path: path.join(__dirname, "dist"), filename: "MyLibrary.umd.js", - library: "MyLibrary", - libraryTarget: "umd" + library: { type: "umd", name: "MyLibrary" } } }; diff --git a/tests/rspack-test/exampleCases/multi-part-library/rspack.config.js b/tests/rspack-test/exampleCases/multi-part-library/rspack.config.js index 47537625b617..ff0985415346 100644 --- a/tests/rspack-test/exampleCases/multi-part-library/rspack.config.js +++ b/tests/rspack-test/exampleCases/multi-part-library/rspack.config.js @@ -8,7 +8,6 @@ module.exports = { output: { path: path.join(__dirname, "dist"), filename: "MyLibrary.[name].js", - library: ["MyLibrary", "[name]"], - libraryTarget: "umd" + library: { type: "umd", name: ["MyLibrary", "[name]"] } } }; diff --git a/tests/rspack-test/fixtures/buildDependencies/run.js b/tests/rspack-test/fixtures/buildDependencies/run.js index c83b64a5121d..33edb2600893 100644 --- a/tests/rspack-test/fixtures/buildDependencies/run.js +++ b/tests/rspack-test/fixtures/buildDependencies/run.js @@ -28,7 +28,7 @@ function run({ default: value2, asyncDep: value3 }) { entry: path.resolve(__dirname, "./index"), output: { path: path.resolve(__dirname, "../../js/buildDeps/" + process.argv[2]), - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, plugins: [ new webpack.DefinePlugin({ diff --git a/tests/rspack-test/serialCases/container/module-federation/rspack.config.js b/tests/rspack-test/serialCases/container/module-federation/rspack.config.js index 37235aa38e67..3fa4f8918500 100644 --- a/tests/rspack-test/serialCases/container/module-federation/rspack.config.js +++ b/tests/rspack-test/serialCases/container/module-federation/rspack.config.js @@ -3,7 +3,7 @@ const { ModuleFederationPluginV1: ModuleFederationPlugin } = require("@rspack/co function createConfig() { return { output: { - libraryTarget: "system" + library: { type: "system" } }, plugins: [ new ModuleFederationPlugin({ diff --git a/tests/rspack-test/serialCases/dll-plugin-entry/0-create-dll/rspack.config.js b/tests/rspack-test/serialCases/dll-plugin-entry/0-create-dll/rspack.config.js index f689c91a8bed..92e73f9b02e7 100644 --- a/tests/rspack-test/serialCases/dll-plugin-entry/0-create-dll/rspack.config.js +++ b/tests/rspack-test/serialCases/dll-plugin-entry/0-create-dll/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { output: { filename: "dll.js", chunkFilename: "[id].dll.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, plugins: [ new webpack.DllPlugin({ diff --git a/tests/rspack-test/serialCases/dll-plugin-format/0-create-dll/rspack.config.js b/tests/rspack-test/serialCases/dll-plugin-format/0-create-dll/rspack.config.js index 92cb893cc84c..05bcff93f274 100644 --- a/tests/rspack-test/serialCases/dll-plugin-format/0-create-dll/rspack.config.js +++ b/tests/rspack-test/serialCases/dll-plugin-format/0-create-dll/rspack.config.js @@ -10,7 +10,7 @@ module.exports = { output: { filename: "dll.js", chunkFilename: "[id].dll.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, plugins: [ new webpack.DllPlugin({ diff --git a/tests/rspack-test/serialCases/dll-plugin-side-effects/0-create-dll/rspack.config.js b/tests/rspack-test/serialCases/dll-plugin-side-effects/0-create-dll/rspack.config.js index e12ea85e1894..9ba757746fa4 100644 --- a/tests/rspack-test/serialCases/dll-plugin-side-effects/0-create-dll/rspack.config.js +++ b/tests/rspack-test/serialCases/dll-plugin-side-effects/0-create-dll/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { output: { filename: "dll.js", chunkFilename: "[id].dll.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, module: { rules: [ diff --git a/tests/rspack-test/serialCases/dll-plugin/0-create-dll-with-contenthash/rspack.config.js b/tests/rspack-test/serialCases/dll-plugin/0-create-dll-with-contenthash/rspack.config.js index c71f7fff201b..db4a5aa6a9d7 100644 --- a/tests/rspack-test/serialCases/dll-plugin/0-create-dll-with-contenthash/rspack.config.js +++ b/tests/rspack-test/serialCases/dll-plugin/0-create-dll-with-contenthash/rspack.config.js @@ -10,7 +10,7 @@ module.exports = { output: { filename: "dll.js", chunkFilename: "[id].dll.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, module: { rules: [ diff --git a/tests/rspack-test/serialCases/dll-plugin/0-create-dll/rspack.config.js b/tests/rspack-test/serialCases/dll-plugin/0-create-dll/rspack.config.js index ac8d019e1254..08cb08c0ebf0 100644 --- a/tests/rspack-test/serialCases/dll-plugin/0-create-dll/rspack.config.js +++ b/tests/rspack-test/serialCases/dll-plugin/0-create-dll/rspack.config.js @@ -10,7 +10,7 @@ module.exports = { output: { filename: "dll.js", chunkFilename: "[id].dll.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, module: { rules: [ diff --git a/tests/rspack-test/serialCases/dll-plugin/0-issue-10475/rspack.config.js b/tests/rspack-test/serialCases/dll-plugin/0-issue-10475/rspack.config.js index f89c4fa66091..f490ace778a9 100644 --- a/tests/rspack-test/serialCases/dll-plugin/0-issue-10475/rspack.config.js +++ b/tests/rspack-test/serialCases/dll-plugin/0-issue-10475/rspack.config.js @@ -7,7 +7,7 @@ module.exports = { output: { filename: "dll.js", chunkFilename: "[id].dll.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, plugins: [ new webpack.DllPlugin({ diff --git a/tests/rspack-test/serialCases/library/0-create-library/rspack.config.js b/tests/rspack-test/serialCases/library/0-create-library/rspack.config.js index 3aa6a42cbe7e..094c7676560c 100644 --- a/tests/rspack-test/serialCases/library/0-create-library/rspack.config.js +++ b/tests/rspack-test/serialCases/library/0-create-library/rspack.config.js @@ -6,7 +6,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "esm", filename: "esm.js", - libraryTarget: "module" + library: { type: "module" } }, target: "node14", resolve: { @@ -23,7 +23,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "modern-module", filename: "modern-module.js", - libraryTarget: "modern-module" + library: { type: "modern-module" } }, target: "node14", resolve: { @@ -43,7 +43,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "esm-runtimeChunk", filename: "esm-runtimeChunk/[name].js", - libraryTarget: "module" + library: { type: "module" } }, target: "node14", resolve: { @@ -63,7 +63,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs", filename: "commonjs.js", - libraryTarget: "commonjs", + library: { type: "commonjs" }, iife: false }, resolve: { @@ -77,7 +77,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs-iife", filename: "commonjs-iife.js", - libraryTarget: "commonjs", + library: { type: "commonjs" }, iife: true }, resolve: { @@ -91,7 +91,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "amd", filename: "amd.js", - libraryTarget: "amd", + library: { type: "amd" }, iife: false }, resolve: { @@ -105,7 +105,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "amd-iife", filename: "amd-iife.js", - libraryTarget: "amd", + library: { type: "amd" }, iife: true }, resolve: { @@ -119,7 +119,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "amd-runtimeChunk", filename: "amd-runtimeChunk/[name].js", - libraryTarget: "amd", + library: { type: "amd" }, globalObject: "global", iife: false }, @@ -138,7 +138,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "amd-iife-runtimeChunk", filename: "amd-iife-runtimeChunk/[name].js", - libraryTarget: "amd", + library: { type: "amd" }, globalObject: "global", iife: true }, @@ -157,7 +157,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "umd", filename: "umd.js", - libraryTarget: "umd" + library: { type: "umd" } }, resolve: { alias: { @@ -220,8 +220,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "umd-default", filename: "umd-default.js", - libraryTarget: "umd", - libraryExport: "default" + library: { type: "umd", export: "default" }, }, resolve: { alias: { @@ -234,7 +233,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "this", filename: "this.js", - libraryTarget: "this", + library: { type: "this" }, iife: false }, resolve: { @@ -248,7 +247,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "this-iife", filename: "this-iife.js", - libraryTarget: "this", + library: { type: "this" }, iife: true }, resolve: { @@ -303,8 +302,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs-nested", filename: "commonjs-nested.js", - libraryTarget: "commonjs", - libraryExport: "NS", + library: { type: "commonjs", export: "NS" }, iife: false }, resolve: { @@ -319,8 +317,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs-nested-iife", filename: "commonjs-nested-iife.js", - libraryTarget: "commonjs", - libraryExport: "NS", + library: { type: "commonjs", export: "NS" }, iife: true }, resolve: { @@ -334,7 +331,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs2-external", filename: "commonjs2-external.js", - libraryTarget: "commonjs2", + library: { type: "commonjs2" }, iife: false }, externals: ["external", "external-named"] @@ -343,7 +340,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs2-external-no-concat", filename: "commonjs2-external-no-concat.js", - libraryTarget: "commonjs2", + library: { type: "commonjs2" }, iife: false }, optimization: { @@ -355,7 +352,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs2-iife-external", filename: "commonjs2-iife-external.js", - libraryTarget: "commonjs2", + library: { type: "commonjs2" }, iife: true }, externals: ["external", "external-named"] @@ -365,7 +362,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs2-external-eval", filename: "commonjs2-external-eval.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, externals: ["external", "external-named"] }, @@ -374,7 +371,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs2-external-eval-source-map", filename: "commonjs2-external-eval-source-map.js", - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, devtool: "eval-source-map", externals: ["external", "external-named"] @@ -383,7 +380,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs-static-external", filename: "commonjs-static-external.js", - libraryTarget: "commonjs-static", + library: { type: "commonjs-static" }, iife: false }, externals: ["external", "external-named"] @@ -393,7 +390,7 @@ module.exports = (env, { testPath }) => [ uniqueName: "index", filename: "index.js", path: path.resolve(testPath, "commonjs2-split-chunks"), - libraryTarget: "commonjs2" + library: { type: "commonjs2" } }, target: "node", optimization: { @@ -419,7 +416,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs2-runtimeChunk", filename: "commonjs2-runtimeChunk/[name].js", - libraryTarget: "commonjs2", + library: { type: "commonjs2" }, iife: false }, resolve: { @@ -436,7 +433,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "commonjs2-iife-runtimeChunk", filename: "commonjs2-iife-runtimeChunk/[name].js", - libraryTarget: "commonjs2", + library: { type: "commonjs2" }, iife: true }, resolve: { @@ -453,8 +450,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "global-runtimeChunk", filename: "global-runtimeChunk/[name].js", - library: ["globalName", "x", "y"], - libraryTarget: "global", + library: { type: "global", name: ["globalName", "x", "y"] }, iife: false }, target: "web", @@ -472,8 +468,7 @@ module.exports = (env, { testPath }) => [ output: { uniqueName: "global-iife-runtimeChunk", filename: "global-iife-runtimeChunk/[name].js", - library: ["globalName", "x", "y"], - libraryTarget: "global", + library: { type: "global", name: ["globalName", "x", "y"] }, iife: true }, target: "web", diff --git a/website/docs/en/api/runtime-api/module-variables.mdx b/website/docs/en/api/runtime-api/module-variables.mdx index a13c7e922504..1b1b27d7428f 100644 --- a/website/docs/en/api/runtime-api/module-variables.mdx +++ b/website/docs/en/api/runtime-api/module-variables.mdx @@ -663,7 +663,7 @@ This method is used to initialize modules of a shared scope in the host containe -Context from System.js when `output.libraryTarget="system"` +Context from System.js when `output.library.type="system"` ## Rspack diff --git a/website/docs/en/config/externals.mdx b/website/docs/en/config/externals.mdx index 50efecb9cb7f..c12dc3b05725 100644 --- a/website/docs/en/config/externals.mdx +++ b/website/docs/en/config/externals.mdx @@ -110,13 +110,13 @@ export default { ### object :::warning -An object with `{ root, commonjs, commonjs2, amd, ... }` is only allowed for [`libraryTarget: 'umd'`](/config/output#outputlibrarytarget) and [`externalsType: 'umd'`](#externalstype). It's not allowed for other library targets. +An object with `{ root, commonjs, commonjs2, amd, ... }` is only allowed for [`library.type: 'umd'`](/config/output#outputlibrarytarget) and [`externalsType: 'umd'`](#externalstype). It's not allowed for other library targets. ::: ```js title="rspack.config.mjs" export default { externals: { - // When `libraryTarget: 'umd'` and `externalsType: 'umd'`, the following format must be strictly followed: + // When `library.type: 'umd'` and `externalsType: 'umd'`, the following format must be strictly followed: lodash: { root: '_', // indicates global variable commonjs: 'lodash', @@ -277,7 +277,7 @@ export default { - **Type:** `string` - **Default:** `'var'` -Specify the default type of externals. `amd`, `umd`, `system` and `jsonp` externals **depend on the [`output.libraryTarget`](/config/output#outputlibrarytarget)** being set to the same value e.g. you can only consume `amd` externals within an `amd` library. +Specify the default type of externals. `amd`, `umd`, `system` and `jsonp` externals **depend on the [`output.library.type`](/config/output#outputlibrarytype)** being set to the same value e.g. you can only consume `amd` externals within an `amd` library. Supported types: diff --git a/website/docs/en/config/output.mdx b/website/docs/en/config/output.mdx index 6c206a0f96a1..be9394275926 100644 --- a/website/docs/en/config/output.mdx +++ b/website/docs/en/config/output.mdx @@ -616,8 +616,10 @@ For example: ```js title="rspack.config.mjs" export default { output: { - library: 'myLib', - libraryTarget: 'umd', + library: { + name: 'myLib', + type: 'umd', + }, filename: 'myLib.js', globalObject: 'this', }, @@ -1298,7 +1300,9 @@ Note that omitting `library.name` will result in the assignment of all propertie export default { //... output: { - libraryTarget: 'umd', + library: { + type: 'umd', + }, }, }; ``` @@ -1551,7 +1555,7 @@ Output JavaScript files as module type. Disabled by default as it's an experimen When enabled, Rspack will set [`output.iife`](#outputiife) to `false`, [`output.scriptType`](#outputscripttype) to `'module'` and `terserOptions.module` to `true` internally. -If you're using Rspack to compile a library to be consumed by others, make sure to set [`output.libraryTarget`](#librarytarget-module) to `'module'` when `output.module` is `true`. +If you're using Rspack to compile a library to be consumed by others, make sure to set [`output.library.type`](#outputlibrarytype) to `'module'` when `output.module` is `true`. ```js title="rspack.config.mjs" export default { @@ -1871,27 +1875,3 @@ export default { }, }; ``` - -## output.auxiliaryComment - -:::warning -Prefer to use [`output.library.auxiliaryComment`](#outputlibraryauxiliarycomment) instead. -::: - -## output.libraryExport \{#outputlibraryexport-1} - -:::warning -We might drop support for this, so prefer to use [output.library.export](#outputlibraryexport) which works the same as `libraryExport`. -::: - -## output.libraryTarget - -:::warning -Please use [`output.library.type`](#outputlibrarytype) instead as we might drop support for `output.libraryTarget` in the future. -::: - -## output.umdNamedDefine - -:::warning -Prefer to use [`output.library.umdNamedDefine`](#outputlibraryumdnameddefine) instead. -::: diff --git a/website/docs/zh/api/runtime-api/module-variables.mdx b/website/docs/zh/api/runtime-api/module-variables.mdx index b02cd55f8431..8124e093600e 100644 --- a/website/docs/zh/api/runtime-api/module-variables.mdx +++ b/website/docs/zh/api/runtime-api/module-variables.mdx @@ -655,7 +655,7 @@ __webpack_get_script_filename__ = (chunkId) => { -可在 `output.libraryTarget="system"` 时获取 System.js 上下文。 +可在 `output.library.type="system"` 时获取 System.js 上下文。 ## Rspack diff --git a/website/docs/zh/config/externals.mdx b/website/docs/zh/config/externals.mdx index 992511a185a6..b6b3fa6090f1 100644 --- a/website/docs/zh/config/externals.mdx +++ b/website/docs/zh/config/externals.mdx @@ -110,13 +110,13 @@ export default { ### 对象 :::warning -带有 `{ root, commonjs, commonjs2, amd, ... }` 的对象只允许用于 [`libraryTarget: 'umd'`](/config/output#outputlibrarytarget) 和 [`externalsType: 'umd'`](#externalstype)。其他库的 target 不允许这样做。 +带有 `{ root, commonjs, commonjs2, amd, ... }` 的对象只允许用于 [`library.type: 'umd'`](/config/output#outputlibrarytarget) 和 [`externalsType: 'umd'`](#externalstype)。其他库的 target 不允许这样做。 ::: ```js title="rspack.config.mjs" export default { externals: { - // 在 `libraryTarget: 'umd'` 和 `externalsType: 'umd'` 时,需严格遵循以下格式: + // 在 `library.type: 'umd'` 和 `externalsType: 'umd'` 时,需严格遵循以下格式: lodash: { root: '_', // 指向全局变量 commonjs: 'lodash', @@ -277,7 +277,7 @@ export default { - **类型:** `string` - **默认值:** `'var'` -指定 externals 的默认类型。当 external 被设置为 `amd`,`umd`,`system` 以及 `jsonp` 时,[`output.libraryTarget`](/config/output#outputlibrarytarget) 的值也应相同。例如,你只能在 `amd` 库中使用 `amd` 的 externals。 +指定 externals 的默认类型。当 external 被设置为 `amd`,`umd`,`system` 以及 `jsonp` 时,[`output.library.type`](/config/output#outputlibrarytype) 的值也应相同。例如,你只能在 `amd` 库中使用 `amd` 的 externals。 支持的类型如下: diff --git a/website/docs/zh/config/output.mdx b/website/docs/zh/config/output.mdx index 03022d1812e1..f831d93a6524 100644 --- a/website/docs/zh/config/output.mdx +++ b/website/docs/zh/config/output.mdx @@ -598,7 +598,7 @@ export default { - **类型:** `string` - **默认值:** `'self'` -当输出为 library 时,尤其是当 `libraryTarget` 为 `'umd'`时,此选项将决定使用哪个全局对象来挂载 library。为了使 UMD 构建在浏览器和 Node.js 上均可用,应将 `output.globalObject` 选项设置为 `'this'`。对于类似 web 的目标,默认为 `self`。 +当输出为 library 时,尤其是当 `library.type` 为 `'umd'`时,此选项将决定使用哪个全局对象来挂载 library。为了使 UMD 构建在浏览器和 Node.js 上均可用,应将 `output.globalObject` 选项设置为 `'this'`。对于类似 web 的目标,默认为 `self`。 入口点的返回值将会使用 `output.library.name` 赋值给全局对象。依赖于 `target` 配置项,全局对象将会发生对应的改变,例如:`self`, `global` 或者 `globalThis`。 @@ -607,8 +607,10 @@ export default { ```js title="rspack.config.mjs" export default { output: { - library: 'myLib', - libraryTarget: 'umd', + library: { + name: 'myLib', + type: 'umd', + }, filename: 'myLib.js', globalObject: 'this', }, @@ -1290,7 +1292,9 @@ export default { export default { //... output: { - libraryTarget: 'umd', + library: { + type: 'umd', + }, }, }; ``` @@ -1863,27 +1867,3 @@ export default { }, }; ``` - -## output.auxiliaryComment - -:::warning -请优先使用 [`output.library.auxiliaryComment`](#outputlibraryauxiliarycomment)。 -::: - -## output.libraryExport \{#outputlibraryexport-1} - -:::warning -我们可能会停止对此的支持,所以最好使用 [output.library.export](#outputlibraryexport),其作用与 `libraryExport` 一致。 -::: - -## output.libraryTarget - -:::warning -请使用 [`output.library.type`](#outputlibrarytype) 代替,因为我们可能在未来放弃对 `output.libraryTarget` 的支持。 -::: - -## output.umdNamedDefine - -:::warning -最好使用 [`output.library.umdNamedDefine`](#outputlibraryumdnameddefine)。 -:::