Skip to content

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

Merged
patak-cat merged 6 commits intovitejs:mainfrom
poyoho:faet/html-import-expression
Jan 16, 2022
Merged

feat(html): html simple script tag support import-expression#6525
patak-cat merged 6 commits intovitejs:mainfrom
poyoho:faet/html-import-expression

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-cat patak-cat 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-cat
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

@poyoho poyoho deleted the faet/html-import-expression branch February 10, 2022 07:04
@poyoho poyoho mentioned this pull request Mar 31, 2022
4 tasks
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