-
Notifications
You must be signed in to change notification settings - Fork 122
fix: snapshot not found error when dev with external bundle #2316
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
11 commits
Select commit
Hold shift + click to select a range
b5ec4b0
fix: snapshot not found error when dev with external bundle
upupming 21e426d
Merge branch 'main' into fix/try-fix-externals-hmr
upupming 3791734
test: add test case
upupming 4d16c22
fix(review): address coderabbit review findings
upupming c0b8467
fix: rename MyRuntimePlugin to PLUGIN_NAME
upupming 8dfdba1
fix(refresh): restore LYNX_WEBPACK_MODULES exposure and refine tests
upupming 6c1745a
Merge branch 'main' into fix/try-fix-externals-hmr
upupming 60fca5f
Merge remote-tracking branch 'origin/main' into fix/try-fix-externals…
upupming 0d9d696
feat: use NODE_ENV for dev build
upupming 747de5f
fix: try finally
upupming 7c2376b
Merge branch 'main' into fix/try-fix-externals-hmr
upupming 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
Some comments aren't visible on the classic Files Changed page.
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,7 @@ | ||
| --- | ||
| "@lynx-js/externals-loading-webpack-plugin": patch | ||
| "@lynx-js/react-refresh-webpack-plugin": patch | ||
| "@lynx-js/lynx-bundle-rslib-config": patch | ||
| --- | ||
|
|
||
| Fix snapshot not found error when dev with external bundle |
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
129 changes: 129 additions & 0 deletions
129
packages/webpack/react-refresh-webpack-plugin/test/intercept.test.ts
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,129 @@ | ||
| // Copyright 2026 The Lynx Authors. All rights reserved. | ||
| // Licensed under the Apache License Version 2.0 that can be found in the | ||
| // LICENSE file in the root directory of this source tree. | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { ReactRefreshRspackPlugin } from '../src/ReactRefreshRspackPlugin.js'; | ||
| import { ReactRefreshWebpackPlugin } from '../src/ReactRefreshWebpackPlugin.js'; | ||
|
|
||
| describe('ReactRefresh plugins', () => { | ||
| it('ReactRefreshWebpackPlugin intercept code generation in dev', () => { | ||
| const plugin = new ReactRefreshWebpackPlugin(); | ||
| let generateResult = ''; | ||
|
|
||
| const mockCompiler = { | ||
| options: { mode: 'development' }, | ||
| context: '/test', | ||
| webpack: { | ||
| EntryPlugin: class { | ||
| apply() { | ||
| /* noop */ | ||
| } | ||
| }, | ||
| ProvidePlugin: class { | ||
| apply() { | ||
| /* noop */ | ||
| } | ||
| }, | ||
| RuntimeGlobals: { | ||
| interceptModuleExecution: 'interceptModuleExecution', | ||
| }, | ||
| RuntimeModule: class { | ||
| name: string; | ||
| stage: number; | ||
| constructor(name: string, stage: number) { | ||
| this.name = name; | ||
| this.stage = stage; | ||
| } | ||
| }, | ||
| }, | ||
| hooks: { | ||
| compilation: { | ||
| tap: (_name: string, cb: (compilation: unknown) => void) => { | ||
| const compilation = { | ||
| compiler: mockCompiler, | ||
| mainTemplate: { | ||
| hooks: { | ||
| localVars: { | ||
| tap: () => { | ||
| /* noop */ | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| hooks: { | ||
| additionalTreeRuntimeRequirements: { | ||
| tap: ( | ||
| _name: string, | ||
| reqCb: (chunk: string, requirements: Set<string>) => void, | ||
| ) => { | ||
| const requirements = new Set<string>(); | ||
| reqCb('chunk', requirements); | ||
| }, | ||
| }, | ||
| }, | ||
| addRuntimeModule: ( | ||
| _chunk: unknown, | ||
| module: { generate: () => string }, | ||
| ) => { | ||
| generateResult = module.generate(); | ||
| }, | ||
| }; | ||
| cb(compilation); | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| plugin.apply(mockCompiler); | ||
| expect(generateResult).toContain('__webpack_modules__'); | ||
| expect(generateResult).toContain( | ||
| 'globalThis[Symbol.for(\'__LYNX_WEBPACK_MODULES__\')] = __webpack_modules__;', | ||
| ); | ||
| }); | ||
|
|
||
| it('ReactRefreshRspackPlugin intercept code generation in dev', () => { | ||
| const plugin = new ReactRefreshRspackPlugin(); | ||
| let generateResult = ''; | ||
|
|
||
| const mockCompiler = { | ||
| options: { mode: 'development' }, | ||
| webpack: { | ||
| ProvidePlugin: class { | ||
| apply() { | ||
| /* noop */ | ||
| } | ||
| }, | ||
| }, | ||
| hooks: { | ||
| thisCompilation: { | ||
| tap: (_name: string, cb: (compilation: unknown) => void) => { | ||
| const compilation = { | ||
| hooks: { | ||
| runtimeModule: { | ||
| tap: (_name: string, moduleCb: (module: unknown) => void) => { | ||
| const module = { | ||
| name: 'hot_module_replacement', | ||
| source: { source: Buffer.from('') }, | ||
| }; | ||
| moduleCb(module); | ||
|
|
||
| generateResult = module.source.source.toString(); | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| cb(compilation); | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| // @ts-expect-error test mock | ||
| plugin.apply(mockCompiler); | ||
| expect(generateResult).toContain('__webpack_modules__'); | ||
| expect(generateResult).toContain( | ||
| 'globalThis[Symbol.for(\'__LYNX_WEBPACK_MODULES__\')] = __webpack_modules__;', | ||
| ); | ||
| }); | ||
| }); |
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.