dts-generator
dts-generator copied to clipboard
Glob feature breaks excludes list
Commit 6bf53678d85623a49fe1581beeef4c194a7771f4 fixing #26 unfortunately broke the use of relative paths with the exclusion list. As globbing occurs from the working directory, you effectively find the relative path injected twice:
baseDir: ./SomePath/SomeSubPath
excludes: [SomeFile.ts]
becomes:
./SomePath/SomeSubPath/SomePath/SomeSubPath/SomeFile.ts
Fix is simple, glob sync operation simply needs to take a relative path.
(index.ts line 124)
glob.sync(filename, {cwd: baseDir}).forEach(.....
I would fix this myself and submit a pull request, but unfortunately there is not much chance of getting the CLA agreement past my organization.
I am going to move this to 1.7.0, because I think if using the tsconfig.json works for you, then all the files will be resolved within there. I will think about how to better make excluding work better via the command line, but I would like to get 1.6.0 out there since it is causing a lot of grief to folks.
Thanks for taking a look.
Just my two cents: I have just run into this problem.
I have a project directory which includes a typings
directory created and maintained with tsd. I do not want the tsd files from the typings
directory to be included in my tsd file, but if I exclude them in tsconfig.json
tsc will not compile, and if I try using the exclude option in dts-generator it excludes files based in the current working directory - not the baseDir
I have provided.
My options for dts-generator look something like this:
{
baseDir: 'AMDComponents',
name: 'AMDComponents',
project: 'AMDComponents',
out: 'build/AMDComponents/AMDComponents.d.ts',
exclude: ['node_modules/**/*.d.ts', 'typings/**/*.d.ts'],
verbose: true
}
dts-generator tries to exclude the following files (I have a node_modules
directory in the current working directory, but not in baseDir
):
node_modules/typescript/lib/lib.core.d.ts
node_modules/typescript/lib/lib.core.es6.d.ts
node_modules/typescript/lib/lib.d.ts
node_modules/typescript/lib/lib.dom.d.ts
node_modules/typescript/lib/lib.es6.d.ts
node_modules/typescript/lib/lib.scriptHost.d.ts
node_modules/typescript/lib/lib.webworker.d.ts
node_modules/typescript/lib/typescript.d.ts
node_modules/typescript/lib/typescriptServices.d.ts
What I think should be the correct functionality (which works with the change suggested by @Metal10k) is for the following files to be excluded:
typings/knockout/knockout.d.ts
typings/tsd.d.ts
This means that my dts file includes the knockout typings, which I do not want.
I am happy to submit a pull request with @Metal10k's change if you like.
Don't know if related, but I cannot get excludes
working. If I run this:
require('dts-generator').default({
name: 'aurelia-json',
project: '.',
files: [
'src/schema.ts',
'src/message-interceptor.ts'
],
excludes: [ 'jspm_packages/**/*.d.ts' ],
out: 'dist/aurelia-json.d.ts'
});
I get all definitions of modules in jspm_packages/**/*.d.ts
bundled and not excluded.
@heruan please use exclude instead of excludes which is in the readme document. @kitsonk but i find if i use baseDir, the code
excludesMap[filenameToMid(pathUtil.resolve(baseDir, globFileName))] = true;[line:134] will add the 'basedir' to exludeslists, and which would cause a bug in
if (excludesMap[filenameToMid(pathUtil.normalize(sourceFile.fileName))]) {[line:170] is this a bug or if i use this in the incorrect way?