Skip to content
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 does not transpile ES6+ codes in node_modules #7296

Closed
jeongtae opened this issue Nov 14, 2021 · 1 comment
Closed

Parcel does not transpile ES6+ codes in node_modules #7296

jeongtae opened this issue Nov 14, 2021 · 1 comment

Comments

@jeongtae
Copy link

🐛 bug report

🎛 Configuration (.babelrc, package.json, cli command)

{
  "name": "parcel-test",
  "version": "1.0.0",
  "browserslist": "> 1%, ie 11, not dead",
  "scripts": {
    "build": "parcel build ./src/index.js --no-optimize"
  },
  "devDependencies": {
    "parcel": "^2.0.1",
  },
  "dependencies": {
    "color-convert": "^2.0.1",
    "jsesc": "^3.0.2"
  }
}

🤔 Expected Behavior

All ES6 codes of the color-convert module must be transpiled to ES5 through the @parcel/transformer-js module. because the IE 11 browser is specified in the browserslist property in the package.json file as you can see above.

😯 Current Behavior

The ES6 specific statements and syntax(e.g. for..of statement of color-convert, arrow function syntax of jsesc) are not being transpiled to legacy ES5. So a SyntaxError is thrown on IE 11.

💁 Possible Solution

Use [email protected] which is deprecated. Parcel v1 seems can handle the package.json#engines property of the color-convert module to make decision to execute transpilation or not. When i edit the value of the engines#node property of color-convert module to more older version like >=0.0.1 then the module is not being transpiled to ES5 by Parcel v1.

🔦 Context

I tried to use Babel but there was no effect. And I read the source code of @parcel/transformer-js, I discovered targets value is not assigned when the target asset is not a source(assets.isSource). I'm not sure, but I think Parcel v2 does not transpile modern codes in external dependencies(in node_module directory) intentionally. Is it correct?

💻 Code Sample

src/index.js

import Convert from "color-convert";
console.log(Convert.rgb.hsl(140, 200, 100));

node_modules/color-convert/conversions.js:10

for (const key of Object.keys(cssKeywords)) {
	reverseKeywords[cssKeywords[key]] = key;
}

dist/index.js:758

for (const key of Object.keys($330224f6db11e147$exports))$d64509da21885dbc$var$reverseKeywords[$330224f6db11e147$exports[key]] = key;

🌍 Your Environment

Software Version(s)
Parcel 2.0.1
Node 16.9.1
npm/Yarn Yarn 1.22.11
Operating System macOS Big Sur 11.5.2 (Apple Silicon)
@jeongtae jeongtae changed the title Parcel does not transpile ES6+ codes in dependencies in node_modules Parcel does not transpile ES6+ codes in node_modules Nov 14, 2021
@mischnic
Copy link
Member

This is indeed getting worse as more packages move to newer syntax

Duplicate of #1655

I'm not sure, but I think Parcel v2 does not transpile modern codes in external dependencies(in node_module directory) intentionally. Is it correct?

Correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants