parcel: πŸ›Parcel do not transpile some ES6+ code in node_modules

Choose one: is this a πŸ› bug report or πŸ™‹ feature request?

πŸ›bug

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

// .babelrc
{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["IE 9"]
      }
    }]
  ],
}
// package.json
{
  "name": "pc",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "parcel-bundler": "^1.6.2"
  },
  "private": true,
  "scripts": {
    "build": "parcel build src/index.js"
  },
  "dependencies": {
    "sweetalert2": "^7.17.0"
  }
}
# command
$ yarn build

πŸ€” Expected Behavior

build result must have no arrow function in because I’m set target to IE 9 and IE 9 do not support arrow function.

😯 Current Behavior

I can find arrow function easliy in build result.

πŸ’ Possible Solution

use webpack (webpack@4 and babel@7)

πŸ”¦ Context

I tried to use babel-preset-env, babel-preset-latest, babel-plugin-es2015-arrow-function(blabla) but there is no effect.

πŸ’» Code Sample

import swal from 'sweetalert2';

(async () => {
  await swal('hello');
})().then();

🌍 Your Environment

Software Version(s)
Parcel parcel-bundler@1.6.2 and 1.7.0
Node v9.7.1
npm/Yarn yarn 1.5.1
Operating System macOS 10.13.3

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

If like me you came here trying to determine how to transpile linked packages in a lerna monorepo, let me save you some time clicking links.

The PR which added this feature is here.

The linked repository will need to have a source property defined in its package.json file. It will also need to have its own .babelrc file if you are using any babel transpiled language features in that package.

  1. Treat all files as source code, don’t change the resolution
{
  "main": "foo.js",
  "source": true
}
  1. When compiling from source, use bar.js as the entry point
{
  "main": "foo.js",
  "source": "bar.js"
}

3.When compiling from source, alias specific files

{
  "main": "foo.js",
  "source": {
    "./foo.js": "./bar.js",
    "./baz.js": "./yay.js"
  }
}
  1. When compiling from source, alias using glob patterns
{
  "main": "foo.js",
  "source": {
    "./lib/**": "./src/$1"
  }
}

I got it. I will make issue to sweetalert2.