Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

[webpack] Production sourcemap for javascript #232

Closed
aegyed91 opened this issue Dec 19, 2015 · 7 comments
Closed

[webpack] Production sourcemap for javascript #232

aegyed91 opened this issue Dec 19, 2015 · 7 comments
Assignees

Comments

@aegyed91
Copy link

Hello @greypants, i am unable to generate a sourcemap for javascript in production. I simply put the devtool option directly to webpackConfig and removed the one in the development conditional.

var webpackConfig = {
   ...,
   devtool: 'source-map',
   ...
}

the error in terminal's stream

path.js:8
    throw new TypeError('Path must be a string. Received ' +
    ^

TypeError: Path must be a string. Received [ 'main-7cdd5e7952f0ad06bc45.js',
  'main-7cdd5e7952f0ad06bc45.js.map' ]
    at assertPath (path.js:8:11)
    at Object.posix.join (path.js:479:5)
    at Compiler.<anonymous> (/Users/tsm/Sites/__projects/backbone-starter/gulpfile.js/lib/webpackManifest.js:15:66)
    at Compiler.applyPlugins (/Users/tsm/Sites/__projects/backbone-starter/node_modules/tapable/lib/Tapable.js:26:37)
    at Compiler.<anonymous> (/Users/tsm/Sites/__projects/backbone-starter/node_modules/webpack/lib/Compiler.js:193:12)
    at Compiler.emitRecords (/Users/tsm/Sites/__projects/backbone-starter/node_modules/webpack/lib/Compiler.js:282:37)
    at Compiler.<anonymous> (/Users/tsm/Sites/__projects/backbone-starter/node_modules/webpack/lib/Compiler.js:187:11)
    at /Users/tsm/Sites/__projects/backbone-starter/node_modules/webpack/lib/Compiler.js:275:11
    at Compiler.applyPluginsAsync (/Users/tsm/Sites/__projects/backbone-starter/node_modules/tapable/lib/Tapable.js:60:69)
    at Compiler.afterEmit (/Users/tsm/Sites/__projects/backbone-starter/node_modules/webpack/lib/Compiler.js:272:8)

npm ERR! Darwin 15.2.0
npm ERR! argv "/Users/tsm/.nvm/versions/node/v5.1.0/bin/node" "/Users/tsm/.nvm/versions/node/v5.1.0/bin/npm" "run" "demo"
npm ERR! node v5.1.0
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! marionette-starter@1.0.0 demo: `gulp production && gulp server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the marionette-starter@1.0.0 demo script 'gulp production && gulp server'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the marionette-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp production && gulp server
npm ERR! You can get their info via:
npm ERR!     npm owner ls marionette-starter
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/tsm/Sites/__projects/backbone-starter/npm-debug.log

npm-debug/log file

0 info it worked if it ends with ok
1 verbose cli [ '/Users/tsm/.nvm/versions/node/v5.1.0/bin/node',
1 verbose cli   '/Users/tsm/.nvm/versions/node/v5.1.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'demo' ]
2 info using npm@3.3.12
3 info using node@v5.1.0
4 verbose run-script [ 'predemo', 'demo', 'postdemo' ]
5 info lifecycle marionette-starter@1.0.0~predemo: marionette-starter@1.0.0
6 silly lifecycle marionette-starter@1.0.0~predemo: no script for predemo, continuing
7 info lifecycle marionette-starter@1.0.0~demo: marionette-starter@1.0.0
8 verbose lifecycle marionette-starter@1.0.0~demo: unsafe-perm in lifecycle true
9 verbose lifecycle marionette-starter@1.0.0~demo: PATH: /Users/tsm/.nvm/versions/node/v5.1.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/tsm/Sites/__projects/backbone-starter/node_modules/.bin:/Users/tsm/.nvm/versions/node/v5.1.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/tsm/bin:/Users/tsm/gsutil
10 verbose lifecycle marionette-starter@1.0.0~demo: CWD: /Users/tsm/Sites/__projects/backbone-starter
11 silly lifecycle marionette-starter@1.0.0~demo: Args: [ '-c', 'gulp production && gulp server' ]
12 silly lifecycle marionette-starter@1.0.0~demo: Returned: code: 1  signal: null
13 info lifecycle marionette-starter@1.0.0~demo: Failed to exec demo script
14 verbose stack Error: marionette-starter@1.0.0 demo: `gulp production && gulp server`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/Users/tsm/.nvm/versions/node/v5.1.0/lib/node_modules/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at EventEmitter.emit (events.js:172:7)
14 verbose stack     at ChildProcess.<anonymous> (/Users/tsm/.nvm/versions/node/v5.1.0/lib/node_modules/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at ChildProcess.emit (events.js:172:7)
14 verbose stack     at maybeClose (internal/child_process.js:818:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid marionette-starter@1.0.0
16 verbose cwd /Users/tsm/Sites/__projects/backbone-starter
17 error Darwin 15.2.0
18 error argv "/Users/tsm/.nvm/versions/node/v5.1.0/bin/node" "/Users/tsm/.nvm/versions/node/v5.1.0/bin/npm" "run" "demo"
19 error node v5.1.0
20 error npm  v3.3.12
21 error code ELIFECYCLE
22 error marionette-starter@1.0.0 demo: `gulp production && gulp server`
22 error Exit status 1
23 error Failed at the marionette-starter@1.0.0 demo script 'gulp production && gulp server'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the marionette-starter package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     gulp production && gulp server
23 error You can get their info via:
23 error     npm owner ls marionette-starter
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
@tommydunn
Copy link

ditto

@aegyed91
Copy link
Author

@Tommyldunn the problem is this revving mechanism does too much, it also minifies the source, it should be done in the css process with gulp-if

@greypants
Copy link
Contributor

The issue with webpack at least is here (it handles it's revving separately): https://github.com/vigetlabs/gulp-starter/blob/master/gulpfile.js/lib/webpackManifest.js#L15

Looks like chunks[key] returns an array that includes the source map (when enabled), instead of a single string. For a quick fix you could add a check and do something like

var chunkName = typeof chunks[key] === 'string' ? chunks[key] : chunks[key][0]
... path.join(publicPath, chunkName)

But that's kind of dirty. This is a good issue. Feel free to open a Pull Request if you come up with a good solution. I may not have time this week, but will try.

@tommydunn
Copy link

@tsm91 - thanks for the info man.

@greypants - thanks man, i'll have some time this weekend to look into that and will let ya know. ps. love your work

@webnesto
Copy link

webnesto commented Apr 6, 2016

@Tommyldunn - had any success with this? Interested to hear your progress and hope to avoid re-inventing the wheel if you've already got one rolling.

@greypants
Copy link
Contributor

greypants commented May 1, 2017

I have not revisited this specifically with Blendid, but you do get FULL access to the webpack config now: https://github.com/vigetlabs/blendid#customizewebpackconfig

@greypants
Copy link
Contributor

Working on this now! Should be fixed in the next release.

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

No branches or pull requests

4 participants