typescript1.8 - Import external libraries and generate single file with typescript -


in gulp, use typescript transpile files es6, babel generate es5, , browserify generate 1 file modules. code:

gulp.task('scripts', function() {     return browserify('./src/scripts/main.ts')         .plugin(tsify, {moduleresolution: "node", target:"es5", allowjs:true, allowunreachablecode:true"})         .transform("babelify", {presets:["es2015"], extensions:[".ts", ".js"]})         .bundle()         //pass desired output filename vinyl-source-stream         .pipe(source('main.js'))         // start piping stream tasks!         .pipe(gulp.dest('./dist/scripts/')); }); 

i thought nice , less error prone if had rely on typescript of above. transpiler tried

tsc --moduleresolution "node" --module "amd"  --allowjs --outdir "out/" --allowunreachablecode --out foo.js main.ts 

this works fine, problem doesn't import external libraries jquery or d3. is, if code says import * d3 "d3", nothing gets imported. browserify, on other hand, recognizes these libraries , has no trouble importing them.

what missing? no error generated have no clue what's going on.

browserify, on other hand, recognizes these libraries , has no trouble importing them. missing?

please use browserify (or webpack) external libs.

basically have file d3.d.ts actual import context , not node_modules/d3/*. typescript doesn't load node_modules/d3 compilation output.

more

--allowjs facilitate your javascript migration @ point. have discovered 1 of many pitfalls.

ps: typescript work fine if node_module in typescript well.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -