vite icon indicating copy to clipboard operation
vite copied to clipboard

feat: dynamic import support ?url and ?worker

Open poyoho opened this issue 2 years ago • 3 comments

Description

dynamic import support ?url and ?worker

feat test glob import for worker

Additional context


What is the purpose of this pull request?

  • [ ] Bug fix
  • [x] New Feature
  • [ ] Documentation update
  • [ ] Other

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

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

poyoho avatar May 21 '22 15:05 poyoho

Let's discuss this in the next meeting. I'm not sure if we would like to keep expanding on the as syntax given that there is a chance it will change. I think the feature makes sense though, and users would be surprised if these modifiers don't work.

patak-dev avatar May 21 '22 16:05 patak-dev

The PR is not expanding on the as syntax, it use the as syntax in dynamic import and make the dynamic import keep same with import.meta.glob. May be we change the as syntax to other syntax, but I think the feature(?raw, ?url, ?worker) we will keep. We can change the import.meta.glob("./*.js", { as: 'url' }) to the new syntax. And the user always use import(./${var}.js?url) to import assert url.

poyoho avatar May 22 '22 02:05 poyoho

@poyoho we decided to move forward with this feature in today's meeting 👍🏼 Would you rebase the PR once you have a chance? Let's merge it in 3.2

patak-dev avatar Sep 09 '22 14:09 patak-dev