Ionic-app-scripts: ionic_source_map_type eval fails in --prod

Created on 27 Apr 2017  路  8Comments  路  Source: ionic-team/ionic-app-scripts

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/
http://ionicworldwide.herokuapp.com/

Short description of the problem:

ionic_source_map_type eval fails in --prod

What behavior are you expecting?

ionic_source_map_type eval should not fail in --prod

Steps to reproduce:

  1. Set config in package.json
  "config": {
    "ionic_source_map_type":"eval"
  }
  1. do a --prod build with v1.3.5-201704271445
Anku@Ankushs-MacBook-Pro:ionic2-mosum$ ionic build ios --prod

> ionic2-mosum@ ionic:build /Users/Anku/Documents/IdeaProjects/ionic2-mosum
> ionic-app-scripts build "--prod"

[09:20:37]  ionic-app-scripts 1.3.5-201704271445 
[09:20:37]  build prod started ... 
[09:20:37]  clean started ... 
[09:20:37]  clean finished in 2 ms 
[09:20:37]  copy started ... 
[09:20:37]  ngc started ... 
[09:20:45]  ngc finished in 8.28 s 
[09:20:45]  preprocess started ... 
[09:20:45]  deeplinks started ... 
[09:20:45]  deeplinks finished in 363 ms 
[09:20:45]  optimization started ... 
[09:20:45]  copy finished in 8.78 s 
[09:20:54]  optimization finished in 8.25 s 
[09:20:54]  preprocess finished in 8.62 s 
[09:20:54]  webpack started ... 
[09:21:55]  webpack finished in 61.16 s 
[09:21:55]  sass started ... 
[09:21:55]  uglifyjs started ... 
[09:21:55]  ionic-app-script task: "build" 
[09:21:55]  Error: ENOENT: no such file or directory, open 
            '/Users/Anku/Documents/IdeaProjects/ionic2-mosum/www/build/0.main.js.map' in undefined at line undefined, 
            col undefined, pos undefined 
Error: ENOENT: no such file or directory, open '/Users/Anku/Documents/IdeaProjects/ionic2-mosum/www/build/0.main.js.map' in undefined at line undefined, col undefined, pos undefined
    at new BuildError (/Users/Anku/Documents/IdeaProjects/ionic2-mosum/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at taskReject (/Users/Anku/Documents/IdeaProjects/ionic2-mosum/node_modules/@ionic/app-scripts/dist/worker-process.js:36:22)
    at /Users/Anku/Documents/IdeaProjects/ionic2-mosum/node_modules/@ionic/app-scripts/dist/worker-process.js:14:13
    at process._tickCallback (internal/process/next_tick.js:103:7)

Which @ionic/app-scripts version are you using?

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Most helpful comment

Work fine when I change ionic_source_map_type config value from "#inline-source-map" to "source-map" in package.json file

All 8 comments

I'm seeing exactly the same on app-scripts 1.3.6 with source map type #inline-source-map

Dev builds work fine, but I can't build for production.

same here --prod doesnt work with

"config": {
"ionic_bundler": "webpack",
"ionic_source_map_type": "#inline-source-map"
},

Getting exactly the same problem. Moreover, it seems that --prod flag does not disable source maps for PROD build - see https://github.com/driftyco/ionic-app-scripts/issues/977

I have the same problem

Work fine when I change ionic_source_map_type config value from "#inline-source-map" to "source-map" in package.json file

As a workaround, you can restrict the custom ionic_source_map_type setting to dev builds by first defining a custom webpack config file, then adjsting the config with config.dev.devtool = '#inline-source-map'.

Minimal example (not tested)

In package.json:

"config": {
  "ionic_webpack": "./src/config/webpack.config.js"
}

In src/config/webpack.config.js (might need to create it):

var config = require('@ionic/app-scripts/config/webpack.config.js');

module.exports = function () {
    // by default mapped to IONIC_SOURCE_MAP_TYPE
    config.dev.devtool = '#inline-source-map';
    return config;
};

Same here.

package.json (snippet)

{
  "scripts": {
    "build:release": "ionic cordova build android --release --prod --generateSourceMap false"
  },
  "config": {
    "ionic_purge_unused_fonts": false,
    "ionic_source_map_type": "#inline-source-map"
  },
}

You see, I also defined the option generateSourceMap to false, and the ionic compiler still handles it.
This should be fixed. Why #inline-source-map? Because it's the only working source-map mode when running on Android and insprecting via Chrome device remote..

Error:

ionic-app-script task: "build" 
Error: ENOENT: no such file or directory, open 
'%somepath%/www/build/main.js.map' in undefined at line undefined, 
col undefined, pos undefined 
...

Workaround:
Use the CLI Parameter to pass the inline-source-map manually to your dev run npm-script. Or for the prod build another type. Like:

ionic cordova run android --sourceMapType #inline-source-map

And remove the inline-source-map global config. Or set sourceMapType for prod to another value.

Was this page helpful?
0 / 5 - 0 ratings