-
-
Notifications
You must be signed in to change notification settings - Fork 54
feat: warn used dep in devDependencies under bundeless mode #1295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "bundleless-dev-dependency-warning", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "devDependencies": { | ||
| "left-pad": "1.0.0", | ||
| "normalize.css": "8.0.1" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { defineConfig } from '@rslib/core'; | ||
| import { generateBundleEsmConfig } from 'test-helper'; | ||
|
|
||
| export default defineConfig({ | ||
| lib: [ | ||
| generateBundleEsmConfig({ | ||
| bundle: false, | ||
| source: { | ||
| entry: { | ||
| index: 'src/index.ts', | ||
| }, | ||
| }, | ||
| output: { | ||
| distPath: 'dist', | ||
| }, | ||
| }), | ||
| ], | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import leftPad from 'left-pad'; | ||
| import leftPadLib from 'left-pad/lib'; | ||
| import 'normalize.css'; | ||
|
|
||
| export const primary = leftPad('foo', 5, ' '); | ||
| export const secondary = leftPadLib; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,3 +112,24 @@ | |
| " | ||
| `); | ||
| }); | ||
|
|
||
| test('warn when bundleless external depends on devDependencies', async () => { | ||
| const fixturePath = join(__dirname, 'dev-dependency-warning'); | ||
| const { logs, restore } = proxyConsole(); | ||
|
|
||
| await buildAndGetResults({ fixturePath }); | ||
|
|
||
| restore(); | ||
| const warnLogs = logs.map((log) => stripAnsi(String(log))); | ||
| console.log(warnLogs); | ||
| const jsMatchingLog = warnLogs.filter( | ||
| (log) => | ||
| log.includes('The externalized request "left-pad/lib" from index.ts is declared in "devDependencies" in package.json. Bundleless mode does not include devDependencies in the output, consider moving it to "dependencies" or "peerDependencies".') | ||
|
||
| ); | ||
| expect(jsMatchingLog.length).toBe(1); | ||
|
Check failure on line 129 in tests/integration/externals/index.test.ts
|
||
| const cssMatchingLog = warnLogs.filter( | ||
| (log) => | ||
| log.includes('The externalized request "normalize.css" from index.ts is declared in "devDependencies" in package.json. Bundleless mode does not include devDependencies in the output, consider moving it to "dependencies" or "peerDependencies".') | ||
| ); | ||
| expect(cssMatchingLog.length).toBe(1); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug
console.logstatement before merging to production. This appears to be leftover debugging code.