Closed ijabit closed 8 years ago
That's strange, it should be working with sourcemap, as per the example in the Readme. Note that you have to load the sourcemaps into the gulp pipeline for it to work. Have a look at the gulp-sourcemaps package for how to load existing sourcemaps into the gulp pipeline.
The entire process happens in one task. Here is the abbreviated task: gulp.src([paths.typeScriptFiles, paths.typeScriptDefinitionFiles], { base: paths.typescriptSrcFolder }) ... .pipe(sourcemaps.init()) ... .pipe(ts(tsProject, {}, visualStudioReporter())) ... // everything is fine here and sourcemaps.write(...) will output the correct TypeScript sourcemaps .pipe(gAmdOptimize({ baseUrl: paths.typescriptSrcFolder, exclude: ["require", "exports"], preserveFiles: true })) // now the only sourcemaps that will be output are the ones that got translated during the gAmdOptimize plugin
Are you saying I'd have to dump the .js and .map files out and then reload them for the plugin to recognize them?
That looks like the correct way to do it. A good way to debug this is to use gulp-tap between ts and gAO to see what files you have and what properties they have. The way gulp-sourcemaps works is that the sourcemap is a property on the file, instead of being a separate file in the pipeline. It might be that the ts compiler isn't outputting it in this format. I'm not familiar with how ts and gulp work together, but that would be my guess
Okay, I output the contents of the sourcemap property on the file and the map definitely exists after being output from the gulp-typescript plugin. It is in this format: { "version":3, "sources":["shared/NotificationsVm.js","shared/NotificationsVm.ts"], "names":[], "mappings":"...", "file":"shared/NotificationsVm.js","sourcesContent":[...] }
Hi Marius, so given the fact that the files do have the .sourcemap property set to the above object, how can I get this plugin to stop resetting the sourcemap?
Thanks!
You don't happen to have this code on github somewhere? So I can try it? Or else I need to create a simple test case to see if I can reproduce it.
I stripped out as much stuff as I could to make a basic repro. See here: SourcemapRepro.zip
Just download, extract, restore packages, and run the index.html file. It's currently setup to use your plugin, bundle the modules, and then load the modules bundle. You can toggle the requirejs calls to pull in the non-optimized and non-bundled versions and see that the sourcemaps are fine.
Marius, do you have everything you need to look at this? Does the reproducible project work? Thanks.
Bump
Sorry, I've been very busy lately.
Try using the 0.5.0 version of gulp-amd-optimizer, and see if that helps
Nope, no difference in amd-optimizer 0.5.0. I tried it in my project and the previously attached sample project. Thanks.
Small bugfix, and I can now get it to work here: https://github.com/mariusGundersen/test-gulp-amd-optimizer
Yes! Thank you so much! It's working great now.
I have a task that runs a TypeScript compiler first to get the resulting JS. Then I run it through this plugin to get an amd-optimized module for bundling purposes. The TS -> JS transpile operation generates it's own sourcemaps, which aren't passed through this plugin. As soon as I hit this plugin, it only outputs the maps that gulp-amd-optimizer generates and seems to throw away the previous maps. Am I doing something wrong, or is this a missing feature?
Thanks!