Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function normalize_lib_d_ts() {
const dts = require('dts-bundle');
const tsfmt = require('typescript-formatter');
const TYPE_DEF_FILE = path.join(__dirname, '..', config.dir.pkg, config.dir.types, PACKAGE_NAME, config.main.bundle_d_ts);
// concat d.ts
dts.bundle(config.dts_bundle);
// format d.ts
tsfmt.processStream(TYPE_DEF_FILE, fs.createReadStream(TYPE_DEF_FILE), {
tsfmt: tsfmt,
})
.then((content) => {
let src = '\ufeff' + banner('.d.ts') + content.message
.replace(/^\ufeff/gm, '')
.replace(/\r\n/gm, '\n')
.replace(/^\/\/ Generated by dts-bundle[\s\S]*?\n/g, '')
.replace(/^ \*/gm, ' *')
.replace(/^ \*/gm, ' *')
.replace(/^ \*/gm, ' *')
.replace(/'/gm, '"')
;
fs.writeFileSync(TYPE_DEF_FILE, src);
gulp.task('bundle_definitions', (done) => {
var opts = {
name: 'typematch',
main: 'bin/src/typematch.d.ts',
baseDir: 'bin',
out: 'src/bundle.d.ts',
};
// require module
var dts = require('dts-bundle');
// run it
dts.bundle(opts);
return done();
})
function calcExternals(main: string = "types/index.d.ts", out: string = "dist/index.d.ts") {
const bundleInfo: any = dts.bundle({
name: "__dummy__",
baseDir: ".",
main,
out,
outputAsModuleFolder: true
});
const externals: string[] = [];
for (const key in bundleInfo.fileMap) {
for (const external of bundleInfo.fileMap[key].externalImports) {
if (externals.indexOf(external) < 0) {
externals.push(external);
}
}
}
return externals;
}
var percentage_handler = function handler(percentage, msg) {
if (0 === percentage) {
console.log("Build started... good luck!");
} else if (1 === percentage) {
if (options.buildType === "prod") {
dts.bundle({
name: "../../survey." + options.platformPrefix,
main: packagePath + "typings/entries/" + options.platform + ".d.ts",
outputAsModuleFolder: true,
headerText: dts_banner
});
if (options.platform === "vue") {
replace(
{
files: packagePath + "survey.vue.d.ts",
from: /export default\s+\w+;/g,
to: ""
},
(error, changes) => {
if (error) {
return console.error("Error occurred:", error);
require("dts-bundle").bundle({
name: "node-ts",
main: "build/node-ts.d.ts",
out: "node-ts.d.ts"
});
compiler.plugin( 'done', () => {
let {opts} = this;
require( 'dts-bundle' ).bundle( opts );
if( opts.removeSource && opts.removeSourceDir ) require( 'rimraf' )( opts.removeSourceDir, () => {} );
} );
};