@esmx/rspack 3.0.0-rc.59 → 3.0.0-rc.60

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.
@@ -76,7 +76,7 @@ export interface RspackAppChainContext {
76
76
  * rspack-chain configuration object.
77
77
  * You can use the chain API in chain hooks to modify the configuration.
78
78
  */
79
- chain: import('rspack-chain');
79
+ chain: import('rspack-chain').default;
80
80
  /**
81
81
  * Options object passed when creating the application.
82
82
  */
@@ -88,7 +88,7 @@ function rewriteBuild(esmx, options = {}) {
88
88
  esmx.resolvePath("dist/index.mjs"),
89
89
  `
90
90
  async function start() {
91
- const options = await import('./node/exports/src/entry.node.mjs').then(
91
+ const options = await import('./node/src/entry.node.mjs').then(
92
92
  (mod) => mod.default
93
93
  );
94
94
  const { Esmx } = await import('@esmx/core');
@@ -1,4 +1,6 @@
1
- import { moduleLinkPlugin } from "@esmx/rspack-module-link-plugin";
1
+ import {
2
+ moduleLinkPlugin
3
+ } from "@esmx/rspack-module-link-plugin";
2
4
  import { rspack } from "@rspack/core";
3
5
  import RspackChain from "rspack-chain";
4
6
  import nodeExternals from "webpack-node-externals";
@@ -13,7 +15,7 @@ export function createChainConfig(esmx, buildTarget, options) {
13
15
  config.target(isClient ? "web" : "node24");
14
16
  config.cache(!esmx.isProd);
15
17
  config.output.clean(esmx.isProd).filename(
16
- !isNode && esmx.isProd ? "exports/[name].[contenthash:8].final.mjs" : "exports/[name].mjs"
18
+ !isNode && esmx.isProd ? "[name].[contenthash:8].final.mjs" : "[name].mjs"
17
19
  ).chunkFilename(
18
20
  esmx.isProd ? "chunks/[name].[contenthash:8].final.mjs" : "chunks/[name].mjs"
19
21
  ).publicPath(
@@ -21,23 +23,13 @@ export function createChainConfig(esmx, buildTarget, options) {
21
23
  );
22
24
  config.output.set(
23
25
  "cssFilename",
24
- esmx.isProd ? "exports/[name].[contenthash:8].final.css" : "exports/[name].css"
26
+ esmx.isProd ? "[name].[contenthash:8].final.css" : "[name].css"
25
27
  );
26
28
  config.output.set(
27
29
  "cssChunkFilename",
28
30
  esmx.isProd ? "chunks/[name].[contenthash:8].final.css" : "chunks/[name].css"
29
31
  );
30
- switch (buildTarget) {
31
- case "client":
32
- config.output.path(esmx.resolvePath("dist/client"));
33
- break;
34
- case "server":
35
- config.output.path(esmx.resolvePath("dist/server"));
36
- break;
37
- case "node":
38
- config.output.path(esmx.resolvePath("dist/node"));
39
- break;
40
- }
32
+ config.output.path(esmx.resolvePath("dist", buildTarget));
41
33
  config.plugin("progress").use(rspack.ProgressPlugin, [
42
34
  {
43
35
  prefix: buildTarget
@@ -72,6 +64,9 @@ export function createChainConfig(esmx, buildTarget, options) {
72
64
  })
73
65
  ]);
74
66
  }
67
+ config.experiments({
68
+ nativeWatcher: true
69
+ });
75
70
  return config;
76
71
  }
77
72
  function createModuleLinkConfig(esmx, buildTarget) {
@@ -83,21 +78,12 @@ function createModuleLinkConfig(esmx, buildTarget) {
83
78
  name: esmx.name,
84
79
  exports: {
85
80
  "src/entry.node": {
86
- rewrite: false,
81
+ pkg: false,
87
82
  file: "./src/entry.node"
88
83
  }
89
84
  }
90
85
  };
91
86
  }
92
- const exports = {};
93
- for (const [name, item] of Object.entries(esmx.moduleConfig.exports)) {
94
- if (item.entryPoints[buildTarget]) {
95
- exports[name] = {
96
- rewrite: item.rewrite,
97
- file: item.entryPoints[buildTarget]
98
- };
99
- }
100
- }
101
87
  const preEntries = [];
102
88
  if (isClient && !esmx.isProd) {
103
89
  preEntries.push(
@@ -105,11 +91,10 @@ function createModuleLinkConfig(esmx, buildTarget) {
105
91
  );
106
92
  }
107
93
  return {
94
+ ...esmx.moduleConfig.environments[buildTarget],
108
95
  name: esmx.name,
109
96
  injectChunkName: isServer,
110
- imports: esmx.moduleConfig.imports,
111
97
  deps: Object.keys(esmx.moduleConfig.links),
112
- exports,
113
98
  preEntries
114
99
  };
115
100
  }
@@ -4,29 +4,29 @@ describe("generateExports", () => {
4
4
  it("should generate exports with both client and server files", () => {
5
5
  const clientExports = {
6
6
  "src/entry.client": {
7
- file: "exports/src/entry.client.95f6085b.final.mjs",
7
+ file: "src/entry.client.95f6085b.final.mjs",
8
8
  name: "src/entry.client",
9
- rewrite: true,
9
+ pkg: true,
10
10
  identifier: "ssr-vue2-remote/src/entry.client"
11
11
  },
12
12
  "src/components/index": {
13
- file: "exports/src/components/index.a73d6772.final.mjs",
13
+ file: "src/components/index.a73d6772.final.mjs",
14
14
  name: "src/components/index",
15
- rewrite: true,
15
+ pkg: true,
16
16
  identifier: "ssr-vue2-remote/src/components/index"
17
17
  }
18
18
  };
19
19
  const serverExports = {
20
20
  "src/entry.server": {
21
- file: "exports/src/entry.server.b85ed2ff.final.mjs",
21
+ file: "src/entry.server.b85ed2ff.final.mjs",
22
22
  name: "src/entry.server",
23
- rewrite: true,
23
+ pkg: true,
24
24
  identifier: "ssr-vue2-remote/src/entry.server"
25
25
  },
26
26
  "src/components/index": {
27
- file: "exports/src/components/index.12b57db5.final.mjs",
27
+ file: "src/components/index.12b57db5.final.mjs",
28
28
  name: "src/components/index",
29
- rewrite: true,
29
+ pkg: true,
30
30
  identifier: "ssr-vue2-remote/src/components/index"
31
31
  }
32
32
  };
@@ -35,11 +35,11 @@ describe("generateExports", () => {
35
35
  server: serverExports
36
36
  });
37
37
  expect(result).toEqual({
38
- "./src/entry.client": "./client/exports/src/entry.client.95f6085b.final.mjs",
39
- "./src/entry.server": "./server/exports/src/entry.server.b85ed2ff.final.mjs",
38
+ "./src/entry.client": "./client/src/entry.client.95f6085b.final.mjs",
39
+ "./src/entry.server": "./server/src/entry.server.b85ed2ff.final.mjs",
40
40
  "./src/components/index": {
41
- default: "./server/exports/src/components/index.12b57db5.final.mjs",
42
- browser: "./client/exports/src/components/index.a73d6772.final.mjs"
41
+ default: "./server/src/components/index.12b57db5.final.mjs",
42
+ browser: "./client/src/components/index.a73d6772.final.mjs"
43
43
  }
44
44
  });
45
45
  });
@@ -48,7 +48,7 @@ describe("generateExports", () => {
48
48
  index: {
49
49
  file: "index.js",
50
50
  name: "index",
51
- rewrite: true,
51
+ pkg: true,
52
52
  identifier: "index"
53
53
  }
54
54
  };
@@ -56,7 +56,7 @@ describe("generateExports", () => {
56
56
  index: {
57
57
  file: "index.js",
58
58
  name: "index",
59
- rewrite: true,
59
+ pkg: true,
60
60
  identifier: "index"
61
61
  }
62
62
  };
@@ -90,7 +90,7 @@ describe("generateExports", () => {
90
90
  utils: {
91
91
  file: "utils.js",
92
92
  name: "utils",
93
- rewrite: true,
93
+ pkg: true,
94
94
  identifier: "utils"
95
95
  }
96
96
  };
@@ -109,7 +109,7 @@ describe("generateExports", () => {
109
109
  api: {
110
110
  file: "api.js",
111
111
  name: "api",
112
- rewrite: true,
112
+ pkg: true,
113
113
  identifier: "api"
114
114
  }
115
115
  };
@@ -126,7 +126,7 @@ describe("generateExports", () => {
126
126
  index: {
127
127
  file: "index.js",
128
128
  name: "index",
129
- rewrite: true,
129
+ pkg: true,
130
130
  identifier: "index"
131
131
  }
132
132
  };
@@ -134,7 +134,7 @@ describe("generateExports", () => {
134
134
  index: {
135
135
  file: "index.js",
136
136
  name: "index",
137
- rewrite: true,
137
+ pkg: true,
138
138
  identifier: "index"
139
139
  }
140
140
  };
@@ -159,7 +159,7 @@ export interface RspackHtmlAppOptions extends RspackAppOptions {
159
159
  * // Per-build-target configuration
160
160
  * target: {
161
161
  * client: 'modern',
162
- * server: ['node>=18']
162
+ * server: ['node>=24']
163
163
  * }
164
164
  * ```
165
165
  */
@@ -57,11 +57,12 @@ function configureWorkerRule(chain, esmx, options) {
57
57
  });
58
58
  }
