Parcel: .babelrc config's ignored for production build

Created on 9 Feb 2018  路  4Comments  路  Source: parcel-bundler/parcel

Bug report

It looks like it ignores .babelrc config when I try to build an app. for production.

馃帥 Configuration (.babelrc, package.json, cli command)

.babelrc

{
  "plugins": ["@babel/plugin-transform-object-assign"]
}

ts

const t = Object.assign({}, {a: 1})

package.json

"scritps": {
"start": "cross-env NODE_ENV=development parcel index.html",
"build": "cross-env NODE_ENV=production parcel build src/main.ts --out-dir build/ --no-minify",
}

So, if I use development mode, all things look good, and Object.assign is polyfilled in the dist bundled file [hash].js:

...
var _extends = Object.assign || function (target) { ...
...
r = _extends({}, { a: 1 });
...

But, when I start build script, I getting no transpiled code in the result file:

r = Object.assign({}, { a: 1 });

馃 Expected Behavior

production build should extend Object.assign

馃槸 Current Behavior

production build ignore plugin, described in the .babelrc

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.2.0
| Node | 8.4.0
| Yarn | 1.0.2
| Operating System | macOS high Sierra 10.13.2
| Typescript | 2.6.2

Most helpful comment

Did you by chance create your .babelrc at the very end? What happens if you build with --no-cache or manually just rm -r .cache/. I just experienced something similar after adding my .babelrc as the final step. It turns out that configuration changes are not picked up with the cache, e.g., https://github.com/parcel-bundler/parcel/issues/509#issuecomment-355896029

All 4 comments

Did you by chance create your .babelrc at the very end? What happens if you build with --no-cache or manually just rm -r .cache/. I just experienced something similar after adding my .babelrc as the final step. It turns out that configuration changes are not picked up with the cache, e.g., https://github.com/parcel-bundler/parcel/issues/509#issuecomment-355896029

@mrcoles thanks I was having this problem.

yep, looks like .cache was an issue. Now it works fine for me, thanks!

Btw, I created #777 about this. I looked a little into how it could be solved, seems like a hacky approach would be to just include in the cache the existence-or-not of each file: [.babelrc, .babelrc.js, .postcssrc, .postcssrc.js, postcss.config.js, .browserslistrc, .posthtmlrc, posthtml.config.js] and if the exists-or-not state changes for any, invalidate the cache. (put discussion in that issue, not here)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzimmek picture jzimmek  路  3Comments

philipodev picture philipodev  路  3Comments

humphd picture humphd  路  3Comments

oliger picture oliger  路  3Comments

Niggler picture Niggler  路  3Comments