Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

buildStatic and conditional boolean true with rollup enabled in jspm@beta #831

Open
horasikus opened this issue Aug 18, 2017 · 1 comment
Labels

Comments

@horasikus
Copy link

horasikus commented Aug 18, 2017

Hello,
when I try to compile with conditional boolean in true and rollup enabled I am getting follow error:

 Error: TypeError: Error compiling esm module "@dummy-entry-point" at null
        Path must be a string. Received null
    at builder.buildStatic.then.catch (/Users/horasikus/work_latest/conditional/gulpfile.js:19:35)
    at tryCatcher (/Users/horasikus/work_latest/conditional/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/horasikus/work_latest/conditional/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise 
...

I already checked similar issues 339 and 549 but it seems a new issue because now ENV is well resolved only throwing this exception when the condition is true.
If i disable rollup the bundle is ok.

src/env.conditions.js (it is not used by the builder static, only for dev mode)

export var mock = true;

jspm.config.js

SystemJS.config({
    map: {
        "ENV": "src/env.conditions.js"
    },
    nodeConfig: {
        "paths": {
            "npm:": "jspm_packages/npm/"
        }
    },
    devConfig: {
        "map": {
            "plugin-babel": "npm:[email protected]"
        }
    },
    packages: {
        "src": {
            "format": "esm",
            "meta": {
                "*.js": {
                    "loader": "plugin-babel"
                }
            }
        }
    }
});

src/app.js

import './employee.mock.js#?ENV|mock';

src/employee.mock.js

export default name = 'foo';

gulpfile.js

gulp.task('bundle', (cb) => {
    const Builder = require('systemjs-builder');
    const builder = new Builder();
    const inputPath = 'src/app.js';
    const outputFile = `dist/app.js`;
    const outputOptions = {
        conditions: {
            'ENV|mock.js': true
        },
        rollup: true
    };

    builder.loadConfig('jspm.config.js')
        .then(() => {
            builder.buildStatic(inputPath, outputFile, outputOptions)
                .then(() => cb())
                .catch((ex) => cb(new Error(ex)));
        });
});

package.json

{
  "name": "conditional",
  "version": "0.0.0",
  "description": "",
  "jspm": {
    "devDependencies": {
      "plugin-babel": "npm:systemjs-plugin-babel@^0.0.25"
    }
  },
  "dependencies": {
    "systemjs-builder": "^0.16.9"
  }
}

I tried command line with the same results. I'm using latest jspm 0.17.0-beta.42.

This issue only happens building the static bundle; jspm+systemjs in dev mode (load modules as separate files with ES6 in the browser) work as expected (playing with the condition in src/env.conditions.js). Also only fails with output format is esm.

@guybedford
Copy link
Member

Thanks, this does sound like a bug with conditional resolutions and rollup compatibility. I don't have a lot of time at the moment to look into it right now unfortunately, but if you'd be interested in exploring it yourself I could certainly help point in the right direction.

@guybedford guybedford added the bug label Aug 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants