@@ -1976,14 +1976,6 @@ describe("snapshots", () => {
19761976 - "progress": false,
19771977 + "progress": "auto",
19781978 @@ ... @@
1979- - "dynamicImport": undefined,
1980- - "dynamicImportInWorker": undefined,
1981- + "dynamicImport": true,
1982- + "dynamicImportInWorker": true,
1983- @@ ... @@
1984- - "module": undefined,
1985- + "module": true,
1986- @@ ... @@
19871979 - "mode": "none",
19881980 + "mode": "development",
19891981 @@ ... @@
@@ -1993,7 +1985,7 @@ describe("snapshots", () => {
19931985 + Object {
19941986 + "resourceQuery": /(\\?|&)raw(&|$)/,
19951987 + "type": "asset/source",
1996- @@ ... @@
1988+ + },
19971989 + Object {
19981990 + "resourceQuery": /(\\?|&)url(&|$)/,
19991991 + "type": "asset/resource",
@@ -2006,9 +1998,7 @@ describe("snapshots", () => {
20061998 + "resourceQuery": /(\\?|&)inline(&|$)/,
20071999 + "type": "asset/inline",
20082000 + },
2009- @@ ... @@
2010- + },
2011- + ],
2001+ + ],
20122002 @@ ... @@
20132003 - "localIdentHashFunction": "md4",
20142004 + "localIdentHashFunction": "xxhash64",
@@ -2033,9 +2023,6 @@ describe("snapshots", () => {
20332023 @@ ... @@
20342024 + "exportsPresence": "error",
20352025 @@ ... @@
2036- - "importMeta": true,
2037- + "importMeta": "preserve-unknown",
2038- @@ ... @@
20392026 - "strictModeViolations": "warn",
20402027 + "strictModeViolations": "error",
20412028 @@ ... @@
@@ -2064,57 +2051,29 @@ describe("snapshots", () => {
20642051 + "minRemainingSize": 0,
20652052 @@ ... @@
20662053 - "charset": true,
2067- - "chunkFilename": "[name].js",
2068- - "chunkFormat": "array-push",
20692054 + "charset": false,
2070- + "chunkFilename": "[name].mjs",
2071- + "chunkFormat": "module",
20722055 @@ ... @@
2073- - "chunkLoading": "jsonp",
20742056 - "chunkLoadingGlobal": "webpackChunkwebpack",
2075- + "chunkLoading": "import",
20762057 + "chunkLoadingGlobal": "webpackChunkmyLib",
20772058 @@ ... @@
20782059 - "devtoolNamespace": "webpack",
20792060 + "devtoolNamespace": "myLib",
20802061 @@ ... @@
2081- - "jsonp",
2082- - "import-scripts",
2083- + "import",
20842062 + ],
20852063 + "enabledLibraryTypes": Array [
20862064 + "var",
20872065 @@ ... @@
20882066 - "enabledLibraryTypes": Array [],
20892067 @@ ... @@
2090- - "dynamicImport": undefined,
2091- - "dynamicImportInWorker": undefined,
2092- + "dynamicImport": true,
2093- + "dynamicImportInWorker": true,
2094- @@ ... @@
2095- - "module": undefined,
2096- + "module": true,
2097- @@ ... @@
2098- - "filename": "[name].js",
2099- + "filename": "[name].mjs",
2100- @@ ... @@
21012068 - "hashDigestLength": 20,
21022069 - "hashFunction": "md4",
21032070 + "hashDigestLength": 16,
21042071 + "hashFunction": "xxhash64",
21052072 @@ ... @@
2106- - "hotUpdateChunkFilename": "[id].[fullhash].hot-update.js",
21072073 - "hotUpdateGlobal": "webpackHotUpdatewebpack",
2108- - "hotUpdateMainFilename": "[runtime].[fullhash].hot-update.json",
2109- + "hotUpdateChunkFilename": "[id].[fullhash].hot-update.mjs",
21102074 + "hotUpdateGlobal": "webpackHotUpdatemyLib",
2111- + "hotUpdateMainFilename": "[runtime].[fullhash].hot-update.json.mjs",
2112- @@ ... @@
2113- - "iife": true,
2114- + "iife": false,
21152075 @@ ... @@
21162076 - "library": undefined,
2117- - "module": false,
21182077 + "library": Object {
21192078 + "amdContainer": undefined,
21202079 + "auxiliaryComment": undefined,
@@ -2124,31 +2083,16 @@ describe("snapshots", () => {
21242083 + "umdAmdContainer": undefined,
21252084 + "umdNamedDefine": undefined,
21262085 + },
2127- + "module": true,
21282086 @@ ... @@
21292087 - "pathinfo": false,
21302088 + "pathinfo": true,
21312089 @@ ... @@
2132- - "resourceHints": undefined,
2133- - "scriptType": false,
2134- + "resourceHints": Object {
2135- + "dedupe": false,
2136- + "initial": true,
2137- + "modulePreloadPolyfill": false,
2138- + },
2139- + "scriptType": "module",
2140- @@ ... @@
21412090 - "strictModuleResolution": false,
21422091 + "strictModuleResolution": true,
21432092 @@ ... @@
21442093 - "uniqueName": "webpack",
21452094 + "uniqueName": "myLib",
21462095 @@ ... @@
2147- - "workerChunkFilename": "[name].js",
2148- - "workerChunkLoading": "import-scripts",
2149- + "workerChunkFilename": "[name].mjs",
2150- + "workerChunkLoading": "import",
2151- @@ ... @@
21522096 - "production",
21532097 + "development",
21542098 @@ ... @@
@@ -6544,6 +6488,74 @@ describe("futureDefaults module output", () => {
65446488 ) . toBe ( true ) ;
65456489 } ) ;
65466490
6491+ it ( "should keep script output for a declared script library type" , ( ) => {
6492+ for ( const library of [
6493+ { type : /** @type {"var" } */ ( "var" ) , name : "myLib" } ,
6494+ { type : /** @type {"umd" } */ ( "umd" ) , name : "myLib" } ,
6495+ { type : /** @type {"commonjs2" } */ ( "commonjs2" ) }
6496+ ] ) {
6497+ const config = getDefaultConfig ( {
6498+ mode : "none" ,
6499+ output : { library } ,
6500+ experiments : { futureDefaults : true }
6501+ } ) ;
6502+
6503+ expect ( config . output . module ) . toBe ( false ) ;
6504+ expect ( config . output . iife ) . toBe ( true ) ;
6505+ }
6506+ } ) ;
6507+
6508+ it ( "should keep script output for a library type declared by an entry" , ( ) => {
6509+ const config = getDefaultConfig ( {
6510+ mode : "none" ,
6511+ entry : {
6512+ main : { import : "./index.js" , library : { type : "var" , name : "myLib" } }
6513+ } ,
6514+ experiments : { futureDefaults : true }
6515+ } ) ;
6516+
6517+ expect ( config . output . module ) . toBe ( false ) ;
6518+ } ) ;
6519+
6520+ it ( "should keep script output for a library type declared by a plugin" , ( ) => {
6521+ const webpack = require ( ".." ) ;
6522+
6523+ const compiler = webpack ( {
6524+ mode : "none" ,
6525+ entry : "./index.js" ,
6526+ experiments : { futureDefaults : true } ,
6527+ plugins : [
6528+ new webpack . container . ModuleFederationPlugin ( {
6529+ name : "container" ,
6530+ library : { type : "var" , name : "container" } ,
6531+ exposes : { "./a" : "./index.js" }
6532+ } )
6533+ ]
6534+ } ) ;
6535+
6536+ expect ( compiler . options . output . module ) . toBe ( false ) ;
6537+ } ) ;
6538+
6539+ it ( "should still emit an ECMAScript module for a module library type" , ( ) => {
6540+ expect (
6541+ getDefaultConfig ( {
6542+ mode : "none" ,
6543+ output : { library : { type : "module" } } ,
6544+ experiments : { futureDefaults : true }
6545+ } ) . output . module
6546+ ) . toBe ( true ) ;
6547+ } ) ;
6548+
6549+ it ( "should let an explicit output.module win over a script library type" , ( ) => {
6550+ expect (
6551+ getDefaultConfig ( {
6552+ mode : "none" ,
6553+ output : { module : true , library : { type : "var" , name : "myLib" } } ,
6554+ experiments : { futureDefaults : true }
6555+ } ) . output . module
6556+ ) . toBe ( true ) ;
6557+ } ) ;
6558+
65476559 it ( "should keep script output without futureDefaults" , ( ) => {
65486560 expect (
65496561 getDefaultConfig ( { mode : "none" , target : "browserslist: chrome 100" } )
0 commit comments