add module:ignore option
Hi, when using ES6 module spec and try to generate ES5 code, the compiler invite me to specify a module type for the output : amd|commonjs. Is it possible to add ignore like in babeljs so we can concatenate output into a single file without having to use an extra tool to do the operation please ?
can you specify more details on the generated output. so how would import * from "module" or export default function foo(){} be emitted?
Hello!
it seems they just strip module information as seen here in documentation : https://babeljs.io/docs/usage/modules/
They gave an example :
import foo from "foo";
export function bar() {
return foo("foobar");
}
Will give :
function bar() {
return foo("foobar");
}
It is probably not as robust as you may want.
I am not sure i understand how this is meant to be used later. looking at babel's output in this case:
import {foo as foobar} from "foo";
export function bar() {
return foobar("foobar");
}
emits with --m ignore:
"use strict";
exports.bar = bar;
Object.defineProperty(exports, "__esModule", {
value: true
});
var foobar = require("foo").foo;
function bar() {
return foobar("foobar");
}
so you still have a call to require; if that is fine, just use --m commonjs.
Hi,
let me talk to you about my use case, it will probably help to understand why i hope to have this kind of feature (and for for your time by the way!). I'm coding using ES6 module and i want to be able to produce ES5 code without having to use commonjs or AMD module things the same way we can do using Typescript module.
For now, i must use a third party solution (babel for example) in order to have ES5 code without this external module things. Since we can do it with Typescript module, i was hopping that we can also ask to the compiler to output ES5 code without having to depend on commonjs/amd/...
To come back to mhegazy, i didn't included a librairie to handle those require calls. They may be changed it, i'll check this point to see if the ES5 code rely on another component in order to load
Hi @bidiboom, are you asking for us to concatenate the code of imported modules in place of loading them at runtime?
@bidiboom what is the difference between --m ignore and --m commonjs in your scenario ?
Hi!
Sorry for responding this late. Wasn't around for some time. Actually after reading some other opened items i saw this one https://github.com/Microsoft/TypeScript/issues/17 which is exactly what i want to achieve with this kind of options.
I suggested the module:ignore to achieve what is described in the ticket (be able to concatenate every file into a single one).
i see. closing this then in favor of #17.