Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All CommonJS and AMD modules to be transpiled #1513

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matthewp
Copy link
Member

@matthewp matthewp commented Nov 5, 2019

This enables AMD and CommonJS modules to also be transpiled (run through Babel). Still a little bit of a WIP. Closes #1276

This enables AMD and CommonJS modules to also be transpiled (run through
		Babel). Still a little bit of a WIP. Closes #1276
@@ -692,10 +692,11 @@ addStealExtension(function addMetaDeps(loader) {
}

loader.transpile = function (load) {
// TODO this needs to change
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that .transpile() is called on all formats, prependDeps needs to check the load.format.

@@ -1735,6 +1761,7 @@ addStealExtension(function addCacheBust(loader) {
System.ext = Object.create(null);
System.logLevel = 0;
System.forceES5 = true;
System.transpileAllFormats = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the right option. In the PR we said transpile would be it.

Also this has to default to false or it will be a breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steal.loader.transpile is a function that's used to do transpilation. We could support the transpile: true option, but this would be tricky to implement. I don't think a slightly better name is actually worth it and transpileAllFormats is just fine.

@matthewp
Copy link
Member Author

matthewp commented Nov 5, 2019

There are a few issues with this PR but it basically works. Also need to test against steal-tools as I'm not sure what the implications this might have on that.

@matthewp matthewp requested a review from m-mujica November 5, 2019 21:54
@matthewp
Copy link
Member Author

matthewp commented Nov 6, 2019

Need a way to test this. My thought:

Have a custom babel plugin. Maybe it could change a function signature in some way. We would know that it works by calling same function. For example:

module.exports = function() {
  return 1;
};

Transpiles to:

module.exports = function() {
  return 2;
};

But only for a certain module. Seems reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow transpiling module formats other than ESM
1 participant