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

Update to rollup 3.0 #62

Merged
merged 1 commit into from
Oct 25, 2022
Merged

Update to rollup 3.0 #62

merged 1 commit into from
Oct 25, 2022

Conversation

dmail
Copy link
Contributor

@dmail dmail commented Oct 17, 2022

This pull request updates dependencies and peerDependencies to enable rollup 3.

⚠️ For now I have removed the dependency to rollup-plugin-license because it's not yet compatible with rollup3.
Either it's ok to go like that or rollup-plugin-license needs to be updated first

@@ -10,7 +10,9 @@ export default {
dir: `dist/${format==='es' ? 'es' : ''}`,
exports: 'auto',
format,
preferConst: true,
generatedCode: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

preferConst is deprecated in rollup3. generatedCode.constBindings is the new way of doing it

@@ -78,6 +78,7 @@ export default function (opts: NodePolyfillsOptions = {}): Plugin {
},
transform(code: string, id: string) {
if(id === PREFIX + 'global.js') return
// @ts-ignore
return injectPlugin.transform!.call(this, code, id.replace(PREFIX, resolve('node_modules', 'polyfill-node')));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TypeScript was complaining about injectPlugin.transform.call being not callable 😬
I suspect rollup updated the types behind their plugins and disallow a plugin to call an other plugin hook 🤷

Copy link
Owner

Choose a reason for hiding this comment

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

Then this might not be a good idea / they may have done this for a reason. @lukastaegert is this okay to ignore?

Copy link
Owner

Choose a reason for hiding this comment

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

@StoneCypher thanks for the ping! If it's been a 3+ days and Lukas hasn't responded here, someone please re-ping me and we can get this merged/released anyway and then see if any users run into issues that way.

Choose a reason for hiding this comment

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

Sorry, missed the original ping. Rollup has no issue with people calling plugin hooks directly if they think they know what they are doing. The reason the types fail is because since recent Rollup 2 releases, plugin hooks can also be objects with a handler property that is the actual hook. Of course the inject plugin does not do that (yet?), so your solution should still work. @ts-ignore is a broad hammer, though. as TransformHook (which is exported by Rollup) might be a more fine-grained way that does not hide any other type errors that may sneak into this line.

Choose a reason for hiding this comment

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

That being said, we do not consider people calling hooks directly a first-class way of using Rollup plugins, which is why we do not consider this a breaking change, and there may be more breaking changes of that kind in the future.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks @lukastaegert!

@dmail dmail mentioned this pull request Oct 17, 2022
@StoneCypher
Copy link

image

@StoneCypher
Copy link

@FredKSchott

@FredKSchott FredKSchott merged commit 597b668 into FredKSchott:main Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants