Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Doesn't generate inline source maps #60

Closed
manuelhuber opened this issue Oct 6, 2015 · 8 comments
Closed

Doesn't generate inline source maps #60

manuelhuber opened this issue Oct 6, 2015 · 8 comments

Comments

@manuelhuber
Copy link

When I try to run with the following tsconfig.json:
"compilerOptions": {
"module": "commonjs",
"inlineSourceMap": true,
"inlineSources": false,
"sourceMap": false
},
I get

ERROR in ./test/HelloWorldSpec.ts
Module build failed: SyntaxError: Unexpected token u
    at Object.parse (native)
    at transform (c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\dist\index.js:378:40)
    at c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\dist\index.js:407:24
    at tryCatcher (c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\promise.js:507:31)
    at Promise._settlePromiseAt (c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\promise.js:581:18)
    at Async._drainQueue (c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\async.js:128:12)
    at Async._drainQueues (c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (c:\Users\m.huber\_Projects\HelloWorldWebpack\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:367:17)

Turning inlinesourcemaps off and sourcemaps on works.
How can I get InlineSource Maps with this loader?

And sourceMaps don't seem to work with the source map loader at all.
https://github.com/webpack/source-map-loader
I get the error

WARNING in ./test/HelloWorldSpec.ts
Cannot find SourceMap 'HelloWorldSpec.js.map': Error: Cannot resolve 'file' or 'directory' ./HelloWorldSpec.js.map in c:\Users\m.huber\_Projects\HelloWorldWebpack\test

WARNING in ./src/hello-world.ts
Cannot find SourceMap 'hello-world.js.map': Error: Cannot resolve 'file' or 'directory' ./hello-world.js.map in c:\Users\m.huber\_Projects\HelloWorldWebpack\src

WARNING in ./src/goodbye-world.ts
Cannot find SourceMap 'goodbye-world.js.map': Error: Cannot resolve 'file' or 'directory' ./goodbye-world.js.map in c:\Users\m.huber\_Projects\HelloWorldWebpack\src
@raveclassic
Copy link

Ran into this issue when tried to disable sourcemaps completely.
Looks like when "sourceMap": false is present in tsconfig, JSON.parse in compiler tries to parse undefined - this is how an error Module build failed: SyntaxError: Unexpected token u appears.

@s-panferov
Copy link
Owner

@raveclassic thanks for your report. I'll fix this.

@raveclassic
Copy link

@s-panferov Thanks!
Besides could you please investigate into disabling sourcemaps in general?
In my current workflow I use typescript transpiling to es6 and then pass result to babel. Somehow it appeared today that sourcemaps from typescript does not suit anymore to babel and it fails with invalid mapping error when receiving inputSourceMap
Sure it's problem with babel or typescript, but nevertheless I failed trying to disable sourcemapping in awesome-typescript-loader.

TIA

@frapontillo
Copy link

I have the same issue, and something more with the following configuration:

{
    resolve: {extensions: ['', '.ts', '.js']},
    watch: watch,
    module: {
      preLoaders: [{test: /\.ts$/, exclude: /node_modules/, loaders: ['tslint-loader']}],
      loaders: [{test: /\.ts$/, exclude: /node_modules/, loaders: ['ng-annotate', 'awesome-typescript-loader']}]
    },
    output: {
      filename: 'output.js'
    }
}

With this configuration, the file is generated BUT there are multiple

//# sourceMappingURL=my.typescript.original.file.js.map

directives for each included transpiled module, while in the end there is a

//# sourceMappingURL=output.js.map

as it should be.
This leads to errors while processing the source maps, since all the first maps are never found (are they temporary during the transpilation process?) as only the last one is actually generated.

Then I tried to set ?sourceMap=false to see if the issue could be fixed and I got the same error as the one reported by @nelo112.

This is similar to webpack/webpack#273 and also causes SitePen/remap-istanbul#20.

@s-panferov
Copy link
Owner

All problems with source maps might gone in v0.15.3, please try it.

@krtr
Copy link

krtr commented Nov 25, 2015

At 0.15.3 and karma I'm still not getting sourcemaps at all with devtool: 'inline-source-map'.
capture

config:

 {
            resolve: {
                extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
            },
            output: {
                devtoolModuleFilenameTemplate: "../[resource-path]",
                devtoolFallbackModuleFilenameTemplate:"../[resource-path]"
            },
            devtool: 'inline-source-map',
            module: {
                loaders: [
                    {
                        test: /\.tsx?$/,
                        loaders: ['awesome-typescript-loader'],
                    },
                    {
                        test: /\.json?$/,
                        loaders: ['json-loader']
                    }
                ]
            }
           }

tsconfig:

{
  "compilerOptions": {
    "target": "es6",
    "sourceMap": true,
    "jsx": "react",
    "experimentalDecorators": true,
    "experimentalAsyncFunctions": true
  },
  "awesomeTypescriptLoaderOptions": {
    "useBabel": true,
    "useCache": false,
    "emitRequireType": false
  }
}

@frapontillo
Copy link

@s-panferov I can confirm the fix, thanks!

@anil1712
Copy link

How to configure the same for react native?

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

No branches or pull requests

6 participants