Parcel: Parcel does not respect tsconfig.json

Created on 10 Aug 2018  路  5Comments  路  Source: parcel-bundler/parcel

馃悰 bug report

  • I set up a project with parcel and tsconfig.json according to the doc. The project run but tsconfig is not respected. Specifically, it was target option

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

tsconfig.json

{
  "compilerOptions": {
    "target": "es2017",
    "module": "es2015",
    "moduleResolution": "node",
    "lib": [
      "es2017",
      "dom"
    ],
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "outDir": "./",
    // Only necessary because @types/uglify-js can't find types for source-map
    "skipLibCheck": true,
    "baseUrl": "."
  },
  "include": [
    "custom_typings/**/*.ts",
    "src/**/*.ts"
  ],
  "exclude": []
}

馃 Expected Behavior


parcel should respect option in tsconfig

馃槸 Current Behavior

parcel does not respect option in tsconfig

馃拋 Possible Solution

馃敠 Context


I am trying to test lit-html and lit-element with typescript which requires some es2017 target

馃捇 Code Sample

index.ts

import {LitElement} from "@polymer/lit-element";
import {TemplateResult, html} from "lit-html";

export class App extends LitElement {
  protected _render(_props: object): TemplateResult {
    return html`
<style>
    .red { color: red; }
</style>
<div class='red'>hello App</div>
`;
  }
}
customElements.define('my-element', App)

index.html

<html>
<body>
  <script src="./index.ts"></script>
</body>
</html>

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | latest
| Node | 8
| npm/Yarn | npm
| Operating System | mac

Waiting Question

Most helpful comment

most of the config file is overwritten by parcel, as we can't respect things like output directory in tsconfig. (It might conflict with other code and is probably unwanted behaviour anyways).

For target, babel-preset-env gets run over every asset parcel processes, to ensure browser or node compatibility. (Especially for node modules).

There is a similar issue that requests for this to be removed, but there has been a huge discussion about this at the beginning of parcel and this seemed like the best solution at the time.

You can configure browsers field in package.json to something more modern, to have ES2017. See parcels docs: https://en.parceljs.org/transforms.html#default-babel-transforms

All 5 comments

Please fill in the bug report entirely, the config field is also there for tsconfigs...

@DeMoorJasper , I updated and provided more info. Please let me know if anything else is needed.

most of the config file is overwritten by parcel, as we can't respect things like output directory in tsconfig. (It might conflict with other code and is probably unwanted behaviour anyways).

For target, babel-preset-env gets run over every asset parcel processes, to ensure browser or node compatibility. (Especially for node modules).

There is a similar issue that requests for this to be removed, but there has been a huge discussion about this at the beginning of parcel and this seemed like the best solution at the time.

You can configure browsers field in package.json to something more modern, to have ES2017. See parcels docs: https://en.parceljs.org/transforms.html#default-babel-transforms

I'm not sure it changed in the past year, but the link provided by @DeMoorJasper has zero information about target browsers.

@ranisalt Seems like that paragraph was moved: https://en.parceljs.org/javascript.html#default-babel-transforms

Was this page helpful?
0 / 5 - 0 ratings