Comparing version 1.0.2 to 1.1.0
22
index.js
#!/usr/bin/env node | ||
const { gzipSync } = require('zlib'); | ||
const { dirname, normalize, resolve, join, extname } = require('path'); | ||
const { existsSync, readFileSync, writeFileSync } = require('fs'); | ||
const { dirname, normalize, resolve } = require('path'); | ||
const { white, red, cyan, dim } = require('kleur'); | ||
@@ -36,7 +36,11 @@ | ||
file = normalize(file); | ||
if (toDir && toDir !== 'default') { | ||
let isDef = /\.d\.ts$/.test(file); | ||
if (isDef && toDir !== 'default') { | ||
file = join(toDir, file); | ||
} else if (toDir && toDir !== 'default') { | ||
file = normalize(file.replace(dirname(file), toDir)); | ||
} | ||
mkdirs(dirname(file)); // sync | ||
let { code } = minify(data, Object.assign({ toplevel:!isUMD }, terser)); | ||
let code = isDef && data; | ||
code = code || minify(data, Object.assign({ toplevel:!isUMD }, terser)).code; | ||
writeFileSync(file, isUMD ? code : data); | ||
@@ -117,2 +121,9 @@ let gzip = size(gzipSync(code).length); | ||
let types = ''; | ||
if (isMode) { | ||
let extn = extname(filepath); | ||
types = filepath.replace(extn, '.d.ts'); | ||
types = existsSync(types) && readFileSync(types, 'utf8'); | ||
} | ||
const keys = []; | ||
@@ -126,2 +137,6 @@ const ESM = readFileSync(filepath, 'utf8'); | ||
return keys.push(name) && `${x}${type} ${name}`; | ||
}) | ||
.replace(/(^|\s|;)export \{(.+?)}(?=(;|\s|$))/, (_, x, names) => { | ||
names.split(',').forEach(name => keys.push(name.trim())); | ||
return x; | ||
}); | ||
@@ -146,2 +161,3 @@ | ||
fields.unpkg && write(fields.unpkg, UMD, isMin || 1, isMode), | ||
types && write('index.d.ts', types, false, isMode), | ||
].filter(Boolean) | ||
@@ -148,0 +164,0 @@ ).then(arr => { |
{ | ||
"name": "bundt", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"repository": "lukeed/bundt", | ||
@@ -37,5 +37,5 @@ "description": "A simple bundler for your delcious modules~!", | ||
"devDependencies": { | ||
"premove": "^2.0.0", | ||
"uvu": "^0.0.14" | ||
"premove": "^3.0.0", | ||
"uvu": "^0.3.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12082
164
243