systemjs / builder

SystemJS build tool
MIT License
466 stars 122 forks source link

Can't bundle tree with addition #846

Open wagnerflo opened 6 years ago

wagnerflo commented 6 years ago

In my current setup creating a bundle from a single file and it's dependencies works perfectly, but I've had no luck with "file1.es6 + file2.es6". Traceback:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
    at assertPath (path.js:39:11)
    at Object.extname (path.js:1376:5)
    at File.initOptions (node_modules/babel-core/lib/transformation/file/index.js:222:75)
    at new File (node_modules/babel-core/lib/transformation/file/index.js:135:24)
    at Pipeline.transform (node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at Object.exports.compile (node_modules/systemjs-builder/compilers/esm.js:119:22)
    at node_modules/systemjs-builder/lib/compile.js:117:43
    at tryCatcher (node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:763:18)
    at tryOnImmediate (timers.js:734:5)

From a quick look at the code line 64 in compilers/esm.js seems to be relevant. With a file tree expression load.path is null and down the road Babel trips over that. Setting filename: "" makes the bundling and the bundle work. No idea how to fix that correctly.

wagnerflo commented 6 years ago

I've just realized that this seems to be only true for creating static bundles (buildStatic function). Running bundle on the addition tree is successful without the workaround.