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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable automatic babel compilation #1207

Closed
bfred-it opened this Issue Apr 17, 2018 · 10 comments

Comments

Projects
None yet
8 participants
@bfred-it

bfred-it commented Apr 17, 2018

Choose one: is this a 馃悰 bug report or 馃檵 feature request?

馃悰 bug report

The site mentions:

Parcel automatically runs these transforms when it finds a configuration file (e.g. .babelrc, .postcssrc) in a module.

But Parcel is automatically running my JS file through babel and "breaking the code" (1. finds await; 2. turns it into regeneratorRuntime; 3. doesn't include regeneratorRuntime)

Does Parcel require a babel configuration or not? The docs make it sounds like one has to install and configure babel-preset-env but apparently it does so without any config.

Moreover, babel-preset-env is still run even if I provide this .babelrc configuration:

{"presets": []}

The only thing that worked:

# .browserlistrc
last 1 Chrome version

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

No configuration:

npm run watch
{
  "license": "MIT",
  "scripts": {
    "watch": "parcel index.html"
  },
  "dependencies": {},
  "devDependencies": {
    "parcel-bundler": "^1.7.1"
  }
}

node_modules is clean and up to date. No babel is installed.

馃 Expected Behavior

No babel processing

馃槸 Current Behavior

JS file is transformed by babel from await/async into regeneratorRuntime code.

馃拋 Possible Solution

  • Fix docs; or
  • Disable unconfigured babel

馃敠 Context

馃捇 Code Sample

馃實 Your Environment

Software Version(s)
Parcel 1.6.2
Node v9.8.0
npm/Yarn 5.8.0
Operating System macOS 10.13.4
@DeMoorJasper

This comment has been minimized.

Show comment
Hide comment
@DeMoorJasper

DeMoorJasper Apr 17, 2018

Member

By default it runs babel-preset-env

Member

DeMoorJasper commented Apr 17, 2018

By default it runs babel-preset-env

@bfred-it

This comment has been minimized.

Show comment
Hide comment
@bfred-it

bfred-it Apr 17, 2018

There are two issues then:

  1. Docs are incorrect unclear (it does happen automatically "in a module", but what about the current project?)
  2. Custom .babelrc (that excludes any presets) isn't followed

bfred-it commented Apr 17, 2018

There are two issues then:

  1. Docs are incorrect unclear (it does happen automatically "in a module", but what about the current project?)
  2. Custom .babelrc (that excludes any presets) isn't followed
@fathyb

This comment has been minimized.

Show comment
Hide comment
@fathyb

fathyb Apr 17, 2018

Member

I had similar problems, and to be honest sometimes I feel like it causes more troubles than it solves. IMO we should only use babel-preset-env if there is a browserlist or similar field in package.json of the project or module. If the user don't ask for await to be transpiled then it should not. This may be resolved by the coming source feature though.

As a workaround you can use last 1 Chrome version as targets.browsers :

  • .babelrc
{
    "presets": [
        ["env", {
            "targets": {
                "browsers": ["last 1 Chrome version"]
            }
        }]
    ]
}
Member

fathyb commented Apr 17, 2018

I had similar problems, and to be honest sometimes I feel like it causes more troubles than it solves. IMO we should only use babel-preset-env if there is a browserlist or similar field in package.json of the project or module. If the user don't ask for await to be transpiled then it should not. This may be resolved by the coming source feature though.

As a workaround you can use last 1 Chrome version as targets.browsers :

  • .babelrc
{
    "presets": [
        ["env", {
            "targets": {
                "browsers": ["last 1 Chrome version"]
            }
        }]
    ]
}
@kadmil

This comment has been minimized.

Show comment
Hide comment
@kadmil

kadmil May 4, 2018

Hey guys! Was stuck by this one yesterday while trying to use fast-async instead of transform-regenerator for faster async functions. Looks like parcel doesn't respect project's .babelrc file, as running transforms with babel-cli does the trick.

kadmil commented May 4, 2018

Hey guys! Was stuck by this one yesterday while trying to use fast-async instead of transform-regenerator for faster async functions. Looks like parcel doesn't respect project's .babelrc file, as running transforms with babel-cli does the trick.

@laosb

This comment has been minimized.

Show comment
Hide comment
@laosb

laosb May 6, 2018

@kadmil Hit this too.

laosb commented May 6, 2018

@kadmil Hit this too.

@laosb

This comment has been minimized.

Show comment
Hide comment
@laosb

laosb May 6, 2018

I'm suggesting using user-defined preset if they defined presets. Don't merge.

laosb commented May 6, 2018

I'm suggesting using user-defined preset if they defined presets. Don't merge.

@psypersky

This comment has been minimized.

Show comment
Hide comment
@psypersky

psypersky Jul 5, 2018

This zero config thing is turning out more confusing that it should be, it is not zero config, it is a collection of defaults configs that can be overwritten but we don't know the defaults so we have to dig in the github issues for answers :( maybe just better docs?

psypersky commented Jul 5, 2018

This zero config thing is turning out more confusing that it should be, it is not zero config, it is a collection of defaults configs that can be overwritten but we don't know the defaults so we have to dig in the github issues for answers :( maybe just better docs?

@DeMoorJasper

This comment has been minimized.

Show comment
Hide comment
@DeMoorJasper

DeMoorJasper Jul 5, 2018

Member

Feel free to open a PR or issue with improvement suggestions @psypersky https://github.com/parcel-bundler/website

Member

DeMoorJasper commented Jul 5, 2018

Feel free to open a PR or issue with improvement suggestions @psypersky https://github.com/parcel-bundler/website

fathyb referenced this issue Jul 25, 2018

Use esnext target with TypeScript and scope hoist (#1781)
Should bring a noticeable size improvement on big TypeScript apps
@SuperOP535

This comment has been minimized.

Show comment
Hide comment
@SuperOP535

SuperOP535 Aug 3, 2018

It transpiles using babel even if there is no .babelrc so this is a bug. The website should not be changed, the bundler should be

SuperOP535 commented Aug 3, 2018

It transpiles using babel even if there is no .babelrc so this is a bug. The website should not be changed, the bundler should be

@devongovett

This comment has been minimized.

Show comment
Hide comment
@devongovett

devongovett Aug 3, 2018

Member

This is not a bug, it is a feature and it has been discussed at length. Going to lock this conversation. Please open a new issue if you have an actual bug.

Member

devongovett commented Aug 3, 2018

This is not a bug, it is a feature and it has been discussed at length. Going to lock this conversation. Please open a new issue if you have an actual bug.

@parcel-bundler parcel-bundler locked and limited conversation to collaborators Aug 3, 2018

@devongovett devongovett closed this Aug 3, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.