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

Parcel 2: Babel Transformer #2350

Merged
merged 4 commits into from
Dec 11, 2018
Merged

Parcel 2: Babel Transformer #2350

merged 4 commits into from
Dec 11, 2018

Conversation

devongovett
Copy link
Member

This is the babel transformer plugin for Parcel 2.

Changes to core

  • The getConfig and getPackage Asset methods now mutate the asset by adding connected files directly rather than returning them alongside the config. Now they just return the config itself and update the asset to include those file references. This is much easier to use in practice, and the connected files are already propagated along the pipeline.
  • The above means the cache entry doesn't need connected files directly anymore since they are all contained within assets instead.
  • getConfig can be passed options including packageKey, which is used to get a key from package.json (e.g. babel), and parse which can be set to false to disable automatic parsing of the config file (used for .browserslist files).

Differences from Parcel 1

  • .babelrc config for babel-preset-env is no longer merged with our internally generated one. Instead, it overrides the internally generated config. This lets the user have more control when they need it.
  • We no longer consider the engines.node field in package.json when compiling for a browser target. This was causing issues for people: Error while rendering map with mapbox-gl: "_typeof is not defined" #1128
  • We use the useBuiltIns: 'usage' mode in babel-preset-env by default. This means that babel-polyfill will be included automatically based on usage of features in code.
  • We no longer look in .babelrc files in node_modules to find browser/node target information.

…o babel-transformer

# Conflicts:
#	packages/core/core/src/TransformerRunner.js
#	packages/core/types/index.js
#	packages/transformers/terser/src/TerserTransformer.js
connectedFiles are propogated to child assets in the pipeline, so no need to have them at the top-level in the cache entry anymore.
@jamiebuilds
Copy link
Member

You're trying to support both Babel 6 and 7 simultaneously in the same transform?

@devongovett
Copy link
Member Author

Mmm yeah... that was copied from Parcel 1. I guess we could separate them out. There is a lot shared there though, like the config loading/generation.

@jamiebuilds
Copy link
Member

Didn't know that, it just seems a bit odd but probably fine

@devongovett
Copy link
Member Author

Going to merge this for now. We can always refactor it later.

@devongovett devongovett merged commit 14a5cd7 into v2-work-so-far Dec 11, 2018
@devongovett devongovett deleted the babel-transformer branch December 11, 2018 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants