Create HTML page with TypeScript script
index.ts
alert('hi')
It fails with Uncaught ReferenceError: define is not defined
No babel config or package.json
Mac OS, Node 9.3
parcel 1.3.1
The content of the build https://gist.github.com/alexeypetrushin/2d3a2a5dabddc34afd0ba09ed02f14b4
There's no declaration for define
function
Maybe try setting your tsconfig.json to use commonjs, as it looks like it's using AMD by default for some reason.
{
"compilerOptions": {
"module": "commonjs"
}
}
We default the module
option to commonjs here but you can override it in your tsconfig.json
. Any chance that's happening? I suppose we could enforce it to commonjs in parcel.
Yeah, that's why I thought it was weird. After some investigation, the simple example code provided doesn't output any AMD wrapping at all unless require
, export
, etc. are used. @alexeypetrushin What's your typescript version? And is this the _only_ file in the entire project? No tsconfig
or anything?
Hmm, I already killed the example, sorry don't have it anymore. I believe there were no tsconfig
, just basic example without any config.
I have the same problem. I have tsconfig file. It works perfectly with the module:umd option but unfortunately does not work with amd. But I still need to compile with amd for my project and now I see only one solution to does not specify the module option in tsconfig file and add it directly during compilation: tsc --module amd. I use jasmine-ts for testing and it adds automatically module type commonjs if it is not specified in tsconfig. Maybe it will be useful for someone :)
Most helpful comment
Maybe try setting your tsconfig.json to use commonjs, as it looks like it's using AMD by default for some reason.