Parcel: Source mapping not working with typescript

Created on 23 Mar 2018  路  3Comments  路  Source: parcel-bundler/parcel

Choose one: a 馃悰 bug report

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


package.json

{
  "name": "vue-ts-parcel",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "dev": "rm -rf .cache && rm -rf dist && parcel src/index.html",
    "build": "parcel build src/index.html"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "vue": "^2.5.16",
    "vue-class-component": "^6.2.0",
    "vue-property-decorator": "^6.0.0",
    "vue-template-compiler": "^2.5.16"
  },
  "devDependencies": {
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "parcel-bundler": "^1.6.2",
    "parcel-plugin-typescript": "^0.7.0",
    "parcel-plugin-vue": "^1.5.0",
    "tslint": "^5.9.1",
    "typescript": "^2.6.2",
    "typescript-eslint-parser": "^14.0.0"
  }
}

tsconfig.json

{
  "compilerOptions": {
      "module": "es2015",
      "noImplicitAny": true,
      "removeComments": true,
      "moduleResolution": "node",
      "preserveConstEnums": true,
      "sourceMap": true,
      "strict": true,
      "target": "es5",
      "experimentalDecorators": true
  },
  "include": [
      "./src/**/*"
  ],
  "exclude": [
      "node_modules",
      "**/*.spec.ts"
  ],
  "parcelTsPluginOptions": {
    // If true type-checking is disabled
    "transpileOnly": false
  }
}

馃 Expected Behavior

With the latest version of parcel 1.6.2 , I got parcel index.html working with the js and map file generated in dist. I was expecting the source map working as expected in browser, but it did not.

馃槸 Current Behavior

The comment pointing to the map file was missing in generated bundle js file. But it was not missing in another project without typescript.

Later I found the source code here removes the comment of "source map URL" for ts asset, and I want to know why.

https://github.com/parcel-bundler/parcel/blob/800268435a8465660f8569f7ba30a94c2b1f75a1/src/assets/TypeScriptAsset.js#L41

馃拋 Possible Solution

馃敠 Context

I want to make source map working with typescript. Is this behavior intended? Is this a bug? And how can I get it works?

馃捇 Code Sample

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.6.2
| Node | 8.9.3
| Yarn | 1.3.2
| Operating System | Mac OSX

Most helpful comment

@DeMoorJasper parcel-plugin-vue was responsible, just so you know as you're working on the Vue support

All 3 comments

Parcel takes care of adding source map URL, so we remove it in the typescript parser.

However this is a parcel-plugin-typescript and unrelated to parcel. (The parser used in parcel is ignored and instead the one from parcel-plugin-typescript is used in your case)

@DeMoorJasper parcel-plugin-vue was responsible, just so you know as you're working on the Vue support

@fathyb Thanks for letting me know, I'll make sure sourcemaps work properly in the official vue support

Was this page helpful?
0 / 5 - 0 ratings