Skip to content

Comments

fix(vite): can not resolve node_module package which has a query surfix#8824

Closed
CaptainLiao wants to merge 1 commit intovitejs:mainfrom
CaptainLiao:main
Closed

fix(vite): can not resolve node_module package which has a query surfix#8824
CaptainLiao wants to merge 1 commit intovitejs:mainfrom
CaptainLiao:main

Conversation

@CaptainLiao
Copy link

@CaptainLiao CaptainLiao commented Jun 28, 2022

Description

When I import a node_module package with query surfix, vite can't resolve it and give me a error:

const Vue3Lottie = async () => (await import( "vue3-lottie?chunkName=vue-lottie")).Vue3Lottie;

error logs:

[vite]: Rollup failed to resolve import "vue3-lottie?chunkName=vue-lottie" from "src/pages/demo/demo.vue".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "vue3-lottie?chunkName=vue-lottie" from "src/pages/demo/demo.vue".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at onRollupWarning (D:\work\ytt-pc-1\node_modules\vite\dist\node\chunks\dep-8f5c9290.js:41772:19)
    at onwarn (D:\work\ytt-pc-1\node_modules\vite\dist\node\chunks\dep-8f5c9290.js:41588:13)
    at Object.onwarn (D:\work\ytt-pc-1\node_modules\rollup\dist\shared\rollup.js:23224:13)
    at ModuleLoader.handleResolveId (D:\work\ytt-pc-1\node_modules\rollup\dist\shared\rollup.js:22508:26)
    at ModuleLoader.resolveDynamicImport (D:\work\ytt-pc-1\node_modules\rollup\dist\shared\rollup.js:22560:120)
    at D:\work\ytt-pc-1\node_modules\rollup\dist\shared\rollup.js:22455:32

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@netlify
Copy link

netlify bot commented Jun 28, 2022

Deploy Preview for vite-docs-main canceled.

Name Link
🔨 Latest commit 9f0f4e6
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62ba7e69f2d0d600081cd903

@CaptainLiao CaptainLiao changed the title feat: resolve nodeId that has a query surfix fix: can not resolve nodeId whitch has a query surfix Jun 28, 2022
@CaptainLiao CaptainLiao changed the title fix: can not resolve nodeId whitch has a query surfix fix(vite): can not resolve nodeId whitch has a query surfix Jun 28, 2022
@CaptainLiao CaptainLiao changed the title fix(vite): can not resolve nodeId whitch has a query surfix fix(vite): can not resolve node_module package whitch has a query surfix Jun 29, 2022
@CaptainLiao CaptainLiao changed the title fix(vite): can not resolve node_module package whitch has a query surfix fix(vite): can not resolve node_module package which has a query surfix Jul 1, 2022
@sapphi-red
Copy link
Member

packagefoo/bar?baz.js might mean bar?bar.js inside packagefoo. (though it is not recommended to do that)
So we could not use id.split('?') there.

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.

2 participants