-
Notifications
You must be signed in to change notification settings - Fork 25
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.emit() not respecting compilerOptions.target
when use with bundle:esm
#44
Comments
I found a work around for that, which I would call "double emit": const sources = {
'/foo.ts': `
export class A {
static a = 'b'
}
`
}
Deno.emit('/foo.ts', {
sources,
bundle: 'esm',
compilerOptions: { target: 'es6' }
})
.then(result => result.files['deno:///bundle.js'])
.then(src =>
Deno.emit('/src.js', {
sources: {
'/src.js': src
},
compilerOptions: { target: 'es6' }
})
)
.then(result => result.files['file:///src.js.js'])
.then(src => console.log(src)) This may not be efficient but can be use as a workaround. |
This issue still exists in deno 1.10.2. |
That is why the issue isn't closed. |
Same with |
The workaround did not work for me (Deno 1.16.3). The transpilation was skipped. I could fix it by using const source = "/path/or/url/to/mod.ts";
// bundling
const bundled = await Deno.emit(source, { bundle: "module" });
const bundledCode = bundled.files["deno:///bundle.js"];
// transpilation
const transpiled = await Deno.emit("/src.ts", {
sources: { "/src.ts": bundledCode },
compilerOptions: { target: "es6" },
});
const transpiledCode = transpiled.files["file:///src.ts.js"];
// write output file
await Deno.writeTextFile("/tmp/bundle.js", out); |
Just ran into this issue on deno 1.18.2 The workaround from @KnorpelSenf worked for me - but it would be excellent if it wasn't needed |
The code to compile :
Static member should be compiled into
A.a = 'b'
if targeting lower versions.The code calling Deno.emit:
The output:
The behavior of
bundle:esm, target:es6
is incorrect,static a = 'b'
should be compiled intoA.a = 'b'
, but actually not.The text was updated successfully, but these errors were encountered: