-
Notifications
You must be signed in to change notification settings - Fork 46
Transpiling TypeScript with other module formats #138
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
Comments
I get a similar error "TypeScript transpiling to CommonJS, consider setting module: "system" in typescriptOptions to transpile directly to System.register format" when configured to support Angular 2 component syntax with relative files
|
@patrickmichalina use |
@guybedford thanks! Learn something new everyday. 👍 |
@guybedford that looks like a limitation of the typescript compiler itself. Also I don't think that typescript understands amd modules, so it cannot assign types to the imports and exports of an amd module, it can only check the types within the file. I will need to try this and report back. |
@frankwallis |
@aluanhaddad - I know that it can output AMD but I don't think that the type-checker can interpret AMD modules, so this code will not type-check but it will work at runtime if it is just transpiled: main.ts
message.ts:
Is that incorrect? The original issue is jspm/jspm#1898 |
@frankwallis No you are correct. But that is because let message: string = 'a_message';
export default message; This produces define(["require", "exports"], function (require, exports) {
"use strict";
var message = 'a_message';
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = message;
}); To expand on this a little, TypeScript does not recognize modules written by hand. It sees define(() => {
let message: string = 'a_message';
return message;
}) as a script, not a module. There is some special support for commonjs modules built into the language Edit: What I mean is, that TypeScript doesn't support AMD any more or less than it supports register(system) modules, but it understands their semantics and translates into them as you say. |
@frankwallis specifically I was just intending for it to ignore the input module format for these other cases (effectively just treating them as single scripts), but at least pass the format information through to SystemJS itself so that it doesn't try and read it as register output. |
@guybedford I think what may be needed here is something like #96 |
I have introduced a configuration setting |
That's awesome I look forward to trying it out. |
The Babel plugin supports transpiling CommonJS when
load.metadata.format == 'cjs'
for a given module metadata.In this case it will skip the registry output, effectively like a
modules: none
.I tried this with the TypeScript plugin but got the error:
//cc @OliverJAsh
The text was updated successfully, but these errors were encountered: