I was trying to use Parcel together with @babel/preset-env to create a bundle to run on ie 11. In my source code I had a call to Object.assign. After build the code fails running on ie with the following mesage Object doesn't support property or method 'assign'.
I have created a repo for reproducing the bug here: https://github.com/slowselfip/object-assign-ie11-polyfill-parcel
{
"presets": [
[
"@babel/preset-env",
{
"debug": true,
"targets": {
"ie": "11"
},
"useBuiltIns": "usage"
}
]
]
}
{
"name": "example",
"version": "1.0.0",
"description": "Object assign polyfill example",
"main": "./src/index.html",
"scripts": {
"build:webpack": "npm run clean && webpack --mode production",
"build:parcel": "npm run clean && parcel build $npm_package_main",
"clean": "rimraf dist/"
},
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.5",
"babel-loader": "^8.0.4",
"html-webpack-plugin": "^3.2.0",
"parcel-bundler": "^1.10.3",
"rimraf": "^2.6.2",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2"
}
}
I expect it to run on ie 11 with a polyfilled Object.assign.
Code fails running on ie with the following mesage Object doesn't support property or method 'assign'
No idea, sorry.
For convenience It would be nice to be able to rely on the useBuiltIn without the need of manually adding polyfills. Also, my hopes is that this helps in fixing the bug.
https://github.com/slowselfip/object-assign-ie11-polyfill-parcel
Mac
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | ^1.10.3
| Node | v10.10.0
| npm/Yarn | 6.4.1
| Operating System | MacOS High Sierra 10.13.6
Some debug information:
When only processed with babel, npx babel src/index.js the output contains the line require("core-js/modules/es6.object.assign"); but in the Parcel bundle that module is not present.
If that line is added explicitly to the source file the module will be present in the bundle.
this seems related to #2304, the bundler doesn't seem to be applying the configuration in a recursive / deep manner
I'm having the same issue, and it looks like regardless of what you set in the .babelrc, it is being changed to 'entry', here:
https://github.com/parcel-bundler/parcel/blob/master/packages/core/parcel-bundler/src/transforms/babel/env.js#L56
I tried changing that line from 'entry' to 'usage', and it worked. It might need a PR to make this actually respect the configuration...
nice catch @tjwlucas it seems that a lot of stuff are hardcoded irrespective of babelrc
Sounds like this will be solved in Parcel 2 by #2350
indeed, it looks like it will fix those dangling issues with configs being ignored / overridden
what will be the workaround for 1.11.0?
@mallim there's none, you need to fork the project, fix the code, then use your fork git address as the "version" field in npm (did this with two ES7+ projects)
use [email protected] stable version
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.
Most helpful comment
I'm having the same issue, and it looks like regardless of what you set in the .babelrc, it is being changed to 'entry', here:
https://github.com/parcel-bundler/parcel/blob/master/packages/core/parcel-bundler/src/transforms/babel/env.js#L56
I tried changing that line from 'entry' to 'usage', and it worked. It might need a PR to make this actually respect the configuration...