-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
161 changed files
with
1,926 additions
and
1,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const content = 'source.alias worked'; | ||
export const content = 'resolve.alias worked'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { build } from '@e2e/helper'; | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('should allow to use the legacy `source.alias` config', async () => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await rsbuild.unwrapOutputJSON(); | ||
const fileNames = Object.keys(files); | ||
const webIndex = fileNames.find( | ||
(file) => file.includes('static/js') && file.endsWith('index.js'), | ||
); | ||
const nodeIndex = fileNames.find( | ||
(file) => file.includes('server/index') && file.endsWith('index.js'), | ||
); | ||
|
||
expect(files[webIndex!]).toContain('for web target'); | ||
expect(files[nodeIndex!]).toContain('for node target'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
|
||
export default defineConfig({ | ||
output: { | ||
filenameHash: false, | ||
}, | ||
environments: { | ||
web: { | ||
source: { | ||
alias: { | ||
'@common': './src/common', | ||
}, | ||
}, | ||
output: { | ||
target: 'web', | ||
}, | ||
}, | ||
node: { | ||
source: { | ||
alias: { | ||
'@common': './src/common2', | ||
}, | ||
}, | ||
output: { | ||
target: 'node', | ||
distPath: { | ||
root: 'dist/server', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const content = 'for web target'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const content = 'for node target'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { content } from '@common/test'; | ||
|
||
console.log(content); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const content = 'source.alias worked'; | ||
export const content = 'resolve.alias worked'; |
4 changes: 3 additions & 1 deletion
4
e2e/cases/alias/tsconfig-paths-specify-config/rsbuild.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
|
||
export default defineConfig({ | ||
source: { | ||
resolve: { | ||
alias: { | ||
'@common': './src/common2', | ||
}, | ||
}, | ||
source: { | ||
tsconfigPath: 'tsconfig.custom.json', | ||
}, | ||
}); |
2 changes: 1 addition & 1 deletion
2
e2e/cases/alias/tsconfig-paths-specify-config/src/common2/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const content = 'source.alias worked'; | ||
export const content = 'resolve.alias worked'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const content = 'source.alias worked'; | ||
export const content = 'resolve.alias worked'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { createRsbuild } from '@rsbuild/core'; | ||
|
||
test('should allow to call `build` and get stats object', async () => { | ||
const rsbuild = await createRsbuild({ | ||
cwd: __dirname, | ||
}); | ||
|
||
const { stats, close } = await rsbuild.build(); | ||
|
||
await close(); | ||
|
||
const result = stats?.toJson({ all: true })!; | ||
|
||
expect(result.name).toBe('web'); | ||
expect(result.assets?.length).toBeGreaterThan(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { join } from 'node:path'; | ||
import { build } from '@e2e/helper'; | ||
import { expect, test } from '@playwright/test'; | ||
import { outputFileSync } from 'fs-extra'; | ||
|
||
function writeDuplicatedPackage(flag: string) { | ||
const fooPath = join(__dirname, 'node_modules', 'foo'); | ||
outputFileSync( | ||
join(fooPath, 'package.json'), | ||
JSON.stringify({ name: 'foo', version: '1.0.0' }), | ||
); | ||
outputFileSync( | ||
join(fooPath, 'index.js'), | ||
'import React from "react";export default React;', | ||
); | ||
outputFileSync( | ||
join(fooPath, 'node_modules', 'react', 'package.json'), | ||
JSON.stringify({ name: 'react', version: '1.0.0' }), | ||
); | ||
outputFileSync( | ||
join(fooPath, 'node_modules', 'react', 'index.js'), | ||
`console.log("${flag}");`, | ||
); | ||
} | ||
|
||
test('should dedupe specified packages as expected', async () => { | ||
const flag = 'This is fake React'; | ||
writeDuplicatedPackage(flag); | ||
|
||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
}); | ||
|
||
const { content } = await rsbuild.getIndexFile(); | ||
expect(content).not.toContain(flag); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
|
||
export default defineConfig({ | ||
resolve: { | ||
dedupe: ['react', 'react-dom'], | ||
}, | ||
performance: { | ||
chunkSplit: { | ||
strategy: 'all-in-one', | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import foo from 'foo'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
console.log(React, ReactDOM, foo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.