"SourceType" should not be used to version the transforms
See original GitHub issueCurrently, the transform creates the equivalent of a static record, with sourceType member:
https://github.com/Agoric/transform-module/blob/master/src/index.js#L87
This is needs to be equal to “module”, “script”, or “expression”: https://github.com/Agoric/transform-module/blob/master/src/index.js#L211 https://github.com/Agoric/transform-module/blob/master/src/index.js#L224
And is wired to derive which transforms to enable: https://github.com/Agoric/transform-module/blob/master/src/babelPlugin.js#L469
In other words, sourceType is really about the type of the source.
However, changes in Babel or in how our Babel plugin work could introduce incompatible changes that need to be detected by the consumers. If sourceType is used, then we would need to include then we would need to include three versions for every change, “module-v2”, “script-v3”, AND “expression-v3” because changes will most likely impact all three types at the same time.
It would be much better to keep version orthogonal to type, so a new version affects all types at the same time.
@michaelfig, following our discussion today, does this clarifies my position?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)

Top Related StackOverflow Question
Hmm, I don’t think that cuts it.
agoric-sdkagoric-sdkhas no dependency ontransform-moduleIn other words, there is no relation between those two packages:
moduleFormatisn’t part of the importer system.In addition:
cjsor not. https://github.com/Agoric/agoric-sdk/blob/master/packages/bundle-source/src/index.js#L29getExport. https://github.com/Agoric/agoric-sdk/blob/master/packages/bundle-source/src/index.js#L48Basically, module format used to decide whether or not to put a wrapper around a module. Its use is completely internal to
agoric-sdk.Bottom-line:
sourceType: do we have a module, a script, an expression.moduleFormat: do we have a cjs module, or an agoric functor.version: which version of the functor do we have.All three values need to evolve independently. The version needs to be tied to the output of the module transform, and needs to take into account the type of functor, etc. The importer then must decide what to do with a given version. Most likely
agoric-sdkdoesn’t need to be aware in involved with the version.No longer relevant.