@rsbuild/webpack 0.0.9 → 0.0.12
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.
- package/compiled/webpack-manifest-plugin/types/helpers.d.ts +1 -1
- package/compiled/webpack-manifest-plugin/types/hooks.d.ts +1 -1
- package/dist/config/validate/tools.js +0 -9
- package/dist/core/devMiddleware.js +6 -6
- package/dist/core/initConfigs.d.ts +2 -2
- package/dist/plugins/babel.d.ts +1 -1
- package/dist/plugins/babel.js +5 -11
- package/dist/plugins/moduleScopes.d.ts +2 -2
- package/dist/plugins/react.d.ts +2 -0
- package/dist/plugins/react.js +96 -0
- package/dist/plugins/tsLoader.js +54 -55
- package/dist/shared/plugin.js +1 -1
- package/dist/types/config/source.d.ts +3 -2
- package/dist/types/config/tools.d.ts +8 -8
- package/dist/types/thirdParty/index.d.ts +0 -1
- package/package.json +31 -29
|
@@ -23,10 +23,6 @@ __export(tools_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(tools_exports);
|
|
24
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
25
|
const toolsConfigSchema = import_shared.sharedToolsConfigSchema.extend({
|
|
26
|
-
pug: import_shared.z.union([import_shared.z.literal(true), import_shared.z.chained(import_shared.z.any())]),
|
|
27
|
-
sass: import_shared.z.chained(import_shared.z.any(), import_shared.z.object({ addExcludes: import_shared.FileFilterUtilSchema })),
|
|
28
|
-
less: import_shared.z.chained(import_shared.z.any(), import_shared.z.object({ addExcludes: import_shared.FileFilterUtilSchema })),
|
|
29
|
-
babel: import_shared.z.chained(import_shared.z.any(), import_shared.z.any()),
|
|
30
26
|
terser: import_shared.z.chained(import_shared.z.any()),
|
|
31
27
|
tsLoader: import_shared.z.chained(
|
|
32
28
|
import_shared.z.any(),
|
|
@@ -35,19 +31,14 @@ const toolsConfigSchema = import_shared.sharedToolsConfigSchema.extend({
|
|
|
35
31
|
addExcludes: import_shared.FileFilterUtilSchema
|
|
36
32
|
})
|
|
37
33
|
),
|
|
38
|
-
minifyCss: import_shared.z.chained(import_shared.z.any()),
|
|
39
34
|
htmlPlugin: import_shared.z.chained(
|
|
40
35
|
import_shared.z.any(),
|
|
41
36
|
import_shared.z.object({ entryName: import_shared.z.string(), entryValue: import_shared.z.any() })
|
|
42
37
|
),
|
|
43
|
-
cssLoader: import_shared.z.chained(import_shared.z.any(), import_shared.z.object({ addPlugins: import_shared.z.function() })),
|
|
44
|
-
styleLoader: import_shared.z.chained(import_shared.z.any()),
|
|
45
38
|
cssExtract: import_shared.z.partialObj({
|
|
46
39
|
pluginOptions: import_shared.z.any(),
|
|
47
40
|
loaderOptions: import_shared.z.any()
|
|
48
41
|
}),
|
|
49
|
-
postcss: import_shared.z.chained(import_shared.z.any(), import_shared.z.object({ addPlugins: import_shared.z.function() })),
|
|
50
|
-
autoprefixer: import_shared.z.chained(import_shared.z.any()),
|
|
51
42
|
webpack: import_shared.z.chained(import_shared.z.any(), import_shared.z.any()),
|
|
52
43
|
webpackChain: import_shared.z.arrayOrNot(import_shared.z.function())
|
|
53
44
|
}).partial();
|
|
@@ -35,15 +35,15 @@ var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev
|
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
36
|
const applyHMREntry = (compiler, clientPath) => {
|
|
37
37
|
const applyEntry = (clientEntry, compiler2) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if ((0, import_shared.isClientCompiler)(compiler2)) {
|
|
39
|
+
new compiler2.webpack.EntryPlugin(compiler2.context, clientEntry, {
|
|
40
|
+
name: void 0
|
|
41
|
+
}).apply(compiler2);
|
|
42
|
+
}
|
|
41
43
|
};
|
|
42
44
|
if (compiler.compilers) {
|
|
43
45
|
compiler.compilers.forEach((target) => {
|
|
44
|
-
|
|
45
|
-
applyEntry(clientPath, target);
|
|
46
|
-
}
|
|
46
|
+
applyEntry(clientPath, target);
|
|
47
47
|
});
|
|
48
48
|
} else {
|
|
49
49
|
applyEntry(clientPath, compiler);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PluginStore, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
-
import type { Context } from '../types';
|
|
2
|
+
import type { Context, WebpackConfig } from '../types';
|
|
3
3
|
export type InitConfigsOptions = {
|
|
4
4
|
context: Context;
|
|
5
5
|
pluginStore: PluginStore;
|
|
@@ -10,5 +10,5 @@ export declare function initConfigs({
|
|
|
10
10
|
pluginStore,
|
|
11
11
|
rsbuildOptions
|
|
12
12
|
}: InitConfigsOptions): Promise<{
|
|
13
|
-
webpackConfigs:
|
|
13
|
+
webpackConfigs: WebpackConfig[];
|
|
14
14
|
}>;
|
package/dist/plugins/babel.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RsbuildPlugin, NormalizedConfig } from '../types';
|
|
2
|
-
export declare const getUseBuiltIns: (config: NormalizedConfig) => false | "
|
|
2
|
+
export declare const getUseBuiltIns: (config: NormalizedConfig) => false | "entry" | "usage";
|
|
3
3
|
export declare const pluginBabel: () => RsbuildPlugin;
|
package/dist/plugins/babel.js
CHANGED
|
@@ -36,6 +36,7 @@ var import_lodash = __toESM(require("lodash"));
|
|
|
36
36
|
var import_web = require("@rsbuild/babel-preset/web");
|
|
37
37
|
var import_node = require("@rsbuild/babel-preset/node");
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
|
+
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
39
40
|
var import_shared2 = require("../shared");
|
|
40
41
|
const getUseBuiltIns = (config) => {
|
|
41
42
|
const { polyfill } = config.output;
|
|
@@ -48,14 +49,7 @@ const pluginBabel = () => ({
|
|
|
48
49
|
name: "plugin-babel",
|
|
49
50
|
setup(api) {
|
|
50
51
|
api.modifyBundlerChain(
|
|
51
|
-
async (chain, {
|
|
52
|
-
CHAIN_ID,
|
|
53
|
-
target,
|
|
54
|
-
isProd,
|
|
55
|
-
isServer,
|
|
56
|
-
isServiceWorker,
|
|
57
|
-
getCompiledPath: getCompiledPath2
|
|
58
|
-
}) => {
|
|
52
|
+
async (chain, { CHAIN_ID, target, isProd, isServer, isServiceWorker }) => {
|
|
59
53
|
const config = api.getNormalizedConfig();
|
|
60
54
|
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
|
|
61
55
|
api.context.rootPath,
|
|
@@ -102,7 +96,7 @@ const pluginBabel = () => ({
|
|
|
102
96
|
baseBabelConfig,
|
|
103
97
|
config2.tools.babel,
|
|
104
98
|
{
|
|
105
|
-
...(0,
|
|
99
|
+
...(0, import_plugin_babel.getBabelUtils)(baseBabelConfig),
|
|
106
100
|
...babelUtils
|
|
107
101
|
}
|
|
108
102
|
);
|
|
@@ -133,11 +127,11 @@ const pluginBabel = () => ({
|
|
|
133
127
|
includes,
|
|
134
128
|
excludes
|
|
135
129
|
});
|
|
136
|
-
rule.test(useTsLoader ? import_shared.JS_REGEX : (0, import_shared.mergeRegex)(import_shared.JS_REGEX, import_shared.TS_REGEX)).use(CHAIN_ID.USE.BABEL).loader(
|
|
130
|
+
rule.test(useTsLoader ? import_shared.JS_REGEX : (0, import_shared.mergeRegex)(import_shared.JS_REGEX, import_shared.TS_REGEX)).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelOptions);
|
|
137
131
|
if (config.source.compileJsDataURI) {
|
|
138
132
|
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
139
133
|
or: ["text/javascript", "application/javascript"]
|
|
140
|
-
}).use(CHAIN_ID.USE.BABEL).loader(
|
|
134
|
+
}).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(import_lodash.default.cloneDeep(babelOptions));
|
|
141
135
|
}
|
|
142
136
|
(0, import_shared.addCoreJsEntry)({ chain, config, isServer, isServiceWorker });
|
|
143
137
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ChainedConfig
|
|
2
|
-
import type { RsbuildPlugin } from '../types';
|
|
1
|
+
import { type ChainedConfig } from '@rsbuild/shared';
|
|
2
|
+
import type { RsbuildPlugin, ModuleScopes } from '../types';
|
|
3
3
|
export declare const isPrimitiveScope: (items: unknown[]) => items is (string | RegExp)[];
|
|
4
4
|
export declare const applyScopeChain: (defaults: ModuleScopes, options: ChainedConfig<ModuleScopes>) => ModuleScopes;
|
|
5
5
|
export declare const pluginModuleScopes: () => RsbuildPlugin;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var react_exports = {};
|
|
30
|
+
__export(react_exports, {
|
|
31
|
+
pluginReactWebpack: () => pluginReactWebpack
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(react_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
const pluginReactWebpack = () => ({
|
|
36
|
+
name: "plugin-react-webpack",
|
|
37
|
+
setup(api) {
|
|
38
|
+
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {
|
|
39
|
+
const babelConfig = {
|
|
40
|
+
tools: {
|
|
41
|
+
babel(_, { addPresets, addPlugins }) {
|
|
42
|
+
const isNewJsx = (0, import_shared.isBeyondReact17)(api.context.rootPath);
|
|
43
|
+
const presetReactOptions = {
|
|
44
|
+
development: !(0, import_shared.isProd)(),
|
|
45
|
+
// Will use the native built-in instead of trying to polyfill
|
|
46
|
+
useBuiltIns: true,
|
|
47
|
+
useSpread: false,
|
|
48
|
+
runtime: isNewJsx ? "automatic" : "classic"
|
|
49
|
+
};
|
|
50
|
+
addPresets([
|
|
51
|
+
[require.resolve("@babel/preset-react"), presetReactOptions]
|
|
52
|
+
]);
|
|
53
|
+
if ((0, import_shared.isProd)()) {
|
|
54
|
+
addPlugins([
|
|
55
|
+
[
|
|
56
|
+
require.resolve("babel-plugin-transform-react-remove-prop-types"),
|
|
57
|
+
{ removeImport: true }
|
|
58
|
+
]
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return mergeRsbuildConfig(babelConfig, config);
|
|
65
|
+
});
|
|
66
|
+
api.modifyWebpackChain(async (chain, utils) => {
|
|
67
|
+
const config = api.getNormalizedConfig();
|
|
68
|
+
if (!(0, import_shared.isUsingHMR)(config, utils)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { CHAIN_ID } = utils;
|
|
72
|
+
const { default: ReactFastRefreshPlugin } = await Promise.resolve().then(() => __toESM(require("@pmmmwh/react-refresh-webpack-plugin")));
|
|
73
|
+
const useTsLoader = Boolean(config.tools.tsLoader);
|
|
74
|
+
const rule = useTsLoader ? chain.module.rule(CHAIN_ID.RULE.TS) : chain.module.rule(CHAIN_ID.RULE.JS);
|
|
75
|
+
if (rule.uses.get(CHAIN_ID.USE.BABEL)) {
|
|
76
|
+
rule.use(CHAIN_ID.USE.BABEL).tap((options) => ({
|
|
77
|
+
...options,
|
|
78
|
+
plugins: [
|
|
79
|
+
...options.plugins || [],
|
|
80
|
+
[require.resolve("react-refresh/babel"), { skipEnvCheck: true }]
|
|
81
|
+
]
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactFastRefreshPlugin, [
|
|
85
|
+
{
|
|
86
|
+
overlay: false,
|
|
87
|
+
exclude: [/node_modules/]
|
|
88
|
+
}
|
|
89
|
+
]);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
pluginReactWebpack
|
|
96
|
+
});
|
package/dist/plugins/tsLoader.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(tsLoader_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(tsLoader_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
35
36
|
var import_lodash = __toESM(require("lodash"));
|
|
36
37
|
var import_web = require("@rsbuild/babel-preset/web");
|
|
37
38
|
var import_babel = require("./babel");
|
|
@@ -39,63 +40,61 @@ const pluginTsLoader = () => {
|
|
|
39
40
|
return {
|
|
40
41
|
name: "plugin-ts-loader",
|
|
41
42
|
setup(api) {
|
|
42
|
-
api.modifyWebpackChain(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
api.modifyWebpackChain(async (chain, { target, CHAIN_ID }) => {
|
|
44
|
+
const config = api.getNormalizedConfig();
|
|
45
|
+
if (!config.tools.tsLoader) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const { rootPath } = api.context;
|
|
49
|
+
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
|
|
50
|
+
rootPath,
|
|
51
|
+
config,
|
|
52
|
+
target
|
|
53
|
+
);
|
|
54
|
+
const baseBabelConfig = (0, import_web.getBabelConfigForWeb)({
|
|
55
|
+
presetEnv: {
|
|
56
|
+
targets: browserslist,
|
|
57
|
+
useBuiltIns: (0, import_babel.getUseBuiltIns)(config)
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
includes.push(...import_lodash.default.castArray(items));
|
|
71
|
-
},
|
|
72
|
-
addExcludes(items) {
|
|
73
|
-
excludes.push(...import_lodash.default.castArray(items));
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const tsLoaderOptions = (0, import_shared.mergeChainedOptions)(
|
|
77
|
-
{
|
|
78
|
-
compilerOptions: {
|
|
79
|
-
target: "esnext",
|
|
80
|
-
module: "esnext"
|
|
81
|
-
},
|
|
82
|
-
transpileOnly: true,
|
|
83
|
-
allowTsInNodeModules: true
|
|
59
|
+
});
|
|
60
|
+
const babelUtils = (0, import_plugin_babel.getBabelUtils)(baseBabelConfig);
|
|
61
|
+
const babelLoaderOptions = (0, import_shared.mergeChainedOptions)(
|
|
62
|
+
baseBabelConfig,
|
|
63
|
+
config.tools.babel,
|
|
64
|
+
babelUtils
|
|
65
|
+
);
|
|
66
|
+
const includes = [];
|
|
67
|
+
const excludes = [];
|
|
68
|
+
const tsLoaderUtils = {
|
|
69
|
+
addIncludes(items) {
|
|
70
|
+
includes.push(...import_lodash.default.castArray(items));
|
|
71
|
+
},
|
|
72
|
+
addExcludes(items) {
|
|
73
|
+
excludes.push(...import_lodash.default.castArray(items));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const tsLoaderOptions = (0, import_shared.mergeChainedOptions)(
|
|
77
|
+
{
|
|
78
|
+
compilerOptions: {
|
|
79
|
+
target: "esnext",
|
|
80
|
+
module: "esnext"
|
|
84
81
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
82
|
+
transpileOnly: true,
|
|
83
|
+
allowTsInNodeModules: true
|
|
84
|
+
},
|
|
85
|
+
config.tools.tsLoader,
|
|
86
|
+
tsLoaderUtils
|
|
87
|
+
);
|
|
88
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.TS);
|
|
89
|
+
(0, import_shared.applyScriptCondition)({
|
|
90
|
+
rule,
|
|
91
|
+
config,
|
|
92
|
+
context: api.context,
|
|
93
|
+
includes,
|
|
94
|
+
excludes
|
|
95
|
+
});
|
|
96
|
+
rule.test(import_shared.TS_REGEX).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelLoaderOptions).end().use(CHAIN_ID.USE.TS).loader(require.resolve("ts-loader")).options(tsLoaderOptions);
|
|
97
|
+
});
|
|
99
98
|
}
|
|
100
99
|
};
|
|
101
100
|
};
|
package/dist/shared/plugin.js
CHANGED
|
@@ -67,8 +67,8 @@ const applyDefaultPlugins = (plugins) => {
|
|
|
67
67
|
Promise.resolve().then(() => __toESM(require("../plugins/hmr"))).then((m) => m.pluginHMR()),
|
|
68
68
|
plugins.svg(),
|
|
69
69
|
Promise.resolve().then(() => __toESM(require("../plugins/pug"))).then((m) => m.pluginPug()),
|
|
70
|
-
plugins.checkSyntax(),
|
|
71
70
|
Promise.resolve().then(() => __toESM(require("../plugins/copy"))).then((m) => m.pluginCopy()),
|
|
71
|
+
Promise.resolve().then(() => __toESM(require("../plugins/react"))).then((m) => m.pluginReactWebpack()),
|
|
72
72
|
plugins.font(),
|
|
73
73
|
plugins.image(),
|
|
74
74
|
plugins.media(),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { SharedSourceConfig, NormalizedSharedSourceConfig, ChainedConfig
|
|
1
|
+
import type { SharedSourceConfig, NormalizedSharedSourceConfig, ChainedConfig } from '@rsbuild/shared';
|
|
2
|
+
export type ModuleScopes = Array<string | RegExp>;
|
|
2
3
|
export type TransformImport = {
|
|
3
4
|
libraryName: string;
|
|
4
5
|
libraryDirectory?: string;
|
|
@@ -20,7 +21,7 @@ export interface SourceConfig extends SharedSourceConfig {
|
|
|
20
21
|
*/
|
|
21
22
|
moduleScopes?: ChainedConfig<ModuleScopes>;
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Configure babel-plugin-import or swc-plugin-import or Rspack builtins plugin import
|
|
24
25
|
*/
|
|
25
26
|
transformImport?: false | TransformImport[];
|
|
26
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ArrayOrNot, ChainedConfig, FileFilterUtil, SharedToolsConfig,
|
|
1
|
+
import type { ArrayOrNot, ChainedConfig, FileFilterUtil, SharedToolsConfig, TerserPluginOptions } from '@rsbuild/shared';
|
|
2
|
+
import type { BabelTransformOptions, BabelConfigUtils } from '@rsbuild/plugin-babel';
|
|
2
3
|
import type { ModifyWebpackChainUtils, ModifyWebpackConfigUtils } from '../hooks';
|
|
3
4
|
import type { CSSExtractOptions, HTMLPluginOptions, TSLoaderOptions, WebpackChain, WebpackConfig } from '../thirdParty';
|
|
4
5
|
import type { NormalizedCSSExtractOptions } from '../thirdParty/css';
|
|
@@ -14,16 +15,15 @@ export type ToolsHtmlPluginConfig = ChainedConfig<HTMLPluginOptions, {
|
|
|
14
15
|
}>;
|
|
15
16
|
export type ToolsWebpackConfig = ChainedConfig<WebpackConfig, ModifyWebpackConfigUtils>;
|
|
16
17
|
export type ToolsWebpackChainConfig = ArrayOrNot<(chain: WebpackChain, utils: ModifyWebpackChainUtils) => void>;
|
|
18
|
+
export type ToolsBabelConfig = ChainedConfig<BabelTransformOptions, BabelConfigUtils>;
|
|
17
19
|
export interface ToolsConfig extends SharedToolsConfig {
|
|
18
20
|
/**
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Modify the config of [less-loader](https://github.com/webpack-contrib/less-loader).
|
|
21
|
+
* Modify the options of [babel-loader](https://github.com/babel/babel-loader)
|
|
22
|
+
* When `tools.babel`'s type is Function,the default babel config will be passed in as the first parameter, the config object can be modified directly, or a value can be returned as the final result.
|
|
23
|
+
* When `tools.babel`'s type is `Object`, the config will be shallow merged with default config by `Object.assign`.
|
|
24
|
+
* Note that `Object.assign` is a shallow copy and will completely overwrite the built-in `presets` or `plugins` array, please use it with caution.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
babel?: ToolsBabelConfig;
|
|
27
27
|
/**
|
|
28
28
|
* Modify the options of [terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin).
|
|
29
29
|
*/
|
|
@@ -2,7 +2,6 @@ import type { WebpackChain } from '@rsbuild/shared';
|
|
|
2
2
|
import type webpack from 'webpack';
|
|
3
3
|
import type { Configuration as WebpackConfig } from 'webpack';
|
|
4
4
|
import type { Options as RawTSLoaderOptions } from 'ts-loader';
|
|
5
|
-
export type { BabelTransformOptions, BabelConfigUtils } from '@rsbuild/shared';
|
|
6
5
|
export type { CopyPluginOptions } from './CopyWebpackPlugin';
|
|
7
6
|
export type { Options as HTMLPluginOptions } from 'html-webpack-plugin';
|
|
8
7
|
export type { SubresourceIntegrityPluginOptions as SubresourceIntegrityOptions } from 'webpack-subresource-integrity';
|
package/package.json
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/webpack",
|
|
3
|
+
"version": "0.0.12",
|
|
3
4
|
"homepage": "https://rsbuild.dev",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/web-infra-dev/rsbuild",
|
|
7
|
-
"directory": "packages/webpack"
|
|
8
|
-
},
|
|
9
|
-
"bugs": {
|
|
10
|
-
"url": "https://github.com/web-infra-dev/rsbuild/issues"
|
|
11
|
-
},
|
|
12
|
-
"engines": {
|
|
13
|
-
"node": ">=14.0.0"
|
|
8
|
+
"directory": "packages/compat/webpack"
|
|
14
9
|
},
|
|
15
10
|
"license": "MIT",
|
|
16
|
-
"version": "0.0.9",
|
|
17
|
-
"types": "./dist/index.d.ts",
|
|
18
|
-
"main": "./dist/index.js",
|
|
19
11
|
"exports": {
|
|
20
12
|
".": {
|
|
21
13
|
"types": "./dist/index.d.ts",
|
|
@@ -30,6 +22,8 @@
|
|
|
30
22
|
"default": "./dist/plugins/babel.js"
|
|
31
23
|
}
|
|
32
24
|
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
33
27
|
"typesVersions": {
|
|
34
28
|
"*": {
|
|
35
29
|
"plugin-babel": [
|
|
@@ -45,41 +39,49 @@
|
|
|
45
39
|
"compiled",
|
|
46
40
|
"dist"
|
|
47
41
|
],
|
|
48
|
-
"publishConfig": {
|
|
49
|
-
"registry": "https://registry.npmjs.org/",
|
|
50
|
-
"access": "public",
|
|
51
|
-
"provenance": true
|
|
52
|
-
},
|
|
53
42
|
"dependencies": {
|
|
54
|
-
"@
|
|
43
|
+
"@babel/core": "^7.23.2",
|
|
44
|
+
"@babel/preset-react": "^7.22.15",
|
|
45
|
+
"@modern-js/server": "^2.39.0",
|
|
55
46
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
|
47
|
+
"babel-loader": "9.1.3",
|
|
56
48
|
"babel-plugin-import": "1.13.5",
|
|
57
|
-
"
|
|
49
|
+
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
|
|
50
|
+
"caniuse-lite": "^1.0.30001559",
|
|
58
51
|
"html-webpack-plugin": "5.5.3",
|
|
59
52
|
"lodash": "^4.17.21",
|
|
60
53
|
"mini-css-extract-plugin": "2.7.6",
|
|
61
54
|
"postcss": "8.4.31",
|
|
62
|
-
"react-refresh": "0.14.0",
|
|
55
|
+
"react-refresh": "^0.14.0",
|
|
63
56
|
"style-loader": "3.3.3",
|
|
64
57
|
"terser-webpack-plugin": "5.3.9",
|
|
65
|
-
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
66
58
|
"ts-loader": "9.4.4",
|
|
67
|
-
"webpack": "
|
|
59
|
+
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
60
|
+
"webpack": "^5.89.0",
|
|
68
61
|
"webpack-subresource-integrity": "5.1.0",
|
|
69
|
-
"@rsbuild/
|
|
70
|
-
"@rsbuild/
|
|
71
|
-
"@rsbuild/
|
|
62
|
+
"@rsbuild/babel-preset": "0.0.12",
|
|
63
|
+
"@rsbuild/core": "0.0.12",
|
|
64
|
+
"@rsbuild/plugin-babel": "0.0.12",
|
|
65
|
+
"@rsbuild/shared": "0.0.12"
|
|
72
66
|
},
|
|
73
67
|
"devDependencies": {
|
|
74
68
|
"@types/lodash": "^4.14.200",
|
|
75
69
|
"@types/node": "^16",
|
|
76
|
-
"
|
|
77
|
-
"react": "^18",
|
|
78
|
-
"
|
|
79
|
-
"@rsbuild/test-helper": "0.0.
|
|
70
|
+
"react": "^18.2.0",
|
|
71
|
+
"react-dom": "^18.2.0",
|
|
72
|
+
"typescript": "^5.2.2",
|
|
73
|
+
"@rsbuild/test-helper": "0.0.12"
|
|
74
|
+
},
|
|
75
|
+
"engines": {
|
|
76
|
+
"node": ">=14.0.0"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public",
|
|
80
|
+
"provenance": true,
|
|
81
|
+
"registry": "https://registry.npmjs.org/"
|
|
80
82
|
},
|
|
81
83
|
"scripts": {
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
+
"build": "modern build",
|
|
85
|
+
"dev": "modern build --watch"
|
|
84
86
|
}
|
|
85
87
|
}
|