-
Notifications
You must be signed in to change notification settings - Fork 57
feat(command): support --lib arguments #390
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
import { execSync } from 'node:child_process'; | ||
import path from 'node:path'; | ||
import fse from 'fs-extra'; | ||
import { globContentJSON } from 'test-helper'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
describe('build command', async () => { | ||
test('basic', async () => { | ||
await fse.remove(path.join(__dirname, 'dist')); | ||
execSync('npx rslib build', { | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await globContentJSON(path.join(__dirname, 'dist')); | ||
const fileNames = Object.keys(files).sort(); | ||
expect(fileNames).toMatchInlineSnapshot(` | ||
[ | ||
"<ROOT>/tests/integration/cli/dist/cjs/index.cjs", | ||
"<ROOT>/tests/integration/cli/dist/esm/index.js", | ||
] | ||
`); | ||
}); | ||
|
||
test('--lib', async () => { | ||
await fse.remove(path.join(__dirname, 'dist')); | ||
execSync('npx rslib build --lib esm', { | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await globContentJSON(path.join(__dirname, 'dist')); | ||
const fileNames = Object.keys(files).sort(); | ||
expect(fileNames).toMatchInlineSnapshot(` | ||
[ | ||
"<ROOT>/tests/integration/cli/dist/esm/index.js", | ||
] | ||
`); | ||
}); | ||
|
||
test('--lib multiple', async () => { | ||
await fse.remove(path.join(__dirname, 'dist')); | ||
execSync('npx rslib build --lib esm --lib cjs', { | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await globContentJSON(path.join(__dirname, 'dist')); | ||
const fileNames = Object.keys(files).sort(); | ||
expect(fileNames).toMatchInlineSnapshot(` | ||
[ | ||
"<ROOT>/tests/integration/cli/dist/cjs/index.cjs", | ||
"<ROOT>/tests/integration/cli/dist/esm/index.js", | ||
] | ||
`); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,95 @@ | ||
import { execSync } from 'node:child_process'; | ||
import path from 'node:path'; | ||
import { describe } from 'node:test'; | ||
import fse from 'fs-extra'; | ||
import { globContentJSON } from 'test-helper'; | ||
import { expect, test } from 'vitest'; | ||
|
||
describe('inspect command', async () => { | ||
test('basic', async () => { | ||
await fse.remove(path.join(__dirname, 'dist')); | ||
execSync('npx rslib inspect', { | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await globContentJSON(path.join(__dirname, 'dist/.rsbuild')); | ||
const fileNames = Object.keys(files).sort(); | ||
|
||
expect(fileNames).toMatchInlineSnapshot(` | ||
[ | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.cjs.mjs", | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.esm.mjs", | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.cjs.mjs", | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.esm.mjs", | ||
] | ||
`); | ||
|
||
// esm rsbuild config | ||
const rsbuildConfigEsm = fileNames.find((item) => | ||
item.includes('rsbuild.config.esm.mjs'), | ||
); | ||
expect(rsbuildConfigEsm).toBeTruthy(); | ||
expect(files[rsbuildConfigEsm!]).toContain("type: 'modern-module'"); | ||
|
||
// esm rspack config | ||
const rspackConfigEsm = fileNames.find((item) => | ||
item.includes('rspack.config.esm.mjs'), | ||
); | ||
expect(rspackConfigEsm).toBeTruthy(); | ||
expect(files[rspackConfigEsm!]).toContain("type: 'modern-module'"); | ||
}); | ||
|
||
test('--lib', async () => { | ||
await fse.remove(path.join(__dirname, 'dist')); | ||
execSync('npx rslib inspect --lib esm', { | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await globContentJSON( | ||
path.join(__dirname, 'dist/esm/.rsbuild'), | ||
); | ||
const fileNames = Object.keys(files).sort(); | ||
|
||
// Rsbuild will emit dump files to `dist/esm` if only one environment is specified. | ||
expect(fileNames).toMatchInlineSnapshot(` | ||
[ | ||
"<ROOT>/tests/integration/cli/dist/esm/.rsbuild/rsbuild.config.mjs", | ||
"<ROOT>/tests/integration/cli/dist/esm/.rsbuild/rspack.config.esm.mjs", | ||
] | ||
`); | ||
|
||
// esm rsbuild config | ||
const rsbuildConfigEsm = fileNames.find((item) => | ||
item.includes('rsbuild.config.mjs'), | ||
); | ||
expect(rsbuildConfigEsm).toBeTruthy(); | ||
expect(files[rsbuildConfigEsm!]).toContain("type: 'modern-module'"); | ||
|
||
// esm rspack config | ||
const rspackConfigEsm = fileNames.find((item) => | ||
item.includes('rspack.config.esm.mjs'), | ||
); | ||
expect(rspackConfigEsm).toBeTruthy(); | ||
expect(files[rspackConfigEsm!]).toContain("type: 'modern-module'"); | ||
}); | ||
|
||
test('--lib multiple', async () => { | ||
await fse.remove(path.join(__dirname, 'dist')); | ||
execSync('npx rslib inspect --lib esm --lib cjs', { | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await globContentJSON(path.join(__dirname, 'dist/.rsbuild')); | ||
const fileNames = Object.keys(files).sort(); | ||
|
||
// Rsbuild will emit dump files to `dist/esm` if only one environment is specified. | ||
expect(fileNames).toMatchInlineSnapshot(` | ||
[ | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.cjs.mjs", | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rsbuild.config.esm.mjs", | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.cjs.mjs", | ||
"<ROOT>/tests/integration/cli/dist/.rsbuild/rspack.config.esm.mjs", | ||
] | ||
`); | ||
}); | ||
}); |
This file contains hidden or 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 foo = 'foo'; |
This file contains hidden or 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 |
---|---|---|
|
@@ -37,6 +37,7 @@ build the library for production | |
Options: | ||
-c --config <config> specify the configuration file, can be a relative or absolute path | ||
--env-mode <mode> specify the env mode to load the `.env.[mode]` file | ||
--lib <name> build the specified library (may be repeated) | ||
-w --watch turn on watch mode, watch for changes and rebuild | ||
-h, --help display help for command | ||
``` | ||
|
@@ -58,6 +59,7 @@ inspect the Rsbuild / Rspack configs of Rslib projects | |
Options: | ||
-c --config <config> specify the configuration file, can be a relative or absolute path | ||
--env-mode <mode> specify the env mode to load the `.env.[mode]` file | ||
--lib <name> build the specified library (may be repeated) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add docs about what name is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In following PR. |
||
--output <output> specify inspect content output path (default: ".rsbuild") | ||
--verbose show full function definitions in output | ||
-h, --help display help for command | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
shared options can be set in
CommonOptions
Uh oh!
There was an error while loading. Please reload this page.
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.
There's a bit difference in the text.
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.
use
choose the specified library
is enough, and what ismay be repeated
mean?