@rspack/browser 2.0.0-beta.3 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { Compiler } from '../Compiler';
|
|
2
|
-
import type { RspackOptionsNormalized } from '../config';
|
|
2
|
+
import type { OptimizationSplitChunksOptions, RspackOptionsNormalized } from '../config';
|
|
3
3
|
export declare function applyLimits(options: RspackOptionsNormalized): void;
|
|
4
4
|
export declare class EsmLibraryPlugin {
|
|
5
5
|
static PLUGIN_NAME: string;
|
|
6
|
-
options
|
|
6
|
+
options: {
|
|
7
7
|
preserveModules?: string;
|
|
8
|
+
splitChunks?: OptimizationSplitChunksOptions | false;
|
|
8
9
|
};
|
|
9
10
|
constructor(options?: {
|
|
10
11
|
preserveModules?: string;
|
|
12
|
+
splitChunks?: OptimizationSplitChunksOptions | false;
|
|
11
13
|
});
|
|
12
14
|
apply(compiler: Compiler): void;
|
|
13
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BuiltinPlugin, BuiltinPluginName } from '../binding';
|
|
1
|
+
import { type BuiltinPlugin, BuiltinPluginName, type RawSplitChunksOptions } from '../binding';
|
|
2
2
|
import type { Compiler } from '../Compiler';
|
|
3
3
|
import type { OptimizationSplitChunksOptions } from '../config';
|
|
4
4
|
import { RspackBuiltinPlugin } from './base';
|
|
@@ -9,3 +9,4 @@ export declare class SplitChunksPlugin extends RspackBuiltinPlugin {
|
|
|
9
9
|
constructor(options: OptimizationSplitChunksOptions);
|
|
10
10
|
raw(compiler: Compiler): BuiltinPlugin;
|
|
11
11
|
}
|
|
12
|
+
export declare function toRawSplitChunksOptions(sc: false | OptimizationSplitChunksOptions, compiler: Compiler): RawSplitChunksOptions | undefined;
|
package/dist/index.js
CHANGED
|
@@ -52740,10 +52740,95 @@ class EnableLibraryPlugin extends RspackBuiltinPlugin {
|
|
|
52740
52740
|
const EnableWasmLoadingPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.EnableWasmLoadingPlugin, (type)=>type);
|
|
52741
52741
|
const EnsureChunkConditionsPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.EnsureChunkConditionsPlugin, ()=>{});
|
|
52742
52742
|
const RemoveDuplicateModulesPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.RemoveDuplicateModulesPlugin, ()=>({}));
|
|
52743
|
+
class JsSplitChunkSizes {
|
|
52744
|
+
static __to_binding(sizes) {
|
|
52745
|
+
if ('number' == typeof sizes) return sizes;
|
|
52746
|
+
if (sizes && 'object' == typeof sizes) {
|
|
52747
|
+
const chunkSizes = {
|
|
52748
|
+
sizes: sizes
|
|
52749
|
+
};
|
|
52750
|
+
return chunkSizes;
|
|
52751
|
+
}
|
|
52752
|
+
return sizes;
|
|
52753
|
+
}
|
|
52754
|
+
}
|
|
52755
|
+
class SplitChunksPlugin extends RspackBuiltinPlugin {
|
|
52756
|
+
options;
|
|
52757
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.SplitChunksPlugin;
|
|
52758
|
+
affectedHooks = 'thisCompilation';
|
|
52759
|
+
constructor(options){
|
|
52760
|
+
super(), this.options = options;
|
|
52761
|
+
}
|
|
52762
|
+
raw(compiler) {
|
|
52763
|
+
const rawOptions = toRawSplitChunksOptions(this.options, compiler);
|
|
52764
|
+
if (void 0 === rawOptions) throw new Error('rawOptions should not be undefined');
|
|
52765
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
52766
|
+
}
|
|
52767
|
+
}
|
|
52768
|
+
function toRawSplitChunksOptions(sc, compiler) {
|
|
52769
|
+
if (!sc) return;
|
|
52770
|
+
function getName(name) {
|
|
52771
|
+
if ('function' == typeof name) return (ctx)=>{
|
|
52772
|
+
if (void 0 === ctx.module) return name(void 0);
|
|
52773
|
+
return name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey);
|
|
52774
|
+
};
|
|
52775
|
+
return name;
|
|
52776
|
+
}
|
|
52777
|
+
function getTest(test) {
|
|
52778
|
+
if ('function' == typeof test) return (ctx)=>{
|
|
52779
|
+
const info = {
|
|
52780
|
+
moduleGraph: compiler._lastCompilation.moduleGraph,
|
|
52781
|
+
chunkGraph: compiler._lastCompilation.chunkGraph
|
|
52782
|
+
};
|
|
52783
|
+
return test(ctx.module, info);
|
|
52784
|
+
};
|
|
52785
|
+
return test;
|
|
52786
|
+
}
|
|
52787
|
+
function getChunks(chunks) {
|
|
52788
|
+
if ('function' == typeof chunks) return (chunk)=>chunks(chunk);
|
|
52789
|
+
return chunks;
|
|
52790
|
+
}
|
|
52791
|
+
const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
|
|
52792
|
+
return {
|
|
52793
|
+
name: getName(name),
|
|
52794
|
+
chunks: getChunks(chunks),
|
|
52795
|
+
defaultSizeTypes: defaultSizeTypes || [
|
|
52796
|
+
"javascript",
|
|
52797
|
+
'unknown'
|
|
52798
|
+
],
|
|
52799
|
+
cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>false !== group).map(([key, group])=>{
|
|
52800
|
+
const { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
|
|
52801
|
+
const rawGroup = {
|
|
52802
|
+
key,
|
|
52803
|
+
test: getTest(test),
|
|
52804
|
+
name: getName(name),
|
|
52805
|
+
chunks: getChunks(chunks),
|
|
52806
|
+
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
52807
|
+
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
52808
|
+
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
52809
|
+
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
52810
|
+
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
52811
|
+
...passThrough
|
|
52812
|
+
};
|
|
52813
|
+
return rawGroup;
|
|
52814
|
+
}),
|
|
52815
|
+
fallbackCacheGroup: {
|
|
52816
|
+
chunks: getChunks(chunks),
|
|
52817
|
+
...fallbackCacheGroup
|
|
52818
|
+
},
|
|
52819
|
+
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
52820
|
+
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
52821
|
+
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
52822
|
+
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
52823
|
+
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
52824
|
+
...passThrough
|
|
52825
|
+
};
|
|
52826
|
+
}
|
|
52743
52827
|
function applyLimits(options) {
|
|
52744
52828
|
options.optimization.concatenateModules = false;
|
|
52745
52829
|
options.optimization.removeEmptyChunks = false;
|
|
52746
52830
|
options.output.chunkFormat = false;
|
|
52831
|
+
options.output.module = true;
|
|
52747
52832
|
if (options.output.chunkLoading && 'import' !== options.output.chunkLoading) options.output.chunkLoading = 'import';
|
|
52748
52833
|
if (void 0 === options.output.chunkLoading) options.output.chunkLoading = 'import';
|
|
52749
52834
|
let { splitChunks } = options.optimization;
|
|
@@ -52762,7 +52847,7 @@ class EsmLibraryPlugin {
|
|
|
52762
52847
|
static PLUGIN_NAME = 'EsmLibraryPlugin';
|
|
52763
52848
|
options;
|
|
52764
52849
|
constructor(options){
|
|
52765
|
-
this.options = options;
|
|
52850
|
+
this.options = options ?? {};
|
|
52766
52851
|
}
|
|
52767
52852
|
apply(compiler) {
|
|
52768
52853
|
applyLimits(compiler.options);
|
|
@@ -52772,7 +52857,8 @@ class EsmLibraryPlugin {
|
|
|
52772
52857
|
compiler.__internal__registerBuiltinPlugin({
|
|
52773
52858
|
name: external_rspack_wasi_browser_js_.BuiltinPluginName.EsmLibraryPlugin,
|
|
52774
52859
|
options: {
|
|
52775
|
-
preserveModules: this.options
|
|
52860
|
+
preserveModules: this.options.preserveModules,
|
|
52861
|
+
splitChunks: toRawSplitChunksOptions(this.options.splitChunks ?? false, compiler)
|
|
52776
52862
|
}
|
|
52777
52863
|
});
|
|
52778
52864
|
}
|
|
@@ -55872,90 +55958,6 @@ const SizeLimitsPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPlu
|
|
|
55872
55958
|
};
|
|
55873
55959
|
});
|
|
55874
55960
|
const SourceMapDevToolPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.SourceMapDevToolPlugin, (options)=>options, 'compilation');
|
|
55875
|
-
class JsSplitChunkSizes {
|
|
55876
|
-
static __to_binding(sizes) {
|
|
55877
|
-
if ('number' == typeof sizes) return sizes;
|
|
55878
|
-
if (sizes && 'object' == typeof sizes) {
|
|
55879
|
-
const chunkSizes = {
|
|
55880
|
-
sizes: sizes
|
|
55881
|
-
};
|
|
55882
|
-
return chunkSizes;
|
|
55883
|
-
}
|
|
55884
|
-
return sizes;
|
|
55885
|
-
}
|
|
55886
|
-
}
|
|
55887
|
-
class SplitChunksPlugin extends RspackBuiltinPlugin {
|
|
55888
|
-
options;
|
|
55889
|
-
name = external_rspack_wasi_browser_js_.BuiltinPluginName.SplitChunksPlugin;
|
|
55890
|
-
affectedHooks = 'thisCompilation';
|
|
55891
|
-
constructor(options){
|
|
55892
|
-
super(), this.options = options;
|
|
55893
|
-
}
|
|
55894
|
-
raw(compiler) {
|
|
55895
|
-
const rawOptions = toRawSplitChunksOptions(this.options, compiler);
|
|
55896
|
-
if (void 0 === rawOptions) throw new Error('rawOptions should not be undefined');
|
|
55897
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
55898
|
-
}
|
|
55899
|
-
}
|
|
55900
|
-
function toRawSplitChunksOptions(sc, compiler) {
|
|
55901
|
-
if (!sc) return;
|
|
55902
|
-
function getName(name) {
|
|
55903
|
-
if ('function' == typeof name) return (ctx)=>{
|
|
55904
|
-
if (void 0 === ctx.module) return name(void 0);
|
|
55905
|
-
return name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey);
|
|
55906
|
-
};
|
|
55907
|
-
return name;
|
|
55908
|
-
}
|
|
55909
|
-
function getTest(test) {
|
|
55910
|
-
if ('function' == typeof test) return (ctx)=>{
|
|
55911
|
-
const info = {
|
|
55912
|
-
moduleGraph: compiler._lastCompilation.moduleGraph,
|
|
55913
|
-
chunkGraph: compiler._lastCompilation.chunkGraph
|
|
55914
|
-
};
|
|
55915
|
-
return test(ctx.module, info);
|
|
55916
|
-
};
|
|
55917
|
-
return test;
|
|
55918
|
-
}
|
|
55919
|
-
function getChunks(chunks) {
|
|
55920
|
-
if ('function' == typeof chunks) return (chunk)=>chunks(chunk);
|
|
55921
|
-
return chunks;
|
|
55922
|
-
}
|
|
55923
|
-
const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
|
|
55924
|
-
return {
|
|
55925
|
-
name: getName(name),
|
|
55926
|
-
chunks: getChunks(chunks),
|
|
55927
|
-
defaultSizeTypes: defaultSizeTypes || [
|
|
55928
|
-
"javascript",
|
|
55929
|
-
'unknown'
|
|
55930
|
-
],
|
|
55931
|
-
cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>false !== group).map(([key, group])=>{
|
|
55932
|
-
const { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
|
|
55933
|
-
const rawGroup = {
|
|
55934
|
-
key,
|
|
55935
|
-
test: getTest(test),
|
|
55936
|
-
name: getName(name),
|
|
55937
|
-
chunks: getChunks(chunks),
|
|
55938
|
-
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
55939
|
-
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
55940
|
-
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
55941
|
-
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
55942
|
-
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
55943
|
-
...passThrough
|
|
55944
|
-
};
|
|
55945
|
-
return rawGroup;
|
|
55946
|
-
}),
|
|
55947
|
-
fallbackCacheGroup: {
|
|
55948
|
-
chunks: getChunks(chunks),
|
|
55949
|
-
...fallbackCacheGroup
|
|
55950
|
-
},
|
|
55951
|
-
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
55952
|
-
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
55953
|
-
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
55954
|
-
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
55955
|
-
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
55956
|
-
...passThrough
|
|
55957
|
-
};
|
|
55958
|
-
}
|
|
55959
55961
|
var SubresourceIntegrityPlugin_Buffer = __webpack_require__("./src/browser/buffer.ts")["Buffer"];
|
|
55960
55962
|
const SubresourceIntegrityPlugin_PLUGIN_NAME = 'SubresourceIntegrityPlugin';
|
|
55961
55963
|
const NATIVE_HTML_PLUGIN = 'HtmlRspackPlugin';
|
|
@@ -58022,7 +58024,7 @@ const applyOutputDefaults = (options, { context, targetProperties: tp, isAffecte
|
|
|
58022
58024
|
});
|
|
58023
58025
|
D(output, 'bundlerInfo', {});
|
|
58024
58026
|
if ('object' == typeof output.bundlerInfo) {
|
|
58025
|
-
D(output.bundlerInfo, 'version', "2.0.0-beta.
|
|
58027
|
+
D(output.bundlerInfo, 'version', "2.0.0-beta.4");
|
|
58026
58028
|
D(output.bundlerInfo, 'bundler', 'rspack');
|
|
58027
58029
|
D(output.bundlerInfo, 'force', !output.library);
|
|
58028
58030
|
}
|
|
@@ -59684,7 +59686,7 @@ class MultiStats {
|
|
|
59684
59686
|
return obj;
|
|
59685
59687
|
});
|
|
59686
59688
|
if (childOptions.version) {
|
|
59687
|
-
obj.rspackVersion = "2.0.0-beta.
|
|
59689
|
+
obj.rspackVersion = "2.0.0-beta.4";
|
|
59688
59690
|
obj.version = "5.75.0";
|
|
59689
59691
|
}
|
|
59690
59692
|
if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
|
|
@@ -61370,7 +61372,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
61370
61372
|
},
|
|
61371
61373
|
version: (object)=>{
|
|
61372
61374
|
object.version = "5.75.0";
|
|
61373
|
-
object.rspackVersion = "2.0.0-beta.
|
|
61375
|
+
object.rspackVersion = "2.0.0-beta.4";
|
|
61374
61376
|
},
|
|
61375
61377
|
env: (object, _compilation, _context, { _env })=>{
|
|
61376
61378
|
object.env = _env;
|
|
@@ -62953,18 +62955,21 @@ class RspackOptionsApply {
|
|
|
62953
62955
|
if (options.optimization.concatenateModules) new ModuleConcatenationPlugin().apply(compiler);
|
|
62954
62956
|
if (options.optimization.inlineExports) new InlineExportsPlugin().apply(compiler);
|
|
62955
62957
|
if (options.optimization.mangleExports) new MangleExportsPlugin('size' !== options.optimization.mangleExports).apply(compiler);
|
|
62958
|
+
let enableLibSplitChunks = false;
|
|
62956
62959
|
if (options.output.enabledLibraryTypes && options.output.enabledLibraryTypes.length > 0) {
|
|
62957
62960
|
let modernModuleCount = 0;
|
|
62958
62961
|
for (const type of options.output.enabledLibraryTypes)if ('modern-module' === type) modernModuleCount++;
|
|
62959
62962
|
if (options.output.library?.preserveModules && 0 === modernModuleCount) throw new Error('preserveModules only works for `modern-module` library type');
|
|
62960
62963
|
if (modernModuleCount > 0) {
|
|
62961
62964
|
if (modernModuleCount !== options.output.enabledLibraryTypes.length) throw new Error('`modern-module` cannot used together with other library types');
|
|
62965
|
+
enableLibSplitChunks = true;
|
|
62962
62966
|
new EsmLibraryPlugin({
|
|
62963
|
-
preserveModules: options.output.library?.preserveModules
|
|
62967
|
+
preserveModules: options.output.library?.preserveModules,
|
|
62968
|
+
splitChunks: options.optimization.splitChunks
|
|
62964
62969
|
}).apply(compiler);
|
|
62965
62970
|
} else for (const type of options.output.enabledLibraryTypes)new EnableLibraryPlugin(type).apply(compiler);
|
|
62966
62971
|
}
|
|
62967
|
-
if (options.optimization.splitChunks) new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
|
|
62972
|
+
if (!enableLibSplitChunks && options.optimization.splitChunks) new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
|
|
62968
62973
|
if (options.optimization.removeEmptyChunks) new RemoveEmptyChunksPlugin().apply(compiler);
|
|
62969
62974
|
if (options.optimization.realContentHash) new RealContentHashPlugin().apply(compiler);
|
|
62970
62975
|
const moduleIds = options.optimization.moduleIds;
|
|
@@ -66161,7 +66166,7 @@ function transformSync(source, options) {
|
|
|
66161
66166
|
const _options = JSON.stringify(options || {});
|
|
66162
66167
|
return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
|
|
66163
66168
|
}
|
|
66164
|
-
const exports_rspackVersion = "2.0.0-beta.
|
|
66169
|
+
const exports_rspackVersion = "2.0.0-beta.4";
|
|
66165
66170
|
const exports_version = "5.75.0";
|
|
66166
66171
|
const exports_WebpackError = Error;
|
|
66167
66172
|
const exports_config = {
|
package/dist/napi-binding.d.ts
CHANGED
|
Binary file
|
package/package.json
CHANGED