59
59
  function configureTypeScriptRule(chain, buildTarget, options) {
60
+ const targets = getTargetSetting(options?.target, buildTarget);
60
61
  chain.module.rule("typescript").test(/\.(ts|mts)$/i).use("swc-loader").loader(
61
62
  options.loaders?.builtinSwcLoader ?? RSPACK_LOADER.builtinSwcLoader
62
63
  ).options({
63
64
  env: {
64
- targets: getTargetSetting(options?.target, buildTarget),
65
+ targets,
65
66
  ...options?.swcLoader?.env
66
67
  },
67
68
  jsc: {
@@ -115,7 +116,7 @@ function configureCssRules(chain, esmx, options) {
115
116
  configureCssInJS(chain, esmx, options);
116
117
  return;
117
118
  }
118
- configureCssExtract(chain, esmx, options);
119
+ configureCssExtract(chain, options);
119
120
  }
120
121
  function configureCssInJS(chain, esmx, options) {
121
122
  chain.module.rule("css").test(/\.css$/).use("style-loader").loader(options.loaders?.styleLoader ?? RSPACK_LOADER.styleLoader).options(options.styleLoader ?? {}).end().use("css-loader").loader(options.loaders?.cssLoader ?? RSPACK_LOADER.cssLoader).options(options.cssLoader ?? {}).end().use("lightning-css-loader").loader(
@@ -137,7 +138,7 @@ function configureCssInJS(chain, esmx, options) {
137
138
  }
138
139
  lessRule.type("javascript/auto");
139
140
  }
140
- function configureCssExtract(chain, esmx, options) {
141
+ function configureCssExtract(chain, options) {
141
142
  chain.set("experiments", {
142
143
  ...chain.get("experiments") ?? {},
143
144
  css: true
package/package.json CHANGED
@@ -63,10 +63,10 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "@esmx/import": "3.0.0-rc.59",
67
- "@esmx/rspack-module-link-plugin": "3.0.0-rc.59",
66
+ "@esmx/import": "3.0.0-rc.60",
67
+ "@esmx/rspack-module-link-plugin": "3.0.0-rc.60",
68
68
  "@npmcli/arborist": "^9.0.1",
69
- "@rspack/core": "1.5.2",
69
+ "@rspack/core": "1.5.4",
70
70
  "css-loader": "^7.1.2",
71
71
  "less-loader": "^12.2.0",
72
72
  "node-polyfill-webpack-plugin": "^4.1.0",
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "@biomejs/biome": "1.9.4",
83
- "@esmx/core": "3.0.0-rc.59",
83
+ "@esmx/core": "3.0.0-rc.60",
84
84
  "@types/node": "^24.0.0",
85
85
  "@types/npmcli__arborist": "^6.3.1",
86
86
  "@types/pacote": "^11.1.8",
@@ -91,7 +91,7 @@
91
91
  "unbuild": "3.6.0",
92
92
  "vitest": "3.2.4"
93
93
  },
94
- "version": "3.0.0-rc.59",
94
+ "version": "3.0.0-rc.60",
95
95
  "type": "module",
96
96
  "private": false,
97
97
  "exports": {
@@ -110,5 +110,5 @@
110
110
  "template",
111
111
  "public"
112
112
  ],
113
- "gitHead": "d221aba2a43064b5666e714f42904ae80b2b57ad"
113
+ "gitHead": "615e91c617e0a58796c591643c6a2e1d2a1f0a76"
114
114
  }
package/src/rspack/app.ts CHANGED
@@ -98,7 +98,7 @@ export interface RspackAppChainContext {
98
98
  * rspack-chain configuration object.
99
99
  * You can use the chain API in chain hooks to modify the configuration.
100
100
  */
101
- chain: import('rspack-chain');
101
+ chain: import('rspack-chain').default;
102
102
 
103
103
  /**
104
104
  * Options object passed when creating the application.
@@ -302,7 +302,7 @@ function rewriteBuild(esmx: Esmx, options: RspackAppOptions = {}) {
302
302
  esmx.resolvePath('dist/index.mjs'),
303
303
  `
304
304
  async function start() {
305
- const options = await import('./node/exports/src/entry.node.mjs').then(
305
+ const options = await import('./node/src/entry.node.mjs').then(
306
306
  (mod) => mod.default
307
307
  );
308
308
  const { Esmx } = await import('@esmx/core');
@@ -1,5 +1,8 @@
1
1
  import type { Esmx } from '@esmx/core';
2
- import { moduleLinkPlugin } from '@esmx/rspack-module-link-plugin';
2
+ import {
3
+ type ModuleLinkPluginOptions,
4
+ moduleLinkPlugin
5
+ } from '@esmx/rspack-module-link-plugin';
3
6
  import { rspack } from '@rspack/core';
4
7
  import type { RspackOptions } from '@rspack/core';
5
8
  import RspackChain from 'rspack-chain';
@@ -28,8 +31,8 @@ export function createChainConfig(
28
31
  .clean(esmx.isProd)
29
32
  .filename(
30
33
  !isNode && esmx.isProd
31
- ? 'exports/[name].[contenthash:8].final.mjs'
32
- : 'exports/[name].mjs'
34
+ ? '[name].[contenthash:8].final.mjs'
35
+ : '[name].mjs'
33
36
  )
34
37
  .chunkFilename(
35
38
  esmx.isProd
@@ -42,9 +45,7 @@ export function createChainConfig(
42
45
 
43
46
  config.output.set(
44
47
  'cssFilename',
45
- esmx.isProd
46
- ? 'exports/[name].[contenthash:8].final.css'
47
- : 'exports/[name].css'
48
+ esmx.isProd ? '[name].[contenthash:8].final.css' : '[name].css'
48
49
  );
49
50
  config.output.set(
50
51
  'cssChunkFilename',
@@ -52,18 +53,7 @@ export function createChainConfig(
52
53
  ? 'chunks/[name].[contenthash:8].final.css'
53
54
  : 'chunks/[name].css'
54
55
  );
55
-
56
- switch (buildTarget) {
57
- case 'client':
58
- config.output.path(esmx.resolvePath('dist/client'));
59
- break;
60
- case 'server':
61
- config.output.path(esmx.resolvePath('dist/server'));
62
- break;
63
- case 'node':
64
- config.output.path(esmx.resolvePath('dist/node'));
65
- break;
66
- }
56
+ config.output.path(esmx.resolvePath('dist', buildTarget));
67
57
 
68
58
  config.plugin('progress').use(rspack.ProgressPlugin, [
69
59
  {
@@ -112,11 +102,17 @@ export function createChainConfig(
112
102
  })
113
103
  ]);
114
104
  }
105
+ config.experiments({
106
+ nativeWatcher: true
107
+ });
115
108
 
116
109
  return config;
117
110
  }
118
111
 
119
- function createModuleLinkConfig(esmx: Esmx, buildTarget: BuildTarget) {
112
+ function createModuleLinkConfig(
113
+ esmx: Esmx,
114
+ buildTarget: BuildTarget
115
+ ): ModuleLinkPluginOptions {
120
116
  const isClient = buildTarget === 'client';
121
117
  const isServer = buildTarget === 'server';
122
118
  const isNode = buildTarget === 'node';
@@ -126,23 +122,13 @@ function createModuleLinkConfig(esmx: Esmx, buildTarget: BuildTarget) {
126
122
  name: esmx.name,
127
123
  exports: {
128
124
  'src/entry.node': {
129
- rewrite: false,
125
+ pkg: false,
130
126
  file: './src/entry.node'
131
127
  }
132
128
  }
133
129
  };
134
130
  }
135
131
 
136
- const exports: Record<string, { rewrite: boolean; file: string }> = {};
137
- for (const [name, item] of Object.entries(esmx.moduleConfig.exports)) {
138
- if (item.entryPoints[buildTarget]) {
139
- exports[name] = {
140
- rewrite: item.rewrite,
141
- file: item.entryPoints[buildTarget]
142
- };
143
- }
144
- }
145
-
146
132
  const preEntries: string[] = [];
147
133
  if (isClient && !esmx.isProd) {
148
134
  preEntries.push(
@@ -151,11 +137,10 @@ function createModuleLinkConfig(esmx: Esmx, buildTarget: BuildTarget) {
151
137
  }
152
138
 
153
139
  return {
140
+ ...esmx.moduleConfig.environments[buildTarget],
154
141
  name: esmx.name,
155
142
  injectChunkName: isServer,
156
- imports: esmx.moduleConfig.imports,
157
143
  deps: Object.keys(esmx.moduleConfig.links),
158
- exports,
159
144
  preEntries
160
145
  };
161
146
  }
@@ -6,30 +6,30 @@ describe('generateExports', () => {
6
6
  it('should generate exports with both client and server files', () => {
7
7
  const clientExports: ManifestJsonExports = {
8
8
  'src/entry.client': {
9
- file: 'exports/src/entry.client.95f6085b.final.mjs',
9
+ file: 'src/entry.client.95f6085b.final.mjs',
10
10
  name: 'src/entry.client',
11
- rewrite: true,
11
+ pkg: true,
12
12
  identifier: 'ssr-vue2-remote/src/entry.client'
13
13
  },
14
14
  'src/components/index': {
15
- file: 'exports/src/components/index.a73d6772.final.mjs',
15
+ file: 'src/components/index.a73d6772.final.mjs',
16
16
  name: 'src/components/index',
17
- rewrite: true,
17
+ pkg: true,
18
18
  identifier: 'ssr-vue2-remote/src/components/index'
19
19
  }
20
20
  };
21
21
 
22
22
  const serverExports: ManifestJsonExports = {
23
23
  'src/entry.server': {
24
- file: 'exports/src/entry.server.b85ed2ff.final.mjs',
24
+ file: 'src/entry.server.b85ed2ff.final.mjs',
25
25
  name: 'src/entry.server',
26
- rewrite: true,
26
+ pkg: true,
27
27
  identifier: 'ssr-vue2-remote/src/entry.server'
28
28
  },
29
29
  'src/components/index': {
30
- file: 'exports/src/components/index.12b57db5.final.mjs',
30
+ file: 'src/components/index.12b57db5.final.mjs',
31
31
  name: 'src/components/index',
32
- rewrite: true,
32
+ pkg: true,
33
33
  identifier: 'ssr-vue2-remote/src/components/index'
34
34
  }
35
35
  };
@@ -41,14 +41,12 @@ describe('generateExports', () => {
41
41
 
42
42
  expect(result).toEqual({
43
43
  './src/entry.client':
44
- './client/exports/src/entry.client.95f6085b.final.mjs',
44
+ './client/src/entry.client.95f6085b.final.mjs',
45
45
  './src/entry.server':
46
- './server/exports/src/entry.server.b85ed2ff.final.mjs',
46
+ './server/src/entry.server.b85ed2ff.final.mjs',
47
47
  './src/components/index': {
48
- default:
49
- './server/exports/src/components/index.12b57db5.final.mjs',
50
- browser:
51
- './client/exports/src/components/index.a73d6772.final.mjs'
48
+ default: './server/src/components/index.12b57db5.final.mjs',
49
+ browser: './client/src/components/index.a73d6772.final.mjs'
52
50
  }
53
51
  });
54
52
  });
@@ -58,7 +56,7 @@ describe('generateExports', () => {
58
56
  index: {
59
57
  file: 'index.js',
60
58
  name: 'index',
61
- rewrite: true,
59
+ pkg: true,
62
60
  identifier: 'index'
63
61
  }
64
62
  };
@@ -67,7 +65,7 @@ describe('generateExports', () => {
67
65
  index: {
68
66
  file: 'index.js',
69
67
  name: 'index',
70
- rewrite: true,
68
+ pkg: true,
71
69
  identifier: 'index'
72
70
  }
73
71
  };
@@ -108,7 +106,7 @@ describe('generateExports', () => {
108
106
  utils: {
109
107
  file: 'utils.js',
110
108
  name: 'utils',
111
- rewrite: true,
109
+ pkg: true,
112
110
  identifier: 'utils'
113
111
  }
114
112
  };
@@ -132,7 +130,7 @@ describe('generateExports', () => {
132
130
  api: {
133
131
  file: 'api.js',
134
132
  name: 'api',
135
- rewrite: true,
133
+ pkg: true,
136
134
  identifier: 'api'
137
135
  }
138
136
  };
@@ -152,7 +150,7 @@ describe('generateExports', () => {
152
150
  index: {
153
151
  file: 'index.js',
154
152
  name: 'index',
155
- rewrite: true,
153
+ pkg: true,
156
154
  identifier: 'index'
157
155
  }
158
156
  };
@@ -161,7 +159,7 @@ describe('generateExports', () => {
161
159
  index: {
162
160
  file: 'index.js',
163
161
  name: 'index',
164
- rewrite: true,
162
+ pkg: true,
165
163
  identifier: 'index'
166
164
  }
167
165
  };
@@ -183,7 +183,7 @@ export interface RspackHtmlAppOptions extends RspackAppOptions {
183
183
  * // Per-build-target configuration
184
184
  * target: {
185
185
  * client: 'modern',
186
- * server: ['node>=18']
186
+ * server: ['node>=24']
187
187
  * }
188
188
  * ```
189
189
  */
@@ -293,6 +293,7 @@ function configureTypeScriptRule(
293
293
  buildTarget: BuildTarget,
294
294
  options: RspackHtmlAppOptions
295
295
  ): void {
296
+ const targets = getTargetSetting(options?.target, buildTarget);
296
297
  chain.module
297
298
  .rule('typescript')
298
299
  .test(/\.(ts|mts)$/i)
@@ -302,7 +303,7 @@ function configureTypeScriptRule(
302
303
  )
303
304
  .options({
304
305
  env: {
305
- targets: getTargetSetting(options?.target, buildTarget),
306
+ targets,
306
307
  ...options?.swcLoader?.env
307
308
  },
308
309
  jsc: {
@@ -382,7 +383,7 @@ function configureCssRules(
382
383
  configureCssInJS(chain, esmx, options);
383
384
  return;
384
385
  }
385
- configureCssExtract(chain, esmx, options);
386
+ configureCssExtract(chain, options);
386
387
  }
387
388
 
388
389
  function configureCssInJS(
@@ -454,7 +455,6 @@ function configureCssInJS(
454
455
 
455
456
  function configureCssExtract(
456
457
  chain: RspackChain,
457
- esmx: Esmx,
458
458
  options: RspackHtmlAppOptions
459
459
  ): void {
460
460
  chain.set('experiments', {