-
Notifications
You must be signed in to change notification settings - Fork 162
refactor(commands): unify webpack and Rspack commands #1424
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
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d6a4ece
refactor(commands): add shared CompilerInterface, CompilerAsset types…
jbroma 831f368
feat(commands): add bundler auto-detection from config filename
jbroma 79b235e
refactor(commands): implement CompilerInterface on both Compiler classes
jbroma 0c8939f
refactor(commands): create unified command entry point with auto-dete…
jbroma 60f05f3
refactor: update consumers to use unified @callstack/repack/commands
jbroma 35c831b
fix: types
jbroma f030d31
Merge remote-tracking branch 'origin/main' into refactor/unify-commands
jbroma 32236c8
fix(commands): reject pending assets on webpack errors
jbroma c5254f2
fix(commands): validate bundler option
jbroma ec1d5b3
chore: add unified commands changeset
jbroma 39d67ef
chore: split unified command release notes
jbroma 6b5b3af
Merge branch 'main' into refactor/unify-commands
dannyhw eadcc91
Merge main into refactor/unify-commands
dannyhw 06daa86
Merge branch 'main' into refactor/unify-commands
dannyhw da3652e
fix(commands): warn on conflicting legacy bundler flag
jbroma 4fa8f7d
chore(commands): align warning message style
jbroma 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@callstack/repack": patch | ||
| --- | ||
|
|
||
| Reject pending webpack asset requests when compilation fails instead of leaving requests hanging. |
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,6 @@ | ||
| --- | ||
| "@callstack/repack": minor | ||
| "@callstack/repack-init": patch | ||
| --- | ||
|
|
||
| Add the unified `@callstack/repack/commands` entry point with automatic bundler detection and a `--bundler` override. Re.Pack Init now uses it, while bundler-specific entry points remain available with deprecation warnings. |
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
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,2 @@ | ||
| import commands from '../dist/commands/index.js'; | ||
| export = commands; |
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,2 @@ | ||
| const commands = require('../dist/commands/index.js'); | ||
| module.exports = commands.default; |
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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| import commands from '../dist/commands/rspack/index.js'; | ||
| import commands from '../dist/commands/index.js'; | ||
| export = commands; |
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 |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| const commands = require('../dist/commands/rspack/index.js'); | ||
| module.exports = commands.default; | ||
| console.warn( | ||
| 'Importing "@callstack/repack/commands/rspack" is deprecated. Use "@callstack/repack/commands" instead.' | ||
| ); | ||
| const { createBoundCommands } = require('../dist/commands/index.js'); | ||
| module.exports = createBoundCommands('rspack'); |
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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| import commands from '../dist/commands/webpack/index.js'; | ||
| import commands from '../dist/commands/index.js'; | ||
| export = commands; |
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 |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| const commands = require('../dist/commands/webpack/index.js'); | ||
| module.exports = commands.default; | ||
| console.warn( | ||
| 'Importing "@callstack/repack/commands/webpack" is deprecated. Use "@callstack/repack/commands" instead.' | ||
| ); | ||
| const { createBoundCommands } = require('../dist/commands/index.js'); | ||
| module.exports = createBoundCommands('webpack'); |
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,49 @@ | ||
| import { bundle } from '../bundle.js'; | ||
| import { createBoundCommands } from '../index.js'; | ||
| import type { BundleArguments, CliConfig, StartArguments } from '../types.js'; | ||
|
|
||
| jest.mock('../bundle.js'); | ||
| jest.mock('../start.js'); | ||
|
|
||
| const cliConfig: CliConfig = { | ||
| root: '/project', | ||
| platforms: ['ios'], | ||
| reactNativePath: '/project/node_modules/react-native', | ||
| }; | ||
|
|
||
| const args = { | ||
| dev: true, | ||
| host: '', | ||
| platform: 'ios', | ||
| } satisfies BundleArguments & StartArguments; | ||
|
|
||
| describe('createBoundCommands', () => { | ||
| const consoleWarn = jest.spyOn(console, 'warn').mockImplementation(); | ||
|
|
||
| test('warns when the bound command overrides --bundler', async () => { | ||
| const [command] = createBoundCommands('webpack'); | ||
|
|
||
| await command.func([], cliConfig, { ...args, bundler: 'rspack' }); | ||
|
|
||
| expect(consoleWarn).toHaveBeenCalledWith( | ||
| 'Ignoring "--bundler rspack" because the deprecated "@callstack/repack/commands/webpack" entry point explicitly selects webpack. Use "@callstack/repack/commands" to select a bundler with --bundler.' | ||
| ); | ||
| expect(bundle).toHaveBeenCalledWith( | ||
| [], | ||
| cliConfig, | ||
| { ...args, bundler: 'rspack' }, | ||
| 'webpack' | ||
| ); | ||
| }); | ||
|
|
||
| test.each([undefined, 'webpack' as const])( | ||
| 'does not warn when --bundler is %s', | ||
| async (bundler) => { | ||
| const [command] = createBoundCommands('webpack'); | ||
|
|
||
| await command.func([], cliConfig, { ...args, bundler }); | ||
|
|
||
| expect(consoleWarn).not.toHaveBeenCalled(); | ||
| } | ||
| ); | ||
| }); |
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,20 @@ | ||
| import { bundleCommandOptions, startCommandOptions } from '../options.js'; | ||
|
|
||
| describe.each([ | ||
| ['start', startCommandOptions], | ||
| ['bundle', bundleCommandOptions], | ||
| ])('%s command options', (_, options) => { | ||
| const bundlerOption = options.find( | ||
| (option) => option.name === '--bundler <string>' | ||
| ); | ||
|
|
||
| test.each(['rspack', 'webpack'])('accepts the %s bundler', (bundler) => { | ||
| expect(bundlerOption?.parse?.(bundler)).toBe(bundler); | ||
| }); | ||
|
|
||
| test('rejects an unsupported bundler', () => { | ||
| expect(() => bundlerOption?.parse?.('metro')).toThrow( | ||
| 'Invalid bundler "metro". Expected "rspack" or "webpack".' | ||
| ); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.