Skip to content

Commit 862b616

Browse files
committed
feat!: target default to node
1 parent b821370 commit 862b616

File tree

83 files changed

+346
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+346
-99
lines changed

examples/express-plugin/rslib.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,4 @@ export default defineConfig({
2727
},
2828
},
2929
],
30-
output: {
31-
target: 'node',
32-
},
3330
});

examples/module-federation/mf-react-component/rslib.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@ export default defineConfig({
5555
],
5656
},
5757
],
58+
output: {
59+
target: 'web',
60+
},
5861
plugins: [pluginReact()],
5962
});

examples/react-component-bundle-false/rslib.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export default defineConfig({
3535
},
3636
},
3737
],
38+
output: {
39+
target: 'web',
40+
},
3841
plugins: [
3942
pluginReact({
4043
swcReactOptions: {

examples/react-component-bundle/rslib.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export default defineConfig({
3333
},
3434
},
3535
],
36+
output: {
37+
target: 'web',
38+
},
3639
plugins: [
3740
pluginReact({
3841
swcReactOptions: {

examples/react-component-umd/rslib.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export default defineConfig({
1717
},
1818
},
1919
],
20+
output: {
21+
target: 'web',
22+
},
2023
plugins: [
2124
pluginReact({
2225
swcReactOptions: {

packages/core/rslib.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default defineConfig({
2121
},
2222
},
2323
output: {
24+
// TODO: Remove this after bumping Rslib
2425
target: 'node',
2526
externals: {
2627
picocolors: '../compiled/picocolors/index.js',

packages/core/src/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ export async function createConstantRsbuildConfig(): Promise<RsbuildConfig> {
453453
},
454454
},
455455
output: {
456+
target: 'node',
456457
filenameHash: false,
457458
distPath: {
458459
js: './',
@@ -558,7 +559,6 @@ const composeFormatConfig = ({
558559
},
559560
output: {
560561
asyncChunks: false,
561-
562562
library: umdName
563563
? {
564564
type: 'umd',
@@ -714,7 +714,7 @@ const composeAutoExtensionConfig = (
714714

715715
const composeSyntaxConfig = (
716716
syntax?: Syntax,
717-
target?: RsbuildConfigOutputTarget,
717+
target: RsbuildConfigOutputTarget = 'node',
718718
): RsbuildConfig => {
719719
// Defaults to ESNext, Rslib will assume all of the latest JavaScript and CSS features are supported.
720720
if (syntax) {
@@ -941,7 +941,7 @@ const composeDtsConfig = async (
941941
};
942942

943943
const composeTargetConfig = (
944-
target: RsbuildConfigOutputTarget = 'web',
944+
target: RsbuildConfigOutputTarget = 'node',
945945
): RsbuildConfig => {
946946
switch (target) {
947947
case 'web':

packages/core/src/utils/syntax.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ export const LATEST_TARGET_VERSIONS: Record<
2626
};
2727

2828
const calcEsnextBrowserslistByTarget = (target: RsbuildConfigOutputTarget) => {
29-
if (!target) {
30-
return [...LATEST_TARGET_VERSIONS.node, ...LATEST_TARGET_VERSIONS.web];
31-
}
32-
3329
if (target === 'node') {
3430
return LATEST_TARGET_VERSIONS.node;
3531
}
@@ -195,7 +191,7 @@ export function transformSyntaxToRspackTarget(
195191

196192
export function transformSyntaxToBrowserslist(
197193
syntax: Syntax,
198-
target?: NonNullable<RsbuildConfig['output']>['target'],
194+
target: NonNullable<RsbuildConfig['output']>['target'],
199195
): NonNullable<NonNullable<RsbuildConfig['output']>['overrideBrowserslist']> {
200196
const handleSyntaxItem = (
201197
syntaxItem: EcmaScriptVersion | string,

packages/core/tests/__snapshots__/config.test.ts.snap

Lines changed: 178 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,62 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
1414
},
1515
"externals": [
1616
[Function],
17+
"assert",
18+
"assert/strict",
19+
"async_hooks",
20+
"buffer",
21+
"child_process",
22+
"cluster",
23+
"console",
24+
"constants",
25+
"crypto",
26+
"dgram",
27+
"diagnostics_channel",
28+
"dns",
29+
"dns/promises",
30+
"domain",
31+
"events",
32+
"fs",
33+
"fs/promises",
34+
"http",
35+
"http2",
36+
"https",
37+
"inspector",
38+
"inspector/promises",
39+
"module",
40+
"net",
41+
"os",
42+
"path",
43+
"path/posix",
44+
"path/win32",
45+
"perf_hooks",
46+
"process",
47+
"punycode",
48+
"querystring",
49+
"readline",
50+
"readline/promises",
51+
"repl",
52+
"stream",
53+
"stream/consumers",
54+
"stream/promises",
55+
"stream/web",
56+
"string_decoder",
57+
"sys",
58+
"timers",
59+
"timers/promises",
60+
"tls",
61+
"trace_events",
62+
"tty",
63+
"url",
64+
"util",
65+
"util/types",
66+
"v8",
67+
"vm",
68+
"wasi",
69+
"worker_threads",
70+
"zlib",
71+
/\\^node:/,
72+
"pnpapi",
1773
],
1874
"filename": {
1975
"js": "[name].js",
@@ -40,13 +96,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
4096
},
4197
"overrideBrowserslist": [
4298
"last 1 node versions",
43-
"last 1 Chrome versions",
44-
"last 1 Firefox versions",
45-
"last 1 Edge versions",
46-
"last 1 Safari versions",
47-
"last 1 ios_saf versions",
48-
"not dead",
4999
],
100+
"target": "node",
50101
},
51102
"performance": {
52103
"chunkSplit": {
@@ -141,7 +192,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
141192
[Function],
142193
{
143194
"target": [
144-
"web",
195+
"node",
145196
],
146197
},
147198
{
@@ -174,6 +225,64 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
174225
"distPath": {
175226
"js": "./",
176227
},
228+
"externals": [
229+
"assert",
230+
"assert/strict",
231+
"async_hooks",
232+
"buffer",
233+
"child_process",
234+
"cluster",
235+
"console",
236+
"constants",
237+
"crypto",
238+
"dgram",
239+
"diagnostics_channel",
240+
"dns",
241+
"dns/promises",
242+
"domain",
243+
"events",
244+
"fs",
245+
"fs/promises",
246+
"http",
247+
"http2",
248+
"https",
249+
"inspector",
250+
"inspector/promises",
251+
"module",
252+
"net",
253+
"os",
254+
"path",
255+
"path/posix",
256+
"path/win32",
257+
"perf_hooks",
258+
"process",
259+
"punycode",
260+
"querystring",
261+
"readline",
262+
"readline/promises",
263+
"repl",
264+
"stream",
265+
"stream/consumers",
266+
"stream/promises",
267+
"stream/web",
268+
"string_decoder",
269+
"sys",
270+
"timers",
271+
"timers/promises",
272+
"tls",
273+
"trace_events",
274+
"tty",
275+
"url",
276+
"util",
277+
"util/types",
278+
"v8",
279+
"vm",
280+
"wasi",
281+
"worker_threads",
282+
"zlib",
283+
/\\^node:/,
284+
"pnpapi",
285+
],
177286
"filename": {
178287
"js": "[name].js",
179288
},
@@ -199,13 +308,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
199308
},
200309
"overrideBrowserslist": [
201310
"last 1 node versions",
202-
"last 1 Chrome versions",
203-
"last 1 Firefox versions",
204-
"last 1 Edge versions",
205-
"last 1 Safari versions",
206-
"last 1 ios_saf versions",
207-
"not dead",
208311
],
312+
"target": "node",
209313
},
210314
"performance": {
211315
"chunkSplit": {
@@ -298,7 +402,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
298402
[Function],
299403
{
300404
"target": [
301-
"web",
405+
"node",
302406
],
303407
},
304408
{
@@ -331,6 +435,64 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
331435
"distPath": {
332436
"js": "./",
333437
},
438+
"externals": [
439+
"assert",
440+
"assert/strict",
441+
"async_hooks",
442+
"buffer",
443+
"child_process",
444+
"cluster",
445+
"console",
446+
"constants",
447+
"crypto",
448+
"dgram",
449+
"diagnostics_channel",
450+
"dns",
451+
"dns/promises",
452+
"domain",
453+
"events",
454+
"fs",
455+
"fs/promises",
456+
"http",
457+
"http2",
458+
"https",
459+
"inspector",
460+
"inspector/promises",
461+
"module",
462+
"net",
463+
"os",
464+
"path",
465+
"path/posix",
466+
"path/win32",
467+
"perf_hooks",
468+
"process",
469+
"punycode",
470+
"querystring",
471+
"readline",
472+
"readline/promises",
473+
"repl",
474+
"stream",
475+
"stream/consumers",
476+
"stream/promises",
477+
"stream/web",
478+
"string_decoder",
479+
"sys",
480+
"timers",
481+
"timers/promises",
482+
"tls",
483+
"trace_events",
484+
"tty",
485+
"url",
486+
"util",
487+
"util/types",
488+
"v8",
489+
"vm",
490+
"wasi",
491+
"worker_threads",
492+
"zlib",
493+
/\\^node:/,
494+
"pnpapi",
495+
],
334496
"filename": {
335497
"js": "[name].js",
336498
},
@@ -356,13 +518,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
356518
},
357519
"overrideBrowserslist": [
358520
"last 1 node versions",
359-
"last 1 Chrome versions",
360-
"last 1 Firefox versions",
361-
"last 1 Edge versions",
362-
"last 1 Safari versions",
363-
"last 1 ios_saf versions",
364-
"not dead",
365521
],
522+
"target": "node",
366523
},
367524
"performance": {
368525
"chunkSplit": {
@@ -437,7 +594,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
437594
[Function],
438595
{
439596
"target": [
440-
"web",
597+
"node",
441598
],
442599
},
443600
{

packages/core/tests/config.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,6 @@ describe('syntax', () => {
217217
).toMatchInlineSnapshot(`
218218
[
219219
"last 1 node versions",
220-
"last 1 Chrome versions",
221-
"last 1 Firefox versions",
222-
"last 1 Edge versions",
223-
"last 1 Safari versions",
224-
"last 1 ios_saf versions",
225-
"not dead",
226220
]
227221
`);
228222
});

0 commit comments

Comments
 (0)