Skip to content

fix(plugin-legacy): fail to get the fileName#5250

Merged
patak-cat merged 3 commits intovitejs:mainfrom
dragonHandsome:patch-1
May 15, 2022
Merged

fix(plugin-legacy): fail to get the fileName#5250
patak-cat merged 3 commits intovitejs:mainfrom
dragonHandsome:patch-1

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
}

// 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-cat patak-cat added the p3-minor-bug An edge case that only affects very specific usage (priority) label May 12, 2022
@patak-cat patak-cat 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