stealjs / steal-tools

Build easy. Load fast.

Home Page:https://stealjs.com/docs/steal-tools.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build exports wrong cjs format

cherifGsoul opened this issue · comments

Currently the export for cjs is the same as amd I noticed this in 2 canjs packages, can-log and can-key-tree .

The used steal-tools version "steal-tools": "^2.2.1"

can-log_js_—_can-log

This is a shared mutable state bug

My current theory is that there is a shared data structure between each transform and previous code tranforms (AMD -> CJS for example) results are overwritten.

I verified transpile is generating the right output

can-log current build script looks like this:

stealTools.export({
  steal: {
    config: __dirname + "/package.json!npm"
  },
  outputs: {
    "+cjs": {},
    "+amd": {},
    "+global-js": {}
  }
});

When you run it, all built bundles are AMDs (which is the last transform in outputs) but it you change the order of the outputs like this:

stealTools.export({
  steal: {
    config: __dirname + "/package.json!npm"
  },
  outputs: {
    "+amd": {},
    "+global-js": {},
    "+cjs": {},
  }
});

All bundles will be written out as CJS instead (the last transform in the outputs object).

I think the problem might be around here

removeActiveSourceKeys(nodesInBundle, options);
...

Also, here all transforms share the same graph / data / loader... If I'm not wrong the activeSource object stores each transform and I think it is attached to the loader