Skip to content
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

Draft
wants to merge 4 commits into
base: v6/environment-api
Choose a base branch
from

Conversation

hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Jun 8, 2024

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.

Copy link

stackblitz bot commented Jun 8, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@@ -17,3 +19,27 @@ describe('resolveBuildEnvironmentOptions in dev', () => {
expect(config.build.rollupOptions).not.toHaveProperty('input')
})
})

test('runner dynamic import', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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

Copy link
Member

@sheremet-va sheremet-va Jun 10, 2024

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)

Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants