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(plugin-legacy): fail to get the fileName #5250

Merged
merged 3 commits into from
May 15, 2022

Conversation

dragonHandsome
Copy link
Contributor

fileName could not be obtained in the bundle argument of the writeBundle hook, see: https://rollupjs.org/guide/en/#writebundle

Description

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.

fileName could not be obtained in the bundle argument of the writeBundle hook, see: https://rollupjs.org/guide/en/#writebundle
@@ -593,7 +593,7 @@ async function buildPolyfillChunk(
}

// add the chunk to the bundle
bundle[polyfillChunk.name] = polyfillChunk
Copy link
Member

Choose a reason for hiding this comment

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

Was name always wrong here? Or can we use something like name || fileName 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I expect the bundle's key to be fileName, because rollup.d.ts is written that way. In fact it's pretty much what I expected, except for 'polyfills-legacy ' chunk. see:
print: assets [
'assets/index-legacy.fc12ec77.js',
'assets/vendor-legacy.2384e447.js',
'polyfills-legacy',
'assets/cut.bd8e1359.png',
'assets/index.4f943797.js',
'assets/vendor.92adb1a9.js',
'assets/vendor.6ff1d4f6.css',
'assets/index.1a175568.css',
'index.html'
]
code: writeBundle(options, bundle) {
Object.keys(bundle).map(fileName => {
// fileName.startsWith('assets') &&
assets.push(fileName)
// assets.push(bundle[fileName].fileName)
})
},
closeBundle() {
console.log('assets', assets)
}

@patak-dev patak-dev added the p3-minor-bug An edge case that only affects very specific usage (priority) label May 12, 2022
@patak-dev patak-dev merged commit c7fc1d4 into vitejs:main May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) plugin: legacy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants