-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
test(v6): add runner dynamic import test #17422
base: v6/environment-api
Are you sure you want to change the base?
test(v6): add runner dynamic import test #17422
Conversation
|
@@ -17,3 +19,27 @@ describe('resolveBuildEnvironmentOptions in dev', () => { | |||
expect(config.build.rollupOptions).not.toHaveProperty('input') | |||
}) | |||
}) | |||
|
|||
test('runner dynamic import', async () => { |
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 is a test for dynamic import already: https://github.com/vitejs/vite/blob/v6/environment-api/packages/vite/src/node/ssr/runtime/__tests__/fixtures/dynamic-import.js
I would rather we update it there
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.
Thanks for the pointer. Moving there makes sense 👍
The same issue reproduces there, but I'm seeing a weird error like it shows up on annotation:
PrettyFormatPluginError: [module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.$$typeof" instead.
Locally, I confirmed the reproduction by console.log like this:
console.log(modules.static === modules.dynamicAbsoluteExtension); // true
console.log(modules.static === modules.dynamicAbsoluteFull); // false
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.
This is because there is a test file that does export const meta = import.meta
, and accessing .env
causes it to throw an error (the Vitest equality checker/formatter tries to access $$typeof
)
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.
Oh right I remember. For now I changed it to expect(modules.static === modules.dynamicAbsoluteFull).toBe(true)
so that the error is not confusing.
Description
I'm testing alpha.18 hi-ogawa/vite-environment-examples#91 and found that
import(/* @vite-ignore */ someAboslutePath)
is returning a duplicate module. I added a failing test case in this PR.