Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/rspack/etc/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions packages/rspack/scripts/check-documentation-coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 3 additions & 5 deletions packages/rspack/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import type {
JavascriptParserOptions,
JsonGeneratorOptions,
Library,
LibraryOptions,
Loader,
Mode,
ModuleOptions,
Expand Down Expand Up @@ -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('.');
Expand Down
30 changes: 4 additions & 26 deletions packages/rspack/src/config/normalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
30 changes: 3 additions & 27 deletions packages/rspack/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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[];
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/src/lib/DllPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack/src/lib/DllReferencePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down Expand Up @@ -67,7 +67,7 @@ export type DllReferencePluginOptions =
*/
scope?: string;
/**
* How the dll is exposed (libraryTarget).
* How the dll is exposed (library.type).
*/
sourceType?: DllReferencePluginOptionsSourceType;
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/src/util/validateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const { ModuleFederationPlugin } = require("@rspack/core").container;
function createConfig() {
return {
output: {
libraryTarget: "system"
library: { type: "system" }
},
plugins: [
new ModuleFederationPlugin({
name: "container",
filename: "container.js",
library: { type: "system" },
exposes: ["./other", "./self", "./dep"],
manifest:false,
manifest: false,
remotes: {
abc: "ABC",
def: "DEF",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
output: {
libraryTarget: "commonjs-module",
library: { type: "commonjs-module" },
importFunctionName: "((name) => Promise.resolve({ request: name }))"
},
externals: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const webpack = require("@rspack/core");
module.exports = [
{
output: {
libraryTarget: "commonjs2"
library: { type: "commonjs2" }
},
externals: {
external: ["@rspack/core", "version"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "system"
library: { type: "system" }
},
target: "web",
node: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "system"
library: { type: "system" }
},
externals: {
external1: "external1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "umd"
library: { type: "umd" }
},
externals: {
external0: "external0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "umd2"
library: { type: "umd2" }
},
externals: {
external0: "external0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "commonjs2"
library: { type: "commonjs2" }
},
externals: {
external: "external"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "umd"
library: { type: "umd" }
},
externals: {
external: "external"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "umd2"
library: { type: "umd2" }
},
externals: {
external: "external",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "umd2"
library: { type: "umd2" }
},
externals: {
external: "external"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
libraryTarget: "umd"
library: { type: "umd" }
},
externals: {
external: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { CopyRspackPlugin } = require("@rspack/core");
module.exports = {
entry: "./index.js",
output: {
libraryTarget: "umd"
library: { type: "umd" }
},
externals: {
lodash: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { CopyRspackPlugin } = require("@rspack/core");
module.exports = {
entry: "./index.js",
output: {
libraryTarget: "umd"
library: { type: "umd" }
},
externals: {
lodash: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
__filename: false
},
output: {
libraryTarget: "commonjs2"
library: { type: "commonjs2" }
},
optimization: {
splitChunks: {
Expand Down
Loading
Loading