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

feat(html): html simple script tag support import-expression #6525

Merged
merged 6 commits into from
Jan 16, 2022

Conversation

poyoho
Copy link
Member

@poyoho poyoho commented Jan 16, 2022

Description

fix: #3658
duplicate of #6240

Additional context


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.

@poyoho
Copy link
Member Author

poyoho commented Jan 16, 2022

@patak-dev new PR in here🙈

@patak-dev patak-dev merged commit 3546d4f into vitejs:main Jan 16, 2022
@eugene1g
Copy link

eugene1g commented Feb 9, 2022

Hi @poyoho,

FYI this PR conflicts with other module loaders such as SystemJS. In my HTML file I have this line -

System.import("/some/other/module.js");

It has nothing to do with Vite, and until 2.8.0 Vite would leave it alone. Starting from 2.8.0, Vite tries to take ownership of that JS file because the line matches the new RegExp from this PR (const inlineImportRE = /\bimport\s*\(("[^"]*"|'[^']*')\)/g). Specifically, the "Word Boundary" \b means the RegExp matches System.import and not just standalone import("..."). This is probably not intentional.

@poyoho
Copy link
Member Author

poyoho commented Feb 9, 2022

so we need to ignore the . before the import🤔 @eugene1g

@patak-dev
Copy link
Member

Thanks for the report @eugene1g, would you create an issue so we can properly track its resolution?
@poyoho maybe instead of the word boundary we could be explicit and use something like ([\s;:\(]|(\*\/))? We could also have issues with "import(, commented code, etc

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

Successfully merging this pull request may close these issues.

<script>import("file.js")</script> works with vite devserver, but not with vite build
4 participants