Skip to content

fix: prebundle dep with colon#7006

Merged
patak-cat merged 1 commit into
vitejs:mainfrom
bluwy:fix-prebundle-colon
Feb 20, 2022
Merged

fix: prebundle dep with colon#7006
patak-cat merged 1 commit into
vitejs:mainfrom
bluwy:fix-prebundle-colon

Conversation

@bluwy
Copy link
Copy Markdown
Member

@bluwy bluwy commented Feb 20, 2022

Description

Fixes #6729
Closes #6364 (supersedes)

When importing a package like node:url (aliased to a browser-safe package), handle the colon when flattening the id.

Additional context

With aliases, technically the import path could be anything that needs to be escaped, but colon only for now sounds fine to be strict.


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.

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Feb 20, 2022
@patak-cat patak-cat merged commit 2136f2b into vitejs:main Feb 20, 2022
@bluwy bluwy deleted the fix-prebundle-colon branch February 20, 2022 12:41
@tance77
Copy link
Copy Markdown

tance77 commented Mar 1, 2022

I'm not sure if it's my environment but this doesn't seem to fix the issue in an Electron environment.

version: "vite": "^2.8.5",

Still getting an error when trying to import something using the node: protocol

'fileURLToPath' is not exported by __vite-browser-external:node:url

@Niputi
Copy link
Copy Markdown
Contributor

Niputi commented Mar 1, 2022

@tance77 vite don't support node builtins as they don't exist in the browser and is not part of the esm specification unless polyfilled or externalized.
you can take a look at vite electron templates at vite-awesome repository or take a look at #native in our discord server where there's previous discussions about this topic

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.

node: protocol alias for dependancy with CommonJS exports not working

5 participants