Skip to content

Conversation

@Andarist
Copy link
Member

Rollup Plugin Name: @rollup/plugin-babel

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

Description

This is still WIP and there is some work left to do regarding migration, but it's ready for a preliminary review. Other than that - I plan to include minor changes to the plugin before it gets released under @rollup scope, so please do not publish this without my green light on that.

I've managed to keep git history from the old repo, which I think is nice here - but it should be merged with squash here.

};
}

const babelPluginFactory = createBabelInputPluginFactory();
Copy link
Member Author

Choose a reason for hiding this comment

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

I would gladly restructure this - I believe those should be 4 separate exports, rather than a single export with static properties. This PR will land v5 of this plugin so this is IMHO OK to do.

WDYT about those:

  • default export (result of createBabelInputPluginFactory())
  • createBabelInputPluginFactory
  • babelOutputPluginFactory
  • createBabelOutputPluginFactory

Those named exports would be quite mouthful 🤷‍♂ but correct. I'm open for other names - but cant figure out anything better myself.

Copy link
Member

Choose a reason for hiding this comment

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

IMO the createXY names are ok as they will not be used often and only by people who know what they are doing. However I think functions should start with a verb, and the return value of createBabelOutputPluginFactory should be called getOutputPlugin, which also sounds less intimidating. For symmetry, I would furthermore export the default export additionally as getInputPlugin. This will make @TrySound happy 😃

Copy link
Member

Choose a reason for hiding this comment

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

On second thought getBabelOutputPlugin and getBabelInputPlugin so that it does not conflict with other plugins

Copy link
Member

Choose a reason for hiding this comment

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

Also note that using named and default export together will switch the plugin to named-exports-mode when imported from CJS. This means that const babel = require(‘rollup-plugin-babel’) will no longer work. And I am not sure if the new CLI rollup -c —plugin babel would work. The latter could be fixed by providing a named export babel instead of a default. In any case, this change would be breaking.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've changed exports to pretty much to what you have suggested, you can check out this commit: 4c5e1a8

Andarist pushed a commit that referenced this pull request Dec 25, 2019
remove ignore from preflight options
@Andarist
Copy link
Member Author

@NotWoods I've resolved your comments, could you take another look at this?

Copy link
Member

@NotWoods NotWoods left a comment

Choose a reason for hiding this comment

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

Tests look pretty good! Some links need updating.

The README and package.json should get updated to match the format of the corresponding files in other plugins. We're trying to use the same template for every plugin in the monorepo.

The CHANGELOG should have an entry for the change in package name and requirements. Other plugins have a similar entry you can copy.

The root README should also be updated with a link to the babel plugin 😄

@Andarist
Copy link
Member Author

@NotWoods resolved your comments, please take a look especially at the documentation changes.

I still have some work to do, but in the meantime, I'd like to get "partial" approvals on what is already included here.

My TODO list:

  • docs about babelHelpers option (compile info from Helpers section into it as well) + link to that from the source (there is currently a verbose console.warn there about it)
  • establish export names - chore: migrate rollup-plugin-babel #108 (comment)
  • document every change in CHANGELOG

Copy link
Member

@NotWoods NotWoods left a comment

Choose a reason for hiding this comment

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

Changelog looks good! README needs a few tweaks to align with the other plugins.

@shellscape
Copy link
Collaborator

@Andarist there seems to be a lot of pushback against conventions that we've set in the repo for migrating this plugin. the conventions we've chosen were to suit the various styles being brought in from repos that were very fragmented. so far, they've worked quite well to bring everything in line and have made maintenance much easier.

If you'd like, I'm happy to go through and update the files that need updating to established conventions so we don't have to engage in the frequent back and forth. I'd like to get you on board, but perhaps it's better to have these discussions after the babel plugin is finished so we can complete the migration? the babel plugin is the last and only outlier, so the likelihood that we'll change the 23 other other plugins we've already completed migration for, before we complete the babel migration is pretty slim.

@LarsDenBakker
Copy link
Contributor

What's the status on this? rollup-plugin-babel 5.x is still on an alpha release. This is a vital plugin in the rollup ecosystem.

@Andarist
Copy link
Member Author

Andarist commented Mar 8, 2020

@LarsDenBakker I'm going to pick up working on this next week. Would appreciate ideas on #108 (comment)

@Andarist Andarist marked this pull request as ready for review April 19, 2020 09:40
@Andarist
Copy link
Member Author

@rollup/plugin-maintainers after quite a long time, way longer than I've anticipated 😢, I've got back to it, resolved all comments, updated docs and changelog. This is no longer a draft from my perspective - I would appreciate a review 🙏 so we can move this forward and finally publish it as @rollup/plugin-babel

@shellscape
Copy link
Collaborator

Thank you, and no worries on the time frame! I'll get to looking at this today!

@shellscape
Copy link
Collaborator

@Andarist I think we're good on this. I'll fix the pnpm conflict later today/tonight and then we'll merge. 🍻

This avoids fresh `pnpm install` problems where the build runs
before babel plugins are installed.
@shellscape
Copy link
Collaborator

@Andarist no matter what I try locally, I cannot get this to build:

./src/index.js → dist/index.js, dist/index.es.js...
[!] (plugin babel) Error: [BABEL] /Users/powella/code/rollup/plugins/packages/babel/src/index.js: Could not find plugin "proposal-numeric-separator". Ensure there is an entry in ./available-plugins.js for it. (While processing: "/Users/powella/code/rollup/plugins/packages/babel/node_modules/@babel/preset-env/lib/index.js")

Please take a look.

@Andarist
Copy link
Member Author

@shellscape fixed

@shellscape shellscape merged commit 440dbc4 into master Apr 26, 2020
@shellscape shellscape deleted the babel branch April 26, 2020 21:53
@shellscape
Copy link
Collaborator

@Andarist I noticed that 5.0.0-alpha.2 was the latest version on rollup-plugin-babel, but the plugin here is only 5.0.0-alpha.1. I also didn't see that you were in an alpha stage, so I'm not sure how to release this because we should release a stable version to archive rollup-plugin-babel.

I guess this is my fault for not looking at the old repo first. Please advise.

@Andarist
Copy link
Member Author

Oh, sorry for not mentioning this recently - my intention was this to be a major bump, so just release this as 5.0.0

@shellscape
Copy link
Collaborator

No worries at all. I'll do that tonight.

@enjikaka
Copy link

enjikaka commented Feb 10, 2021

Is this broken again? rollup/rollup-plugin-babel#360

I just tried making two outputs in Rollup, both with a plugin field with babel in them. Getting the same errors as in the issue above;

(!) The "load" hook used by the output plugin babel is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
(!) The "options" hook used by the output plugin babel is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.
(!) The "resolveId" hook used by the output plugin babel is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.

"@rollup/plugin-babel": "^5.2.3"
"rollup": "^2.38.5"

@Andarist
Copy link
Member Author

Is this broken again?

We don't know as you haven't really provided a repro case - there is a non-zero chance that you made some mistake. You could also try to actually debug the problem - the code is all there, on your machine, ready to be investigated.

@stevage
Copy link

stevage commented Apr 15, 2021

I have made a repro case that shows the same thing: https://replit.com/@stevage/rollup-plugin-repro

@Andarist
Copy link
Member Author

@stevage you are using the input plugin in the output plugin's position. Please refer to this doc if you want to use the output plugin: https://github.com/rollup/plugins/blob/master/packages/babel/README.md#running-babel-on-the-generated-code

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.