-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: do not clean dist path if it is outside root (#1433)
- Loading branch information
1 parent
b426cb5
commit f90c127
Showing
10 changed files
with
149 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rsbuild/core': patch | ||
--- | ||
|
||
release: 0.3.9 |
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 |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
"selfsign", | ||
"sirv", | ||
"stacktracey", | ||
"subdir", | ||
"subpage", | ||
"svgr", | ||
"systemjs", | ||
|
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,61 @@ | ||
import { join } from 'node:path'; | ||
import { expect, test } from '@playwright/test'; | ||
import { fse } from '@rsbuild/shared'; | ||
import { build, proxyConsole } from '@e2e/helper'; | ||
|
||
const cwd = __dirname; | ||
const testDistFile = join(cwd, 'dist/test.json'); | ||
|
||
test('should clean dist path by default', async () => { | ||
await fse.outputFile(testDistFile, `{ "test": 1 }`); | ||
|
||
await build({ | ||
cwd, | ||
}); | ||
|
||
expect(fse.existsSync(testDistFile)).toBeFalsy(); | ||
fse.removeSync(testDistFile); | ||
}); | ||
|
||
test('should not clean dist path if it is outside root', async () => { | ||
const { logs, restore } = proxyConsole(); | ||
const testOutsideFile = join(cwd, '../node_modules/test.json'); | ||
await fse.outputFile(testOutsideFile, `{ "test": 1 }`); | ||
|
||
await build({ | ||
cwd, | ||
rsbuildConfig: { | ||
output: { | ||
distPath: { | ||
root: '../node_modules', | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect( | ||
logs.find((log) => log.includes('dist path is not a subdir of root path')), | ||
).toBeTruthy(); | ||
|
||
expect(fse.existsSync(testOutsideFile)).toBeTruthy(); | ||
|
||
fse.removeSync(testOutsideFile); | ||
restore(); | ||
}); | ||
|
||
test('should allow to disable cleanDistPath', async () => { | ||
await fse.outputFile(testDistFile, `{ "test": 1 }`); | ||
|
||
await build({ | ||
cwd, | ||
rsbuildConfig: { | ||
output: { | ||
cleanDistPath: false, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(fse.existsSync(testDistFile)).toBeTruthy(); | ||
|
||
fse.removeSync(testDistFile); | ||
}); |
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
30 changes: 25 additions & 5 deletions
30
packages/document/docs/en/config/output/clean-dist-path.mdx
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
28 changes: 24 additions & 4 deletions
28
packages/document/docs/zh/config/output/clean-dist-path.mdx
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