systemjs / plugin-less

MIT License
11 stars 13 forks source link

less-node.js overwrites NODE_ENV #5

Open mikol-styra opened 8 years ago

mikol-styra commented 8 years ago

In the following code from less-node.js, the line pEnv.NODE_ENV = productionEnv ? 'production' : 'development'; overwrites the actual environment such that commands like jspm run ... do not behave as expected. If the module being run imports plugin-less at any point, then NODE_ENV will always be 'production'.

$__System.registerDynamic("@system-env", [], false, function() {
  return {
    "production": true,
    "browser": false,
    "node": true,
    "dev": false,
    "default": true
  };
});

$__System.registerDynamic("github:jspm/nodelibs-process@0.2.0-alpha/process-node.js", ["@system-env", "@node/process"], true, function($__require, exports, module) {
  ;
  var define,
      global = this,
      GLOBAL = this;
  var productionEnv = $__require('@system-env').production;
  var process = $__require('@node/process');
  var pEnv = process.env;
  pEnv.NODE_ENV = productionEnv ? 'production' : 'development';
  module.exports = process;
  return module.exports;
});

I discovered this while working through a separate issue with server-side rendering when plugin-less (via css-plugin-base) attempts to inject into the DOM but document is not defined (of course).

guybedford commented 8 years ago

I've added an adjustment to jspm 0.17 here in https://github.com/jspm/jspm-cli/commit/78da833bb45ecf8f3ccdb9a7b41658993fe9a77f.

That should hopefully make this work out for your use case I think.