@rsbuild/core 0.0.15 → 0.0.17

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.
@@ -25,32 +25,30 @@ var import_lodash = require("lodash");
25
25
  var import_shared = require("@rsbuild/shared");
26
26
  const pluginDefine = () => ({
27
27
  name: "plugin-define",
28
- async setup(api) {
29
- api.modifyBundlerChain(
30
- async (chain, { env, target, CHAIN_ID, bundler }) => {
31
- const config = api.getNormalizedConfig();
32
- const publicPath = chain.output.get("publicPath");
33
- const assetPrefix = publicPath && typeof publicPath === "string" ? publicPath : config.output.assetPrefix;
34
- const builtinVars = {
35
- "process.env.NODE_ENV": process.env.NODE_ENV,
36
- "process.env.ASSET_PREFIX": (0, import_shared.removeTailSlash)(assetPrefix)
37
- };
38
- const globalVars = (0, import_shared.mergeChainedOptions)(
39
- builtinVars,
40
- config.source.globalVars,
41
- { env, target }
42
- );
43
- const serializedVars = (0, import_lodash.mapValues)(
44
- globalVars,
45
- (value) => {
46
- var _a;
47
- return (_a = JSON.stringify(value)) != null ? _a : "undefined";
48
- }
49
- );
50
- const defineExprs = config.source.define;
51
- chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [{ ...serializedVars, ...defineExprs }]);
52
- }
53
- );
28
+ setup(api) {
29
+ api.modifyBundlerChain((chain, { env, target, CHAIN_ID, bundler }) => {
30
+ const config = api.getNormalizedConfig();
31
+ const publicPath = chain.output.get("publicPath");
32
+ const assetPrefix = publicPath && typeof publicPath === "string" ? publicPath : config.output.assetPrefix;
33
+ const builtinVars = {
34
+ "process.env.NODE_ENV": process.env.NODE_ENV,
35
+ "process.env.ASSET_PREFIX": (0, import_shared.removeTailSlash)(assetPrefix)
36
+ };
37
+ const globalVars = (0, import_shared.mergeChainedOptions)({
38
+ defaults: builtinVars,
39
+ options: config.source.globalVars,
40
+ utils: { env, target }
41
+ });
42
+ const serializedVars = (0, import_lodash.mapValues)(
43
+ globalVars,
44
+ (value) => {
45
+ var _a;
46
+ return (_a = JSON.stringify(value)) != null ? _a : "undefined";
47
+ }
48
+ );
49
+ const defineExprs = config.source.define;
50
+ chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [{ ...serializedVars, ...defineExprs }]);
51
+ });
54
52
  }
55
53
  });
56
54
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,14 @@
1
- import type { HtmlConfig, DefaultRsbuildPlugin, SharedRsbuildPluginAPI, NormalizedOutputConfig } from '@rsbuild/shared';
1
+ import type { MetaAttrs, HtmlConfig, MetaOptions, NormalizedConfig, DefaultRsbuildPlugin, SharedRsbuildPluginAPI, NormalizedOutputConfig } from '@rsbuild/shared';
2
+ export declare function getTitle(entryName: string, config: NormalizedConfig): string;
3
+ export declare function getInject(entryName: string, config: NormalizedConfig): import("@rsbuild/shared").ScriptInject;
4
+ export declare function getTemplatePath(entryName: string, config: NormalizedConfig): string;
5
+ export declare function getFavicon(entryName: string, config: {
6
+ html: HtmlConfig;
7
+ }): string;
8
+ export declare const generateMetaTags: (metaOptions?: MetaOptions) => MetaAttrs[];
2
9
  export declare function getMetaTags(entryName: string, config: {
3
10
  html: HtmlConfig;
4
11
  output: NormalizedOutputConfig;
5
- }): Promise<import("html-webpack-plugin").HtmlTagObject[]>;
12
+ }): Promise<MetaAttrs[]>;
6
13
  export declare const applyInjectTags: (api: SharedRsbuildPluginAPI) => void;
7
14
  export declare const pluginHtml: () => DefaultRsbuildPlugin;
@@ -29,7 +29,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var html_exports = {};
30
30
  __export(html_exports, {
31
31
  applyInjectTags: () => applyInjectTags,
32
+ generateMetaTags: () => generateMetaTags,
33
+ getFavicon: () => getFavicon,
34
+ getInject: () => getInject,
32
35
  getMetaTags: () => getMetaTags,
36
+ getTemplatePath: () => getTemplatePath,
37
+ getTitle: () => getTitle,
33
38
  pluginHtml: () => pluginHtml
34
39
  });
35
40
  module.exports = __toCommonJS(html_exports);
@@ -37,39 +42,87 @@ var import_path = __toESM(require("path"));
37
42
  var import_shared = require("@rsbuild/shared");
38
43
  var import_fs_extra = require("@rsbuild/shared/fs-extra");
39
44
  var import_lodash = __toESM(require("lodash"));
40
- var import_generateMetaTags = require("../utils/generateMetaTags");
41
- async function getMetaTags(entryName, config) {
42
- const { meta, metaByEntries } = config.html;
43
- const metaOptions = {};
44
- if (config.output.charset === "utf8") {
45
- metaOptions.charset = { charset: "utf-8" };
45
+ var import_HtmlBasicPlugin = require("../rspack-plugins/HtmlBasicPlugin");
46
+ function getTitle(entryName, config) {
47
+ return (0, import_shared.mergeChainedOptions)({
48
+ defaults: "",
49
+ options: config.html.title,
50
+ utils: { entryName },
51
+ useObjectParam: true
52
+ });
53
+ }
54
+ function getInject(entryName, config) {
55
+ return (0, import_shared.mergeChainedOptions)({
56
+ defaults: "head",
57
+ options: config.html.inject,
58
+ utils: { entryName },
59
+ useObjectParam: true
60
+ });
61
+ }
62
+ function getTemplatePath(entryName, config) {
63
+ const DEFAULT_TEMPLATE = import_path.default.resolve(
64
+ __dirname,
65
+ "../../static/template.html"
66
+ );
67
+ return (0, import_shared.mergeChainedOptions)({
68
+ defaults: DEFAULT_TEMPLATE,
69
+ options: config.html.template,
70
+ utils: { entryName },
71
+ useObjectParam: true
72
+ });
73
+ }
74
+ function getFavicon(entryName, config) {
75
+ return (0, import_shared.mergeChainedOptions)({
76
+ defaults: "",
77
+ options: config.html.favicon,
78
+ utils: { entryName },
79
+ useObjectParam: true
80
+ });
81
+ }
82
+ const generateMetaTags = (metaOptions) => {
83
+ if (!metaOptions) {
84
+ return [];
46
85
  }
47
- Object.assign(metaOptions, meta, metaByEntries == null ? void 0 : metaByEntries[entryName]);
48
- return (0, import_generateMetaTags.generateMetaTags)(metaOptions);
86
+ return Object.keys(metaOptions).map((metaName) => {
87
+ const metaTagContent = metaOptions[metaName];
88
+ return typeof metaTagContent === "string" ? {
89
+ name: metaName,
90
+ content: metaTagContent
91
+ } : metaTagContent;
92
+ }).filter(Boolean);
93
+ };
94
+ async function getMetaTags(entryName, config) {
95
+ const merged = (0, import_shared.mergeChainedOptions)({
96
+ defaults: {},
97
+ options: config.html.meta,
98
+ utils: { entryName },
99
+ useObjectParam: true
100
+ });
101
+ return generateMetaTags(merged);
49
102
  }
50
- async function getTemplateParameters(entryName, config, assetPrefix) {
51
- const { mountId, templateParameters, templateParametersByEntries } = config.html;
52
- const templateParams = (templateParametersByEntries == null ? void 0 : templateParametersByEntries[entryName]) || templateParameters;
53
- const baseParameters = {
54
- mountId,
55
- entryName,
56
- assetPrefix
57
- };
103
+ function getTemplateParameters(entryName, config, assetPrefix) {
58
104
  return (compilation, assets, assetTags, pluginOptions) => {
105
+ const { mountId, templateParameters } = config.html;
59
106
  const defaultOptions = {
107
+ mountId,
108
+ entryName,
109
+ assetPrefix,
60
110
  compilation,
61
111
  webpackConfig: compilation.options,
62
112
  htmlWebpackPlugin: {
63
113
  tags: assetTags,
64
114
  files: assets,
65
115
  options: pluginOptions
66
- },
67
- ...baseParameters
116
+ }
68
117
  };
69
- return (0, import_shared.mergeChainedOptions)(defaultOptions, templateParams);
118
+ return (0, import_shared.mergeChainedOptions)({
119
+ defaults: defaultOptions,
120
+ options: templateParameters,
121
+ utils: { entryName }
122
+ });
70
123
  };
71
124
  }
72
- async function getChunks(entryName, entryValue) {
125
+ function getChunks(entryName, entryValue) {
73
126
  const dependOn = [];
74
127
  if ((0, import_shared.isPlainObject)(entryValue)) {
75
128
  dependOn.push(...entryValue.dependOn);
@@ -124,42 +177,19 @@ const pluginHtml = () => ({
124
177
  const entries = chain.entryPoints.entries() || {};
125
178
  const entryNames = Object.keys(entries);
126
179
  const htmlPaths = api.getHTMLPaths();
127
- const faviconUrls = [];
128
- const metaPluginOptions = {
129
- meta: [],
130
- HtmlPlugin
131
- };
132
- const titlePluginOptions = {
133
- titles: [],
134
- HtmlPlugin
135
- };
180
+ const htmlInfoMap = {};
136
181
  await Promise.all(
137
182
  entryNames.map(async (entryName, index) => {
138
183
  const entryValue = entries[entryName].values();
139
- const chunks = await getChunks(entryName, entryValue);
140
- const inject = (0, import_shared.getInject)(entryName, config);
141
- const favicon = (0, import_shared.getFavicon)(entryName, config);
184
+ const chunks = getChunks(entryName, entryValue);
185
+ const inject = getInject(entryName, config);
142
186
  const filename = htmlPaths[entryName];
143
- const template = (0, import_shared.getTemplatePath)(entryName, config);
144
- const metaTags = await getMetaTags(entryName, config);
145
- const title = await (0, import_shared.getTitle)(entryName, config);
146
- const templateParameters = await getTemplateParameters(
187
+ const template = getTemplatePath(entryName, config);
188
+ const templateParameters = getTemplateParameters(
147
189
  entryName,
148
190
  config,
149
191
  assetPrefix
150
192
  );
151
- if (metaTags.length) {
152
- metaPluginOptions.meta.push({
153
- tags: metaTags,
154
- filename
155
- });
156
- }
157
- if (title) {
158
- titlePluginOptions.titles.push({
159
- title,
160
- filename
161
- });
162
- }
163
193
  const pluginOptions = {
164
194
  chunks,
165
195
  inject,
@@ -169,24 +199,32 @@ const pluginHtml = () => ({
169
199
  templateParameters,
170
200
  scriptLoading: config.html.scriptLoading
171
201
  };
202
+ const htmlInfo = {};
203
+ htmlInfoMap[filename] = htmlInfo;
204
+ const title = getTitle(entryName, config);
205
+ if (title) {
206
+ htmlInfo.title = title;
207
+ }
208
+ const metaTags = await getMetaTags(entryName, config);
209
+ if (metaTags.length) {
210
+ htmlInfo.meta = metaTags;
211
+ }
212
+ const favicon = getFavicon(entryName, config);
172
213
  if (favicon) {
173
214
  if ((0, import_shared.isURL)(favicon)) {
174
- faviconUrls.push({
175
- filename,
176
- url: favicon
177
- });
215
+ htmlInfo.favicon = favicon;
178
216
  } else {
179
217
  pluginOptions.favicon = favicon;
180
218
  }
181
219
  }
182
- const finalOptions = (0, import_shared.mergeChainedOptions)(
183
- pluginOptions,
184
- config.tools.htmlPlugin,
185
- {
220
+ const finalOptions = (0, import_shared.mergeChainedOptions)({
221
+ defaults: pluginOptions,
222
+ options: config.tools.htmlPlugin,
223
+ utils: {
186
224
  entryName,
187
225
  entryValue
188
226
  }
189
- );
227
+ });
190
228
  routesInfo.push({
191
229
  urlPath: index === 0 ? "/" : `/${entryName}`,
192
230
  entryName,
@@ -196,12 +234,7 @@ const pluginHtml = () => ({
196
234
  chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).use(HtmlPlugin, [finalOptions]);
197
235
  })
198
236
  );
199
- if (metaPluginOptions.meta.length) {
200
- chain.plugin(CHAIN_ID.PLUGIN.HTML_META).use(import_shared.HtmlMetaPlugin, [metaPluginOptions]);
201
- }
202
- if (titlePluginOptions.titles.length) {
203
- chain.plugin(CHAIN_ID.PLUGIN.HTML_TITLE).use(import_shared.HtmlTitlePlugin, [titlePluginOptions]);
204
- }
237
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_BASIC).use(import_HtmlBasicPlugin.HtmlBasicPlugin, [{ HtmlPlugin, info: htmlInfoMap }]);
205
238
  if (config.security) {
206
239
  const { nonce } = config.security;
207
240
  if (nonce) {
@@ -219,10 +252,6 @@ const pluginHtml = () => ({
219
252
  ]);
220
253
  chain.output.crossOriginLoading(formattedCrossorigin);
221
254
  }
222
- if (faviconUrls.length) {
223
- const { HtmlFaviconUrlPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
224
- chain.plugin(CHAIN_ID.PLUGIN.FAVICON_URL).use(HtmlFaviconUrlPlugin, [{ faviconUrls, HtmlPlugin }]);
225
- }
226
255
  if (appIcon) {
227
256
  const { HtmlAppIconPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
228
257
  const distDir = (0, import_shared.getDistPath)(config.output, "image");
@@ -249,6 +278,11 @@ const pluginHtml = () => ({
249
278
  // Annotate the CommonJS export names for ESM import in node:
250
279
  0 && (module.exports = {
251
280
  applyInjectTags,
281
+ generateMetaTags,
282
+ getFavicon,
283
+ getInject,
252
284
  getMetaTags,
285
+ getTemplatePath,
286
+ getTitle,
253
287
  pluginHtml
254
288
  });
@@ -93,7 +93,7 @@ const openedURLs = [];
93
93
  function pluginStartUrl() {
94
94
  return {
95
95
  name: "plugin-start-url",
96
- async setup(api) {
96
+ setup(api) {
97
97
  let port;
98
98
  api.onAfterStartDevServer(async (params) => {
99
99
  ({ port } = params);
@@ -0,0 +1,19 @@
1
+ import type HtmlWebpackPlugin from 'html-webpack-plugin';
2
+ import type { Compiler } from '@rspack/core';
3
+ import type { MetaAttrs } from '@rsbuild/shared';
4
+ export type HtmlInfo = {
5
+ meta?: MetaAttrs[];
6
+ title?: string;
7
+ favicon?: string;
8
+ };
9
+ export type HtmlBasicPluginOptions = {
10
+ info: Record<string, HtmlInfo>;
11
+ HtmlPlugin: typeof HtmlWebpackPlugin;
12
+ };
13
+ export declare class HtmlBasicPlugin {
14
+ readonly name: string;
15
+ readonly options: HtmlBasicPluginOptions;
16
+ readonly HtmlPlugin: typeof HtmlWebpackPlugin;
17
+ constructor(options: HtmlBasicPluginOptions);
18
+ apply(compiler: Compiler): void;
19
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var HtmlBasicPlugin_exports = {};
20
+ __export(HtmlBasicPlugin_exports, {
21
+ HtmlBasicPlugin: () => HtmlBasicPlugin
22
+ });
23
+ module.exports = __toCommonJS(HtmlBasicPlugin_exports);
24
+ class HtmlBasicPlugin {
25
+ constructor(options) {
26
+ this.name = "HtmlBasicPlugin";
27
+ this.options = options;
28
+ this.HtmlPlugin = options.HtmlPlugin;
29
+ }
30
+ apply(compiler) {
31
+ const addTitleTag = (headTags, outputName) => {
32
+ const { title } = this.options.info[outputName];
33
+ if (title) {
34
+ headTags.unshift({
35
+ tagName: "title",
36
+ innerHTML: title,
37
+ attributes: {},
38
+ voidTag: false,
39
+ meta: {}
40
+ });
41
+ }
42
+ };
43
+ const addMetaTag = (headTags, outputName) => {
44
+ const { meta } = this.options.info[outputName];
45
+ if (meta) {
46
+ headTags.unshift(
47
+ ...meta.map((attr) => ({
48
+ tagName: "meta",
49
+ attributes: attr,
50
+ meta: {},
51
+ voidTag: true
52
+ }))
53
+ );
54
+ }
55
+ };
56
+ const addFavicon = (headTags, outputName) => {
57
+ const { favicon } = this.options.info[outputName];
58
+ if (favicon) {
59
+ headTags.unshift({
60
+ tagName: "link",
61
+ voidTag: true,
62
+ attributes: {
63
+ rel: "icon",
64
+ href: favicon
65
+ },
66
+ meta: {}
67
+ });
68
+ }
69
+ };
70
+ compiler.hooks.compilation.tap(this.name, (compilation) => {
71
+ this.HtmlPlugin.getHooks(compilation).alterAssetTagGroups.tap(
72
+ this.name,
73
+ (data) => {
74
+ const { headTags, outputName } = data;
75
+ addTitleTag(headTags, outputName);
76
+ addMetaTag(headTags, outputName);
77
+ addFavicon(headTags, outputName);
78
+ return data;
79
+ }
80
+ );
81
+ });
82
+ }
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ HtmlBasicPlugin
87
+ });
@@ -41,12 +41,12 @@ async function modifyRspackConfig(context, rspackConfig, utils) {
41
41
  utils
42
42
  );
43
43
  if ((_a = context.config.tools) == null ? void 0 : _a.rspack) {
44
- modifiedConfig = (0, import_shared.mergeChainedOptions)(
45
- modifiedConfig,
46
- context.config.tools.rspack,
44
+ modifiedConfig = (0, import_shared.mergeChainedOptions)({
45
+ defaults: modifiedConfig,
46
+ options: context.config.tools.rspack,
47
47
  utils,
48
- utils.mergeConfig
49
- );
48
+ mergeFn: utils.mergeConfig
49
+ });
50
50
  }
51
51
  (0, import_shared.debug)("modify Rspack config done");
52
52
  return modifiedConfig;
@@ -56,7 +56,7 @@ async function applyBaseCSSRule({
56
56
  const enableCssMinify = !enableExtractCSS && isProd;
57
57
  if (!enableNativeCss(config)) {
58
58
  const localIdentName = (0, import_shared.getCssModuleLocalIdentName)(config, isProd);
59
- const cssLoaderOptions = await (0, import_shared.getCssLoaderOptions)({
59
+ const cssLoaderOptions = (0, import_shared.getCssLoaderOptions)({
60
60
  config,
61
61
  enableSourceMap,
62
62
  importLoaders,
@@ -65,14 +65,14 @@ async function applyBaseCSSRule({
65
65
  localIdentName
66
66
  });
67
67
  if (!isServer && !isWebWorker) {
68
- const styleLoaderOptions = (0, import_shared.mergeChainedOptions)(
69
- {
68
+ const styleLoaderOptions = (0, import_shared.mergeChainedOptions)({
69
+ defaults: {
70
70
  // todo: hmr does not work while esModule is true
71
71
  // @ts-expect-error
72
72
  esModule: false
73
73
  },
74
- config.tools.styleLoader
75
- );
74
+ options: config.tools.styleLoader
75
+ });
76
76
  rule.use(CHAIN_ID.USE.STYLE).loader(require.resolve("style-loader")).options(styleLoaderOptions).end();
77
77
  if (enableCSSModuleTS && cssLoaderOptions.modules) {
78
78
  rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(
@@ -110,7 +110,7 @@ async function applyBaseCSSRule({
110
110
  rule.type("css");
111
111
  }
112
112
  if (!isServer && !isWebWorker) {
113
- const postcssLoaderOptions = await (0, import_shared.getPostcssConfig)({
113
+ const postcssLoaderOptions = (0, import_shared.getPostcssConfig)({
114
114
  enableSourceMap,
115
115
  browserslist,
116
116
  config,
@@ -47,7 +47,7 @@ function pluginLess() {
47
47
  context: api.context,
48
48
  importLoaders: 2
49
49
  });
50
- const { excludes, options } = await (0, import_shared.getLessLoaderOptions)(
50
+ const { excludes, options } = (0, import_shared.getLessLoaderOptions)(
51
51
  config.tools.less,
52
52
  (0, import_shared.isUseCssSourceMap)(config)
53
53
  );
@@ -27,8 +27,7 @@ const pluginResolve = () => ({
27
27
  setup(api) {
28
28
  (0, import_shared.applyResolvePlugin)(api);
29
29
  api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
30
- const config = api.getNormalizedConfig();
31
- if (chain.module.rules.get(CHAIN_ID.RULE.JS_DATA_URI) && config.source.compileJsDataURI) {
30
+ if (chain.module.rules.get(CHAIN_ID.RULE.JS_DATA_URI)) {
32
31
  chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).resolve.set("fullySpecified", false);
33
32
  }
34
33
  });
@@ -35,14 +35,14 @@ var import_shared = require("@rsbuild/shared");
35
35
  function pluginSass() {
36
36
  return {
37
37
  name: "plugin-sass",
38
- async setup(api) {
38
+ setup(api) {
39
39
  api.onAfterCreateCompiler(({ compiler }) => {
40
40
  (0, import_shared.patchCompilerGlobalLocation)(compiler);
41
41
  });
42
42
  api.modifyBundlerChain(async (chain, utils) => {
43
43
  const config = api.getNormalizedConfig();
44
44
  const { applyBaseCSSRule } = await Promise.resolve().then(() => __toESM(require("./css")));
45
- const { excludes, options } = await (0, import_shared.getSassLoaderOptions)(
45
+ const { excludes, options } = (0, import_shared.getSassLoaderOptions)(
46
46
  config.tools.sass,
47
47
  // source-maps required for loaders preceding resolve-url-loader
48
48
  true
@@ -98,11 +98,9 @@ const pluginSwc = () => ({
98
98
  }
99
99
  }
100
100
  rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(swcConfig);
101
- if (config.source.compileJsDataURI) {
102
- chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
103
- or: ["text/javascript", "application/javascript"]
104
- }).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_lodash.cloneDeep)(swcConfig));
105
- }
101
+ chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
102
+ or: ["text/javascript", "application/javascript"]
103
+ }).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_lodash.cloneDeep)(swcConfig));
106
104
  }
107
105
  );
108
106
  api.modifyRspackConfig(async (config) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Unleash the power of Rspack with the out-of-the-box build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -62,7 +62,7 @@
62
62
  ],
63
63
  "dependencies": {
64
64
  "@modern-js/server": "0.0.0-next-20231103131234",
65
- "@rspack/core": "0.3.10",
65
+ "@rspack/core": "0.3.11",
66
66
  "commander": "^10.0.1",
67
67
  "core-js": "~3.32.2",
68
68
  "filesize": "^8.0.7",
@@ -74,7 +74,7 @@
74
74
  "pkg-up": "^3.1.0",
75
75
  "postcss": "8.4.31",
76
76
  "semver": "^7.5.4",
77
- "@rsbuild/shared": "0.0.15"
77
+ "@rsbuild/shared": "0.0.17"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/lodash": "^4.14.200",
@@ -0,0 +1,7 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <div id="<%= mountId %>"></div>
6
+ </body>
7
+ </html>
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright JS Foundation and other contributors.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file at
6
- * https://github.com/jantimon/html-webpack-plugin/blob/main/LICENSE
7
- *
8
- * Modified from https://github.com/jantimon/html-webpack-plugin/blob/2f5de7ab9e8bca60e9e200f2e4b4cfab90db28d4/index.js#L800
9
- */
10
- import type { MetaOptions } from '@rsbuild/shared';
11
- import type { HtmlTagObject } from 'html-webpack-plugin';
12
- export declare const generateMetaTags: (metaOptions?: MetaOptions) => HtmlTagObject[];
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var generateMetaTags_exports = {};
20
- __export(generateMetaTags_exports, {
21
- generateMetaTags: () => generateMetaTags
22
- });
23
- module.exports = __toCommonJS(generateMetaTags_exports);
24
- const generateMetaTags = (metaOptions) => {
25
- if (!metaOptions) {
26
- return [];
27
- }
28
- const metaTagAttributeObjects = Object.keys(metaOptions).map((metaName) => {
29
- const metaTagContent = metaOptions[metaName];
30
- return typeof metaTagContent === "string" ? {
31
- name: metaName,
32
- content: metaTagContent
33
- } : metaTagContent;
34
- }).filter((attribute) => attribute !== false);
35
- return metaTagAttributeObjects.map((metaTagAttributes) => {
36
- if (metaTagAttributes === false) {
37
- throw new Error("Invalid meta tag");
38
- }
39
- return {
40
- tagName: "meta",
41
- voidTag: true,
42
- attributes: metaTagAttributes,
43
- meta: {}
44
- };
45
- });
46
- };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- generateMetaTags
50
- });