Parcel: Parcel ignores .babelrc file

Created on 4 Aug 2019  ยท  3Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

.babelrc

{
  "presets": [
    ["@babel/preset-env", {
      "targets": [
        "> 1%",
        "IE 9",
        "not dead"
      ]
    }]
  ],
  "yo!": []
}


package.json

{
  "name": "passfather-build",
  "version": "1.0.0",
  "description": "Build passfather package to most compatibility with browsers and Node.js",
  "author": "Evgeny Vyushin <[email protected]> (https://github.com/vyushin)",
  "contributors": [
    "Evgeny Vyushin <[email protected]> (https://github.com/vyushin)"
  ],
  "maintainers": [
    "Evgeny Vyushin <@vyushin.ru> (https://github.com/vyushin)"
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/vyushin/passfather/build"
  },
  "scripts": {
    "prebuild": "rm -rf ../dist",
    "build": "parcel build ../src/passfather.js --out-dir ../dist/ --out-file passfather.min.js --target browser --no-source-maps --no-cache --global passfather",
    "prepublish": "npm run build"
  },
  "bugs": {
    "url": "https://github.com/vyushin/passfather/issues"
  },
  "homepage": "https://github.com/vyushin/passfather",
  "main": "./index.js",
  "license": "MIT",
  "keywords": [],
  "directories": {
    "doc": ""
  },
  "devDependencies": {
    "parcel": "^1.12.3"
  }
}

cli comman

npx parcel build ../src/passfather.js --out-dir ../dist/ --out-file passfather.min.js --target browser --no-source-maps --no-cache --global passfather

๐Ÿค” Expected Behavior

Parcel should make an error because .babelrc is invalid! If Parcel doesn't say anything, how can I be sure that it is using .bebelrc?

๐Ÿ˜ฏ Current Behavior

Parcel works silently, secretly, whithout messaging any errors.

๐Ÿ’ Possible Solution

Don't ignore .babelrc. Original Babel compiler always creates arrors if .babelrc is invalid. Try to use @babel/core. Something like this:

const { transformFileAsync } = require('@babel/core');
transformFileAsync('./test.js', { 'yo!': [] });

you'll see in terminal that property 'yo!' is invalid.

๐Ÿ”ฆ Context

๐Ÿ’ป Code Sample

https://github.com/vyushin/passfather/tree/master/build

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.3
| Node | 12.4.0
| npm/Yarn | NPM 6.10.2
| Operating System | Windows 10 x64

Bug โœจ Parcel 2

Most helpful comment

Parcel currently merges its default babel configuration (preset-env + jsx ...) with the provided babelrc. That could explain this behaviour (Parcel 2 will just use the babelrc without changes).

All 3 comments

Parcel currently merges its default babel configuration (preset-env + jsx ...) with the provided babelrc. That could explain this behaviour (Parcel 2 will just use the babelrc without changes).

@mischnic, thanks for answer. Waiting for Parcel 2 :)

Parcel 2 prints:
Error: Unknown option: .yo!. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.

Was this page helpful?
0 / 5 - 0 ratings