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

Untransformed files for build with .babelrc #2304

Open
pocesar opened this issue Nov 19, 2018 · 5 comments
Open

Untransformed files for build with .babelrc #2304

pocesar opened this issue Nov 19, 2018 · 5 comments

Comments

@pocesar
Copy link
Contributor

pocesar commented Nov 19, 2018

🐛 bug report

Currently, not all files are going through babel transforms, even though it's explicitly set in .babelrc file.

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

package.json important parts:

  "devDependencies": {
    "@babel/core": "^7.1.6",
    "@babel/plugin-transform-block-scoping": "^7.1.5",
    "@babel/plugin-transform-classes": "^7.1.0",
    "@babel/plugin-transform-runtime": "^7.1.0",
    "@babel/polyfill": "^7.0.0",
    "@babel/preset-env": "^7.1.6",
  }

.babelrc

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "entry",
        "targets": {
          "ie": 7,
          "safari": 5
        },
        "forceAllTransforms": true,
        "ignoreBrowserslistConfig": true
      }
    ]
  ]
}

🤔 Expected Behavior

properly transformed node_modules that has a const and class keywords

😯 Current Behavior

Generated build has un-transformed node_modules

image
N.B.: const and class keywords from the moip-sdk-js

💁 Possible Solution

🔦 Context

Build one app.js from many legacy code files using:

parcel build --public-url /assets/dist/ -o ./public/dist/app.js -d ./public/dist _entry.js

💻 Code Sample

'use strict'

import '@babel/polyfill'

const jquery = require('jquery')

const jQuery = jquery.noConflict()
const $ = jQuery

window['$'] = window['jQuery'] = jQuery

import 'typeface-roboto'
import '@fortawesome/fontawesome-free/css/all.css'
import 'bootstrap/dist/css/bootstrap.css'
import 'select2/dist/css/select2.css'
import 'bootstrap-fileinput/css/fileinput.css'
import './public/css/main.scss'
import './public/css/loader.css'

import MoipSdkJs from 'moip-sdk-js'
window['MoipSdkJs'] = MoipSdkJs
import JSEncrypt from 'jsencrypt'
window['MoipSdkJs'].MoipCreditCard.setEncrypter(JSEncrypt, 'node')

🌍 Your Environment

Software Version(s)
Parcel 1.10.3
Node v10.12.0
npm 6.4.1
Operating System Windows 10 x64
@DeMoorJasper
Copy link
Member

Node modules don't get transformed unless they define a target

Related issues/PRs: #2073 #1887

@pocesar
Copy link
Contributor Author

pocesar commented Dec 1, 2018

well, that didn't help at all, I had to manually fork the offending repo and convert to Typescript then compile down to ES5. since parcel is "zero conf", I would expect it to work as-is, even though I did set to do all the transforms, everywhere, in the babelrc

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Dec 1, 2018

Setting the target in the module's package.json would have been easier.
I'm a big fan of introducing this as you can see I wrote that initial PR. But there has been some large discussion about not doing this at the start of Parcel. So it will be hard to find a solution to be able to do this without slowing down parcel or causing unwanted side-effects.

Feel free to come up with ideas on how to implement it without making parcel slower for users who are happy with the current behaviour and without introducing new cli flags.

@pocesar
Copy link
Contributor Author

pocesar commented Dec 3, 2018

since parcel makes a bridge of many existing solutions (like babel, postcss, etc), it would just make sense that setting something at the project root to cascade everywhere. as showin in #2262 (comment) there are some hardcoded stuff in here that can be pretty confusing if you're trying to enforce something with config files

@DeMoorJasper
Copy link
Member

@pocesar that was to prevent breaking changes with Parcel 1, it could have probably been overwritable though

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

No branches or pull requests

2 participants