-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Native support for loading ES Modules #975
Comments
Why did I think this was an issue? Mostly because I never tried it I guess. I just assumed that TypeScript wouldn't transpile JS files, but it does. So currently Deno will take something like this: foo.js import * as bar from "./bar.js";
(async () => {
const baz = await import("./baz.ts");
console.log(baz);
})();
export const foo = "bar";
console.log(bar); And transform it to: define(["require", "exports", "./bar.js"], function (require, exports, bar) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
(async () => {
const baz = await new Promise((resolve_1, reject_1) => { require(["./baz.ts"], resolve_1, reject_1);});
console.log(baz);
})();
exports.foo = "bar";
console.log(bar);
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9vLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9Vc2Vycy9ra2VsbHkvZ2l0aHViL2Rlbm9fZXhhbXBsZS9zcmMvZm9vLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztJQUVBLENBQUMsS0FBSyxJQUFJLEVBQUU7UUFDVixNQUFNLEdBQUcsR0FBRyxzREFBYSxVQUFVLDJCQUFDLENBQUM7UUFDckMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUNuQixDQUFDLENBQUMsRUFBRSxDQUFDO0lBRVEsUUFBQSxHQUFHLEdBQUcsS0FBSyxDQUFDO0lBRXpCLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgKiBhcyBiYXIgZnJvbSBcIi4vYmFyLmpzXCI7XG5cbihhc3luYyAoKSA9PiB7XG4gIGNvbnN0IGJheiA9IGF3YWl0IGltcG9ydChcIi4vYmF6LnRzXCIpO1xuICBjb25zb2xlLmxvZyhiYXopO1xufSkoKTtcblxuZXhwb3J0IGNvbnN0IGZvbyA9IFwiYmFyXCI7XG5cbmNvbnNvbGUubG9nKGJhcik7XG4iXX0= Which loads perfectly with the Deno compiler and stack traces will map back to the source JavaScript file. I have an example available at kitsonk/deno_example. So coupled with #1068 end users can fully author ES Modules in plain JavaScript, with type safety and even interpolate TypeScript and JavaScript modules. That significantly lowers the priority of this issue in my mind. There may be advantages to moving over to ES Modules from AMD, but the complication of integrating to V8 is rather daunting. cc: @sebs |
Thanks for linking me ;) <3 Its a well received feature where I stand. |
I’m working on this |
Ah, maybe a time to give my codebase a spin as I have some problems regarding esm (it was a esm test after all) .. Thanks. Building from source |
This reverts commit e976b3e. There is nothing technically wrong with this commit, but it's adding complexity to a big refactor (native ES modules denoland#975). Since it's not necessary and simply a philosophical preference, I will revert for now and try to bring it back later.
This reverts commit e976b3e. There is nothing technically wrong with this commit, but it's adding complexity to a big refactor (native ES modules denoland#975). Since it's not necessary and simply a philosophical preference, I will revert for now and try to bring it back later.
This reverts commit e976b3e. There is nothing technically wrong with this commit, but it's adding complexity to a big refactor (native ES modules denoland#975). Since it's not necessary and simply a philosophical preference, I will revert for now and try to bring it back later.
This adds the ability to spawn additional Isolates from Rust and send and receive messages from them. This is preliminary work to support running the typescript compiler in a separate isolate and thus support native ES modules (denoland#975).
This adds the ability to spawn additional Isolates from Rust and send and receive messages from them. This is preliminary work to support running the typescript compiler in a separate isolate and thus support native ES modules (denoland#975).
This adds the ability to spawn additional Isolates from Rust and send and receive messages from them. This is preliminary work to support running the typescript compiler in a separate isolate and thus support native ES modules. Ref #975.
Thanks @ry ;) Big <3 for these changes. |
Currently Deno cannot load JavaScript that requires ES
import
statements natively. It supports it in TypeScript by transpiling the module to AMD and then loading it.Both Node.js and d8 support this, so there are examples in place.
Adding this for tracking purposes as this is likely something I will work on in the future (e.g. this is fairly complex problem to tackle and not for the weak of heart).
The text was updated successfully, but these errors were encountered: