plugin-typescript icon indicating copy to clipboard operation
plugin-typescript copied to clipboard

Source map files have incorrect path locations

Open pietschy opened this issue 8 years ago • 3 comments

Hi there, I'm getting the wrong path information being generated in my source map files. Details are:

Versions:

[email protected] [email protected] Dev [email protected] [email protected] (and I also tried with 2.2.0 with the same outcome)

Config

  • I'm using jspm bundle app ../public/frontend --source-map-contents
  • my jspm.config.js file:
paths: {
    "github:": "jspm_packages/github/",
    "npm:": "jspm_packages/npm/",
  },
  browserConfig: {
    "baseURL": "/frontend"
  },
  transpiler: "ts",
  typescriptOptions: {
    "tsconfig": true
  },
packages: {
    "app": {
      "defaultExtension": "ts",
      "main": "bootstrap.js",
      "meta": {
        "*.ts": {
          "loader": "ts"
        },
        "*.css": {
          "loader": "text"
        },
        "*.html": {
          "loader": "text"
        },
        "*.js": {
          "loader": "ts"
        }
      }
    },
 etc....
  • my tsconfig.json file:
"compilerOptions": {
    "allowJs": true,
    "module": "es2015",
    "target": "es5",
    "moduleResolution": "classic",
    "noImplicitAny": false,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "rootDirs": [  /** these correspond to my jspm package entries **/
      "./apiActions",
      "./app",
      "./components",
      "./common",
      "./controlPanelApp",
      "./pectin",
      "./place",
      "./tests/spec"
    ],
   etc... 

Result

The sources: entry in app.map.js has:

  • files from jspm_packages at the correct path. .i.e
"../../frontend/jspm_packages/npm/[email protected]/helpers/isPrimitive.js",
  • the first of my source files in the correct location
"../../frontend/app/templates.js",
  • but the remainder of files from my packages are all at the root, i.e.
"../../frontend/clock.module.ts",

(it should be at ../../frontend/common/clock/clock.module.ts)

Any ideas?

pietschy avatar Feb 20 '17 00:02 pietschy

I think this could be due to the rootDirs option, what exactly is it for? As this setting is related to module resolution, and runtime module resolution is handled entirely by systemjs, it may be that the plugin should not pass this option through when transpiling files.

Have you tried using the paths option instead?

frankwallis avatar Feb 26 '17 14:02 frankwallis

Also see https://github.com/Microsoft/TypeScript/issues/12246 as it sounds very similar.

frankwallis avatar Feb 26 '17 14:02 frankwallis

Excellent, thanks for the pointers. I'll dig a bit further into the documentation and make sure I'm not just confused about how it should work.

pietschy avatar Feb 27 '17 01:02 pietschy