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

deno bundle doesn't work with import.meta #2553

Closed
ry opened this issue Jun 20, 2019 · 4 comments · Fixed by #3965
Closed

deno bundle doesn't work with import.meta #2553

ry opened this issue Jun 20, 2019 · 4 comments · Fixed by #3965

Comments

@ry
Copy link
Member

ry commented Jun 20, 2019

~/src/deno_std> deno bundle test.ts

file:///Users/rld/src/deno_std/archive/tar_test.ts:91:11 - error TS1343: 
The 'import.meta' meta-property is only allowed using 'ESNext' for 
the 'target' and 'module' compiler options.

91 runIfMain(import.meta);
             ~~~~~~~~~~~

@kitsonk
Copy link
Contributor

kitsonk commented Jun 21, 2019

Yeah, I am not sure of an easy way around that, because any bundle is not going to be an ESM module. We could "ignore" the TypeScript error when doing the bundle, but then would a bundled version have the right behaviours. Hmmm... 🤔

This was referenced Sep 23, 2019
@kt3k
Copy link
Member

kt3k commented Jan 26, 2020

What is the expected behavior for this?

Should we replace import.meta with something like the below?

({ url: "file:///path/to/file.js", main: false })

@kitsonk
Copy link
Contributor

kitsonk commented Jan 27, 2020

Hmmm... Possibly... Just checking with recent versions of TypeScript and import.meta works under SystemJS modules, and that is the module format we are going to have to move to for bundling in order to support TLA (because AMD is likely to never support it). It might "just work" but our SystemJS loader will need to supply it base on what the down-emit look like.

@kitsonk
Copy link
Contributor

kitsonk commented Jan 27, 2020

So this:

declare function runIfMain(arg: any): void;

runIfMain(import.meta);

Emits as this for System, which I already have a branch where I am trying to move bundling to System and supply the context, so just need to supply the right value:

System.register([], function (exports_1, context_1) {
    "use strict";
    var __moduleName = context_1 && context_1.id;
    return {
        setters: [],
        execute: function () {
            runIfMain(context_1.meta);
        }
    };
});

kitsonk added a commit to kitsonk/deno that referenced this issue Feb 11, 2020
Moves to using a minimal System loader for bundles generated by Deno.
TypeScript in 3.8 will be able to output TLA for modules, and the loader
is written to take advantage of that as soon as we update Deno to TS
3.8.

System also allows us to support `import.meta` and provide more ESM
aligned assignment of exports, as well as there is better handling of
circular imports.

The loader is also very terse versus to try to save overhead.

Also, fixed an issue where abstract classes were not being rexported.

Fixes denoland#2553
Fixes denoland#3559
Fixes denoland#3751
Fixes denoland#3825
Refs denoland#3301
kitsonk added a commit to kitsonk/deno that referenced this issue Feb 11, 2020
Moves to using a minimal System loader for bundles generated by Deno.
TypeScript in 3.8 will be able to output TLA for modules, and the loader
is written to take advantage of that as soon as we update Deno to TS
3.8.

System also allows us to support `import.meta` and provide more ESM
aligned assignment of exports, as well as there is better handling of
circular imports.

The loader is also very terse versus to try to save overhead.

Also, fixed an issue where abstract classes were not being rexported.

Fixes denoland#2553
Fixes denoland#3559
Fixes denoland#3751
Fixes denoland#3825
Refs denoland#3301
@ry ry closed this as completed in #3965 Feb 12, 2020
ry pushed a commit that referenced this issue Feb 12, 2020
Moves to using a minimal System loader for bundles generated by Deno.
TypeScript in 3.8 will be able to output TLA for modules, and the loader
is written to take advantage of that as soon as we update Deno to TS
3.8.

System also allows us to support `import.meta` and provide more ESM
aligned assignment of exports, as well as there is better handling of
circular imports.

The loader is also very terse versus to try to save overhead.

Also, fixed an issue where abstract classes were not being re-exported.

Fixes #2553
Fixes #3559
Fixes #3751
Fixes #3825
Refs #3301
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 a pull request may close this issue.

3 participants