gulp-typescript
gulp-typescript copied to clipboard
Ability to generate metadata.json files?
Expected behavior:
I would expect .metadata.json files to appear alongside .js, .d.ts and map files. Is this something that's achievable using gulp-typescript?
I'm using this as a replacement to gulp-ngc (as that wasn't compatible with Angular 5, and now i'm concerned that this isn't going to work).
Actual behavior:
No files. I've added skipMetadataEmit:false just to make sure, although the default is false.
Your gulpfile:
gulp.task('remove', function () {
return gulp
.src(
'../node_modules/proj',
{
read: false,
force: true
})
.pipe(
clean({
force: true,
read: false
})
);
});
gulp.task('build', function () {
var tsResult =
tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject());
return merge
([
tsResult.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('../node_modules/proj')),
tsResult.dts.pipe(gulp.dest('../node_modules/proj'))
]);
});
tsconfig.json
{
"compilerOptions": {
"outDir": "../node_modules/proj",
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noEmitHelpers": false,
"noImplicitAny": true,
"declaration": true,
"skipLibCheck": false,
"stripInternal": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"lib": [ "dom", "es6" ]
},
"include": [
"dest/**/*"
],
"exclude": [
"node_modules"
],
"angularCompilerOptions": {
"skipMetadataEmit": false,
"strictMetadataEmit": true,
"skipTemplateCodegen": true
}
}
Any help would be appreciated, debating throwing my computer out of the window ;)
I wasn't aware of this. Personally I don't use ngc and I don't really have interest in this, but I would accept a pull request on this. Currently files are filtered on file extension, and passed to the right substream. A compilation namely returns multiple streams, the main stream (with js and definition (.d.ts) files) and two substreams .js
and .dts
which respectively contain the JavaScript and definition files. The JavaScript files are annotated with sourcemaps, using the gulp-sourcemaps plugin.
Files that do not have one of those extensions are ignored (https://github.com/ivogabe/gulp-typescript/blob/d799f1982585510efb36bda82dac61c0a593894d/lib/compiler.ts#L127). I'd suggest to pass all 'unknown' file extensions to the main stream, and (if needed) add an additional substream .other
. Do you have time to create such a pull request?
Are you still interested in this feature?
I think I have a related issue #609. I believe the plugin shouldn't filter out content received from the compiler, for future compatibility at least. @ivogabe are you planning to fix this? I will be glad to help, but I'm not familiar with the code base and the compiler's API. I'm afraid it could take too much time for me to figure out. Will you be able to help with this?