-
Notifications
You must be signed in to change notification settings - Fork 297
fix: silent IMPORT_IS_UNDEFINED for proxy.ts #787
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1444,6 +1444,81 @@ describe("Plugin config", () => { | |
| expect(defaultHandler).toHaveBeenCalledWith(otherWarning); | ||
| }); | ||
|
|
||
| it("suppresses IMPORT_IS_UNDEFINED noise for generated proxy/middleware fallback probes", async () => { | ||
| const plugins = vinext() as any[]; | ||
| const configPlugin = plugins.find((p) => p.name === "vinext:config"); | ||
| expect(configPlugin).toBeDefined(); | ||
|
|
||
| const result = await configPlugin.config({ root: FIXTURE_DIR, plugins: [] }); | ||
|
|
||
| expect(result.build).toBeDefined(); | ||
| const bundlerOptions = getBuildBundlerOptions(result); | ||
| expect(bundlerOptions).toBeDefined(); | ||
| expect(bundlerOptions.onwarn).toBeDefined(); | ||
|
|
||
| const defaultHandler = vi.fn(); | ||
|
|
||
| bundlerOptions.onwarn( | ||
| { | ||
| code: "IMPORT_IS_UNDEFINED", | ||
| message: | ||
| "[IMPORT_IS_UNDEFINED] Warning: Import `default` will always be undefined because there is no matching export in 'proxy.ts'\\n ╭─[ \\0virtual:vinext-rsc-entry:2632:34 ]", | ||
|
Contributor
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. Nit: these test messages use Not blocking — just a fidelity improvement if you're doing another pass. |
||
| }, | ||
| defaultHandler, | ||
| ); | ||
| expect(defaultHandler).not.toHaveBeenCalled(); | ||
|
|
||
| bundlerOptions.onwarn( | ||
| { | ||
| code: "IMPORT_IS_UNDEFINED", | ||
| message: | ||
| "[IMPORT_IS_UNDEFINED] Warning: Import `default` will always be undefined because there is no matching export in 'middleware.ts'\\n ╭─[ \\0virtual:vinext-server-entry:168:34 ]", | ||
| }, | ||
| defaultHandler, | ||
| ); | ||
| expect(defaultHandler).not.toHaveBeenCalled(); | ||
|
|
||
| bundlerOptions.onwarn( | ||
| { | ||
| code: "IMPORT_IS_UNDEFINED", | ||
| message: | ||
| "[IMPORT_IS_UNDEFINED] Warning: Import `proxy` will always be undefined because there is no matching export in 'proxy.tsx'\\n ╭─[ \\0virtual:vinext-rsc-entry:2632:34 ]", | ||
| }, | ||
| defaultHandler, | ||
| ); | ||
| expect(defaultHandler).not.toHaveBeenCalled(); | ||
|
|
||
| bundlerOptions.onwarn( | ||
| { | ||
| code: "IMPORT_IS_UNDEFINED", | ||
| message: | ||
| "[IMPORT_IS_UNDEFINED] Warning: Import `middleware` will always be undefined because there is no matching export in 'middleware.jsx'\\n ╭─[ \\0virtual:vinext-server-entry:168:34 ]", | ||
| }, | ||
| defaultHandler, | ||
| ); | ||
| expect(defaultHandler).not.toHaveBeenCalled(); | ||
|
|
||
| bundlerOptions.onwarn( | ||
| { | ||
| code: "IMPORT_IS_UNDEFINED", | ||
| message: | ||
| "[IMPORT_IS_UNDEFINED] Warning: Import `default` will always be undefined because there is no matching export in 'some-user-file.ts'", | ||
| }, | ||
| defaultHandler, | ||
| ); | ||
| expect(defaultHandler).toHaveBeenCalledTimes(1); | ||
|
|
||
| bundlerOptions.onwarn( | ||
| { | ||
| code: "IMPORT_IS_UNDEFINED", | ||
| message: | ||
| "[IMPORT_IS_UNDEFINED] Warning: Import `proxy` will always be undefined because there is no matching export in 'some-user-file.ts'", | ||
| }, | ||
| defaultHandler, | ||
| ); | ||
| expect(defaultHandler).toHaveBeenCalledTimes(2); | ||
| }); | ||
|
|
||
| it("preserves user-supplied build.rollupOptions.onwarn", async () => { | ||
| const plugins = vinext() as any[]; | ||
| const configPlugin = plugins.find((p) => p.name === "vinext:config"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.