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

fix: do not warn (about not being able to bundle non module scripts) when src is an external url #7380

Merged
merged 1 commit into from Mar 19, 2022

Conversation

rstoenescu
Copy link
Contributor

Description

Do not warn (about not being able to bundle non module scripts injected into /index.html) when src is an external url.

Additional context

Example of script tag in /index.html causing following warning:

<script src="https://www.googletagmanager.com/gtag/js?id=..."> in "/index.html" can't be bundled without type="module" attribute

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.

…when src is an external url

Example of script tag in /index.html causing following warning:
<script src="https://www.googletagmanager.com/gtag/js?id=..."> in "/index.html" can't be bundled without type="module" attribute
@rstoenescu
Copy link
Contributor Author

Cheers from the Quasar Team!

config.logger.warn(
`<script src="${url}"> in "${publicPath}" can't be bundled without type="module" attribute`
)
if (!isExcludedUrl(url)) {
Copy link
Member

Choose a reason for hiding this comment

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

This has been on my to-fix list for a long while. Thanks for fixing this 😄

My only concern with this is that isExcludedUrl also runs checkPublicFile, which is already covered by isPublicFile. But given this warning don't always happen, I think it's still fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bluwy I thought it was too much to create a new function similar to isExcludedUrl() but without the checkPublicFile() call. Felt more like duplicating code than optimization. However, should you guys want to, I can create a new PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine the way it is now 👍

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 19, 2022
@patak-dev patak-dev merged commit 0646fe8 into vitejs:main Mar 19, 2022
@Evavic44
Copy link
Contributor

Honestly, thanks for the fix. I've been seeing this error and I can't help but feel like something is broken in my code.

Stupid question 😅: How do I update so the fix can take effect? @bluwy

I ran npm run build a few minutes ago and still got the error.

vite-google-tag-manager-error

vite version: v2.7.13
node version: v16.14.0

@patak-dev
Copy link
Member

You can use vite@2.9.0-beta.4, or wait until 2.9 is released

@Evavic44
Copy link
Contributor

You can use vite@2.9.0-beta.4, or wait until 2.9 is released

Oh... Many thanks. 🙏🏾

@dh336699
Copy link

dh336699 commented Feb 7, 2023

@patak-dev Hey guy, I had met the same issue in vite v3.2.5

@patak-dev
Copy link
Member

@dh336699 please try with Vite's latest version and if you find a regression, create a new issue with a minimal reproduction. Thanks!

@dh336699
Copy link

dh336699 commented Feb 7, 2023

@patak-dev Thanks for your reply, our project was based on Vben.
Maybe you can clone it and build it have a try

@patak-dev
Copy link
Member

That isn't how reports are tracked and resolved. If you can reproduce it without VBen, create an issue with a minimal reproduction. If not, create an issue in the VBen repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants