Open fregante opened 4 years ago
I looked into this β in v2, we do pass an accurate config to Babel when we transform it, however we don't pass the babel config when we generate β which is where I imagine the comments
option is used. Right now we only resolve an asset's Babel config in the Babel transformer, and generate
can be called on any transformer that supports the AST depending on the pipeline order.
We'll need to get the babel config to whichever transformer ends up generating the asset code. Should we have an API for a transformer to expose options to be available to generation, independent of which transformer generates?
cc @padmaia @devongovett
I'd like to add on that "env" also does not work. (parcel-bundler ^1.12.4)
{
"presets": ["@babel/preset-env"],
"env": {
"production": {
"plugins": ["transform-remove-console"]
}
}
}
Has there been a fix or a hack that people have used to get around this?
Parcel 2 doesn't seem to be respecting a good portion of my .babelrc
config. Is there some other pattern I should be following?
{
"presets": [
"@parcel/babel-preset-env",
"@babel/preset-typescript",
["minify", { "builtIns": false }] // ignored?
],
"plugins": [
"@babel/plugin-proposal-class-properties",
[
"@babel/plugin-proposal-decorators",
{
"decoratorsBeforeExport": true
}
]
],
"compact": true, // ignored?
"comments": false // ignored?
}
π bug report
Only
presets
andplugins
are considered from babel's config (package.json'sbabel
and.babelrc
). Other keys likecomments
are completely ignored.This is the relevant piece of code in v1 and in v2:
https://github.com/parcel-bundler/parcel/blob/f01437e7f646f4aa74a5d3cf48ed7c4f21822352/packages/transformers/babel/src/config.js#L177-L185
Notice how only
presets
andplugins
are taken from theconfig
variable.π Configuration (.babelrc, package.json, cli command)
π€ Expected Behavior
Configuration shouldn't be ignored, comments should be omitted (without enabling full-on minification)
π― Current Behavior
The configuration is ignored and comments are still in the files.
π Possible Solution
Include all keys when merging configs
π¦ Context
I want to use babel to package my browser extensions, which don't accept minified files. Dropping comments saves some bytes without enabling full-on minification.
π Your Environment