@rsbuild/core 0.6.3 → 0.6.5

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.
@@ -39,7 +39,7 @@ const applyServerOptions = (command) => {
39
39
  command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
40
40
  };
41
41
  function runCli() {
42
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.6.3");
42
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.6.5");
43
43
  const devCommand = import_commander.program.command("dev");
44
44
  const buildCommand = import_commander.program.command("build");
45
45
  const previewCommand = import_commander.program.command("preview");
@@ -34,7 +34,7 @@ function prepareCli() {
34
34
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
35
35
  console.log();
36
36
  }
37
- import_rslog.logger.greet(` ${`Rsbuild v${"0.6.3"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.6.5"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,4 @@
1
- declare let createOverlay: undefined | ((err: string[]) => void);
2
- declare let clearOverlay: undefined | (() => void);
3
1
  export declare const registerOverlay: (options: {
4
2
  createOverlay: (err: string[]) => void;
5
3
  clearOverlay: () => void;
6
4
  }) => void;
7
- export {};
@@ -164,10 +164,10 @@ function linkedText(root, selector, text) {
164
164
  el.appendChild(document.createTextNode(frag));
165
165
  }
166
166
  var overlayTemplate = '\n<style>\n.root {\n position: fixed;\n z-index: 9999;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow-y: scroll;\n margin: 0;\n background: rgba(0, 0, 0, 0.66);\n cursor: pointer;\n}\n.container {\n font-family: Menlo, Consolas, monospace;\n line-height: 1.6;\n width: 800px;\n max-width: 85%;\n color: #d8d8d8;\n margin: 32px auto;\n padding: 32px 40px;\n position: relative;\n background: #181818;\n border-radius: 24px;\n box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);\n overflow: hidden;\n direction: ltr;\n text-align: left;\n box-sizing: border-box;\n cursor: default;\n}\n.title {\n margin: 0 0 20px;\n padding-bottom: 12px;\n font-size: 17px;\n font-weight: 600;\n color: #fc5e5e;\n border-bottom: 2px solid rgba(252,94,94,.66);\n}\n.content {\n margin: 0;\n font-size: 14px;\n font-family: inherit;\n overflow-x: scroll;\n scrollbar-width: none;\n color: #b8b8b8;\n}\n.content::-webkit-scrollbar {\n display: none;\n}\n.file-link {\n cursor: pointer;\n color: #27caca;\n text-decoration: underline;\n &:hover {\n opacity: 0.8;\n }\n &:active {\n opacity: 0.6;\n }\n}\n.close {\n position: absolute;\n top: 27px;\n right: 32px;\n width: 32px;\n height: 32px;\n cursor: pointer;\n}\n.close:hover {\n opacity: 0.8;\n}\n.close:active {\n opacity: 0.6;\n}\n.close:before,\n.close:after {\n position: absolute;\n left: 16px;\n top: 8px;\n content: \' \';\n height: 18px;\n width: 2px;\n border-radius: 4px;\n background-color: #b8b8b8;\n}\n.close:before {\n transform: rotate(45deg);\n}\n.close:after {\n transform: rotate(-45deg);\n}\n.footer {\n font-size: 12px;\n color: #7e6a92;\n margin-top: 20px;\n padding-top: 12px;\n border-top: 2px solid rgba(126,106,146,.6);\n}\n.footer p {\n margin: 4px 0 0;\n}\n.footer span {\n color: #a88dc3;\n}\n</style>\n\n<div class="root">\n <div class="container">\n <div class="close"></div>\n <p class="title">Compilation failed</p>\n <pre class="content"></pre>\n <footer class="footer">\n <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>\n <p>Disable overlay by setting Rsbuild\'s <span>dev.client.overlay</span> config to false.<p>\n </footer>\n </div>\n</div>\n';
167
- var _globalThis_HTMLElement = globalThis.HTMLElement, HTMLElement = _globalThis_HTMLElement === void 0 ? function HTMLElement() {
167
+ var _ref = typeof window !== "undefined" ? window : globalThis, _ref_HTMLElement = _ref.HTMLElement, HTMLElement = _ref_HTMLElement === void 0 ? function HTMLElement() {
168
168
  "use strict";
169
169
  _class_call_check(this, HTMLElement);
170
- } : _globalThis_HTMLElement, customElements = globalThis.customElements;
170
+ } : _ref_HTMLElement, customElements = _ref.customElements;
171
171
  var ErrorOverlay = /*#__PURE__*/ function(HTMLElement) {
172
172
  "use strict";
173
173
  _inherits(ErrorOverlay, HTMLElement);
package/dist/config.js CHANGED
@@ -140,7 +140,8 @@ const getDefaultOutputConfig = () => ({
140
140
  cssModules: {
141
141
  auto: true,
142
142
  exportLocalsConvention: "camelCase"
143
- }
143
+ },
144
+ emitAssets: () => true
144
145
  });
145
146
  const createDefaultConfig = () => ({
146
147
  dev: getDefaultDevConfig(),
@@ -1,5 +1,5 @@
1
1
  import { type BundlerType, type RsbuildConfig, type RsbuildContext, type NormalizedConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
2
- import type { InternalContext } from '../types';
2
+ import type { InternalContext } from './types';
3
3
  export declare function updateContextByNormalizedConfig(context: RsbuildContext, config: NormalizedConfig): void;
4
4
  export declare function createPublicContext(context: RsbuildContext): Readonly<RsbuildContext>;
5
5
  /**
@@ -25,9 +25,9 @@ __export(createContext_exports, {
25
25
  module.exports = __toCommonJS(createContext_exports);
26
26
  var import_node_path = require("node:path");
27
27
  var import_shared = require("@rsbuild/shared");
28
- var import_initHooks = require("../initHooks");
29
- var import_config = require("../config");
30
- var import_entry = require("../plugins/entry");
28
+ var import_initHooks = require("./initHooks");
29
+ var import_config = require("./config");
30
+ var import_entry = require("./plugins/entry");
31
31
  function getAbsolutePath(root, filepath) {
32
32
  return (0, import_node_path.isAbsolute)(filepath) ? filepath : (0, import_node_path.join)(root, filepath);
33
33
  }
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
44
44
  const context = {
45
45
  entry: (0, import_entry.getEntryObject)(config, "web"),
46
46
  targets: config.output?.targets || [],
47
- version: "0.6.3",
47
+ version: "0.6.5",
48
48
  rootPath,
49
49
  distPath,
50
50
  cachePath,
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ var import_config = require("./config");
38
38
  var import_shared = require("@rsbuild/shared");
39
39
  var import_mergeConfig = require("./mergeConfig");
40
40
  var import_constants = require("./constants");
41
- const version = "0.6.3";
41
+ const version = "0.6.5";
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  PLUGIN_CSS_NAME,
@@ -1,5 +1,5 @@
1
1
  import { type PluginManager, type RsbuildPluginAPI } from '@rsbuild/shared';
2
- import type { InternalContext, NormalizedConfig } from '../types';
2
+ import type { InternalContext, NormalizedConfig } from './types';
3
3
  export declare function getHTMLPathByEntry(entryName: string, config: NormalizedConfig): string;
4
4
  export declare function getPluginAPI({ context, pluginManager, }: {
5
5
  context: InternalContext;
@@ -104,7 +104,7 @@ function getPluginAPI({
104
104
  if (descriptor.resourceQuery) {
105
105
  rule.resourceQuery(descriptor.resourceQuery);
106
106
  }
107
- rule.use(id).loader((0, import_node_path.join)(__dirname, "../rspack/transformLoader")).options({ id });
107
+ rule.use(id).loader((0, import_node_path.join)(__dirname, "./rspack/transformLoader")).options({ id });
108
108
  applyTransformPlugin(chain, transformer);
109
109
  });
110
110
  };
@@ -4,17 +4,17 @@
4
4
  * Please do not use them in your Rsbuild project or plugins.
5
5
  */
6
6
  export { rspackProvider } from './provider/provider';
7
- export { createContext, createPublicContext } from './provider/createContext';
7
+ export { createContext, createPublicContext } from './createContext';
8
8
  export { initPlugins, createPluginManager } from './pluginManager';
9
9
  export { initHooks, type Hooks } from './initHooks';
10
10
  export { initRsbuildConfig } from './provider/initConfigs';
11
- export { getPluginAPI } from './provider/initPlugins';
11
+ export { getPluginAPI } from './initPlugins';
12
12
  export { applyBaseCSSRule, applyCSSModuleRule } from './provider/plugins/css';
13
13
  export type { InternalContext } from './types';
14
14
  export { setHTMLPlugin, getHTMLPlugin } from './htmlUtils';
15
15
  export { formatStats, getStatsOptions } from './provider/shared';
16
16
  export { getChainUtils } from './provider/rspackConfig';
17
17
  export { applySwcDecoratorConfig } from './provider/plugins/swc';
18
- export { getDevMiddleware } from './provider/devMiddleware';
18
+ export { getDevMiddleware } from './server/devMiddleware';
19
19
  export { createDevServer, startProdServer } from './server';
20
20
  export { plugins } from './plugins';
package/dist/internal.js CHANGED
@@ -41,17 +41,17 @@ __export(internal_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(internal_exports);
43
43
  var import_provider = require("./provider/provider");
44
- var import_createContext = require("./provider/createContext");
44
+ var import_createContext = require("./createContext");
45
45
  var import_pluginManager = require("./pluginManager");
46
46
  var import_initHooks = require("./initHooks");
47
47
  var import_initConfigs = require("./provider/initConfigs");
48
- var import_initPlugins = require("./provider/initPlugins");
48
+ var import_initPlugins = require("./initPlugins");
49
49
  var import_css = require("./provider/plugins/css");
50
50
  var import_htmlUtils = require("./htmlUtils");
51
51
  var import_shared = require("./provider/shared");
52
52
  var import_rspackConfig = require("./provider/rspackConfig");
53
53
  var import_swc = require("./provider/plugins/swc");
54
- var import_devMiddleware = require("./provider/devMiddleware");
54
+ var import_devMiddleware = require("./server/devMiddleware");
55
55
  var import_server = require("./server");
56
56
  var import_plugins = require("./plugins");
57
57
  // Annotate the CommonJS export names for ESM import in node:
@@ -28,6 +28,7 @@ const OVERRIDE_PATH = [
28
28
  "output.inlineStyles",
29
29
  "output.cssModules.auto",
30
30
  "output.targets",
31
+ "output.emitAssets",
31
32
  "server.printUrls",
32
33
  "dev.startUrl",
33
34
  "provider"
@@ -35,22 +35,25 @@ module.exports = __toCommonJS(asset_exports);
35
35
  var import_node_path = __toESM(require("node:path"));
36
36
  var import_shared = require("@rsbuild/shared");
37
37
  const chainStaticAssetRule = ({
38
+ emit,
38
39
  rule,
39
40
  maxSize,
40
41
  filename,
41
42
  assetType
42
43
  }) => {
43
- rule.oneOf(`${assetType}-asset-url`).type("asset/resource").resourceQuery(/(__inline=false|url)/).set("generator", {
44
+ const generatorOptions = {
44
45
  filename
45
- });
46
+ };
47
+ if (emit === false) {
48
+ generatorOptions.emit = false;
49
+ }
50
+ rule.oneOf(`${assetType}-asset-url`).type("asset/resource").resourceQuery(/(__inline=false|url)/).set("generator", generatorOptions);
46
51
  rule.oneOf(`${assetType}-asset-inline`).type("asset/inline").resourceQuery(/inline/);
47
52
  rule.oneOf(`${assetType}-asset`).type("asset").parser({
48
53
  dataUrlCondition: {
49
54
  maxSize
50
55
  }
51
- }).set("generator", {
52
- filename
53
- });
56
+ }).set("generator", generatorOptions);
54
57
  };
55
58
  function getRegExpForExts(exts) {
56
59
  const matcher = exts.map((ext) => ext.trim()).map((ext) => ext.startsWith(".") ? ext.slice(1) : ext).join("|");
@@ -62,9 +65,9 @@ function getRegExpForExts(exts) {
62
65
  const pluginAsset = () => ({
63
66
  name: "rsbuild:asset",
64
67
  setup(api) {
65
- api.modifyBundlerChain((chain, { isProd }) => {
68
+ api.modifyBundlerChain((chain, { isProd, target }) => {
66
69
  const config = api.getNormalizedConfig();
67
- const createAssetRule = (assetType, exts) => {
70
+ const createAssetRule = (assetType, exts, emit2) => {
68
71
  const regExp = getRegExpForExts(exts);
69
72
  const distDir = (0, import_shared.getDistPath)(config, assetType);
70
73
  const filename = (0, import_shared.getFilename)(config, assetType, isProd);
@@ -72,16 +75,22 @@ const pluginAsset = () => ({
72
75
  const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit[assetType];
73
76
  const rule = chain.module.rule(assetType).test(regExp);
74
77
  chainStaticAssetRule({
78
+ emit: emit2,
75
79
  rule,
76
80
  maxSize,
77
81
  filename: import_node_path.default.posix.join(distDir, filename),
78
82
  assetType
79
83
  });
80
84
  };
81
- createAssetRule("image", import_shared.IMAGE_EXTENSIONS);
82
- createAssetRule("svg", ["svg"]);
83
- createAssetRule("media", [...import_shared.VIDEO_EXTENSIONS, ...import_shared.AUDIO_EXTENSIONS]);
84
- createAssetRule("font", import_shared.FONT_EXTENSIONS);
85
+ const emit = config.output.emitAssets({ target });
86
+ createAssetRule("image", import_shared.IMAGE_EXTENSIONS, emit);
87
+ createAssetRule("svg", ["svg"], emit);
88
+ createAssetRule(
89
+ "media",
90
+ [...import_shared.VIDEO_EXTENSIONS, ...import_shared.AUDIO_EXTENSIONS],
91
+ emit
92
+ );
93
+ createAssetRule("font", import_shared.FONT_EXTENSIONS, emit);
85
94
  });
86
95
  }
87
96
  });
@@ -49,6 +49,7 @@ const pluginBasic = () => ({
49
49
  level: "error"
50
50
  }
51
51
  });
52
+ chain.ignoreWarnings([/Conflicting order/]);
52
53
  chain.performance.hints(false);
53
54
  chain.module.parser.merge({
54
55
  javascript: {
@@ -99,7 +99,8 @@ function pluginStartUrl() {
99
99
  const config = api.getNormalizedConfig();
100
100
  const { startUrl, beforeStartUrl } = config.dev;
101
101
  const { https } = api.context.devServer || {};
102
- const shouldOpen = Boolean(startUrl);
102
+ const isCodesandbox = process.env.CSB === "true";
103
+ const shouldOpen = Boolean(startUrl) && !isCodesandbox;
103
104
  if (!shouldOpen) {
104
105
  return;
105
106
  }
@@ -131,7 +131,7 @@ async function createDevMiddleware(options, customCompiler) {
131
131
  rspackConfigs
132
132
  });
133
133
  }
134
- const { getDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./devMiddleware")));
134
+ const { getDevMiddleware } = await Promise.resolve().then(() => __toESM(require("../server/devMiddleware")));
135
135
  return {
136
136
  devMiddleware: getDevMiddleware(compiler),
137
137
  compiler
@@ -24,7 +24,7 @@ __export(initConfigs_exports, {
24
24
  module.exports = __toCommonJS(initConfigs_exports);
25
25
  var import_shared = require("@rsbuild/shared");
26
26
  var import_mergeConfig = require("../mergeConfig");
27
- var import_createContext = require("./createContext");
27
+ var import_createContext = require("../createContext");
28
28
  var import_inspectConfig = require("./inspectConfig");
29
29
  var import_rspackConfig = require("./rspackConfig");
30
30
  var import_config = require("../config");
@@ -32,9 +32,9 @@ __export(provider_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(provider_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
- var import_createContext = require("./createContext");
35
+ var import_createContext = require("../createContext");
36
36
  var import_initConfigs = require("./initConfigs");
37
- var import_initPlugins = require("./initPlugins");
37
+ var import_initPlugins = require("../initPlugins");
38
38
  var import_plugins = require("../plugins");
39
39
  const rspackProvider = async ({
40
40
  pluginManager,
@@ -29,12 +29,12 @@ export declare const getPort: ({ host, port, strictPort, tryLimits, silent, }: {
29
29
  host: string;
30
30
  port: string | number;
31
31
  strictPort: boolean;
32
- tryLimits?: number | undefined;
33
- silent?: boolean | undefined;
32
+ tryLimits?: number;
33
+ silent?: boolean;
34
34
  }) => Promise<number>;
35
35
  export declare const getServerOptions: ({ rsbuildConfig, getPortSilently, }: {
36
36
  rsbuildConfig: RsbuildConfig;
37
- getPortSilently?: boolean | undefined;
37
+ getPortSilently?: boolean;
38
38
  }) => Promise<{
39
39
  port: number;
40
40
  host: string;
@@ -43,7 +43,7 @@ export declare const getServerOptions: ({ rsbuildConfig, getPortSilently, }: {
43
43
  }>;
44
44
  export declare const getDevOptions: ({ rsbuildConfig, getPortSilently, }: {
45
45
  rsbuildConfig: RsbuildConfig;
46
- getPortSilently?: boolean | undefined;
46
+ getPortSilently?: boolean;
47
47
  }) => Promise<{
48
48
  devConfig: DevConfig;
49
49
  serverConfig: import("@rsbuild/shared").ServerConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -53,7 +53,7 @@
53
53
  "core-js": "~3.36.0",
54
54
  "html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
55
55
  "postcss": "^8.4.38",
56
- "@rsbuild/shared": "0.6.3"
56
+ "@rsbuild/shared": "0.6.5"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "16.x",
File without changes
File without changes