-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 removes @babel/preset-env configuration #3216
Comments
Oddly enough, repeating configuration in
|
To add: the same bug exists when configuring babel in |
Noticing this issue as well. The workaround to use Is there a better way of handling this while a fix is being developed? |
I am trying to get the presets and corejs to work on this as well, has any progress been made or do I still need to use the hack of development and production? |
After a few hours going down the rabbit hole and not finding a solution, here are my findings, maybe someone else finds them useful. getBabelConfig will get the Then removes all your env settings if it finds browserlist targets. The discongruity of running parcel with The code is a bit convoluted to me. I wished parcel would stop it's "magic" if it detects a HTH |
And now you know why we do exactly that in Parcel 2 😄 |
@mischnic awesome. I already know I can do more things with |
Not so simple. I'm trying to use
But it seems to ignore the Edit: The offending code seems to be this: Where I don't know why this happens, the documentation clearly states that parcel uses And it is clear that parcel is not reading the By the way, |
@ranisalt I think you actually want to pass |
@mischnic I tried every combination I could think of. Right now I'm trying this: {
"presets": ["@parcel/babel-preset-env", ["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": [
"@parcel/babel-plugin-transform-runtime",
["@babel/plugin-transform-react-jsx", {
"runtime": "automatic"
}],
"@babel/plugin-transform-typescript"
]
} But it does not work still. It would be so helpful to know what are the defaults that Parcel uses, but I could not find it anywhere... |
This works correctly for me: package.json {
"dependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-react": "^7.12.10",
"@parcel/babel-preset-env": "^2.0.0-nightly.556",
"parcel": "^2.0.0-nightly.554",
"react": "^17.0.1"
}
} .babelrc: {
"presets": [
"@parcel/babel-preset-env",
["@babel/preset-react", { "runtime": "automatic" }]
]
} index.js: function App() {
return <div>1</div>;
}
console.log(App);
The default config is generated here:
|
Try to put Typescript there: import { FC } from 'react';
export const App: FC = () => {
return <div>1</div>;
}
console.log(App); |
This babelrc works with an {
"presets": [
"@parcel/babel-preset-env",
"@babel/preset-typescript",
["@babel/preset-react", { "runtime": "automatic" }]
]
} |
Oh, of course it will, you are never executing the JSX transform itself. I think using |
The jsx runtime is correctly bundled, if that's what you meant. |
If you are using a monorepo, read the answer below.
{
/* "presets": [ */
/* "@parcel/babel-preset-env", */
/* ["@babel/preset-typescript", { isTSX: true }], */
/* ["@babel/preset-react", { "runtime": "automatic" }] */
/* ] */
}
|
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
🐛 bug report
I noticed that despite configuring my .babelrc like so:
Object.entries
does not have the polyfill added on usage.🎛 Configuration (.babelrc, package.json, cli command)
.babelrc
🤔 Expected Behavior
useBulitIns
andcorejs
options are not ignored.😯 Current Behavior
useBulitIns
andcorejs
options are ignored.I investigated a lot in parcel-bundler source code and here's what I found.
In
config.js
, in getBabelConfig, I added a log:which resulted in console output:
So far so good. At the end of getBabelConfig I added log again:
and to my surprise, my preset was gone:
💁 Possible Solution
Commenting out these lines from config.js:
resulted in Babel receiving proper configuration & adding core-js polyfills to my file as desired.
If I understand source code correctly, these lines are there because we expect
getEnvConfig
to load@babel/preset-env
in some special way. So my best guess is thatgetEnvConfig
does something incorrectly, resulting in@babel/preset-env
ignored.🌍 Your Environment
The text was updated successfully, but these errors were encountered: