-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b72d551
commit 9e7032d
Showing
13 changed files
with
9,222 additions
and
5,661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const estrella = require('estrella'); | ||
|
||
const base = { | ||
entry: 'src/index.ts', | ||
bundle: true, | ||
sourcemap: true, | ||
}; | ||
|
||
estrella.build({ | ||
...base, | ||
outfile: 'dist/browser/bundle.js', | ||
format: 'iife', | ||
tsconfig: 'tsconfig.browser.json', | ||
onEnd(config) { | ||
const dtsFilesOutdir = estrella.dirname(config.outfile); | ||
generateTypeDefs(estrella.tsconfig(config), config.entry, dtsFilesOutdir); | ||
}, | ||
}); | ||
|
||
estrella.build({ | ||
...base, | ||
outfile: 'dist/node/index.js', | ||
format: 'cjs', | ||
tsconfig: 'tsconfig.node.json', | ||
onEnd(config) { | ||
const dtsFilesOutdir = estrella.dirname(config.outfile); | ||
generateTypeDefs(estrella.tsconfig(config), config.entry, dtsFilesOutdir); | ||
}, | ||
}); | ||
|
||
function generateTypeDefs(tsconfig, entryfiles, outdir) { | ||
const filenames = Array.from( | ||
new Set((Array.isArray(entryfiles) ? entryfiles : [entryfiles]).concat(estrella.tsconfig.include || [])) | ||
).filter((v) => v); | ||
estrella.log.info('Generating type declaration files for', filenames.join(', ')); | ||
const compilerOptions = { | ||
...estrella.tsconfig.compilerOptions, | ||
moduleResolution: undefined, | ||
declaration: true, | ||
outDir: outdir, | ||
}; | ||
const program = estrella.ts.ts.createProgram(filenames, compilerOptions); | ||
const targetSourceFile = undefined; | ||
const writeFile = undefined; | ||
const cancellationToken = undefined; | ||
const emitOnlyDtsFiles = true; | ||
program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); | ||
estrella.log.info('Wrote', estrella.glob(outdir + '/*.d.ts').join(', ')); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.