@hyrious/dts
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -52,3 +52,3 @@ #!/usr/bin/env node | ||
// package.json | ||
var version = "0.1.2"; | ||
var version = "0.1.3"; | ||
@@ -55,0 +55,0 @@ // src/cli.ts |
34
index.js
@@ -25,6 +25,5 @@ // src/index.ts | ||
import { readFileSync, rmSync } from "fs"; | ||
import { dirname as dirname2 } from "path"; | ||
import { rollup } from "rollup"; | ||
import dts from "rollup-plugin-dts"; | ||
var CommonExts = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|json|png|jpe?g|gif|svg|ico|webp|avif|mp4|webm|ogg|mp3|wav|flac|aac|woff2?|eot|ttf|otf|wasm)$/; | ||
var CommonExts = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|png|jpe?g|gif|svg|ico|webp|avif|mp4|webm|ogg|mp3|wav|flac|aac|woff2?|eot|ttf|otf|wasm)$/; | ||
var _options = { | ||
@@ -49,3 +48,2 @@ noEmit: false, | ||
input: entry, | ||
output: { file: outfile }, | ||
onwarn(warning, warn) { | ||
@@ -58,3 +56,6 @@ if (warning.code === "UNRESOLVED_IMPORT" || warning.code === "CIRCULAR_DEPENDENCY" || warning.code === "EMPTY_BUNDLE") { | ||
plugins: [ | ||
json(), | ||
ignore(CommonExts), | ||
json({ | ||
preferConst: true | ||
}), | ||
dts({ | ||
@@ -64,8 +65,9 @@ respectExternal: true, | ||
compilerOptions | ||
}) | ||
}), | ||
fix_trivia() | ||
], | ||
external: [CommonExts, ...get_external(entry, new Set(include)), ...exclude] | ||
external: [...get_external(entry, new Set(include)), ...exclude] | ||
}); | ||
const result = await bundle.write({ | ||
dir: dirname2(outfile), | ||
file: outfile, | ||
format: "es", | ||
@@ -90,4 +92,22 @@ exports: "named" | ||
} | ||
function fix_trivia() { | ||
return { | ||
name: "fix-trivia", | ||
renderChunk(code) { | ||
return code.replace(/^(\s*)(const|enum)\s/gm, "$1declare $2 "); | ||
} | ||
}; | ||
} | ||
function ignore(re) { | ||
return { | ||
name: "ignore", | ||
load(id) { | ||
if (re.test(id)) { | ||
return ""; | ||
} | ||
} | ||
}; | ||
} | ||
export { | ||
build | ||
}; |
{ | ||
"name": "@hyrious/dts", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Invoke rollup-plugin-dts to generate bundled .d.ts file", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,8 +6,7 @@ import type ts from 'typescript' | ||
import { readFileSync, rmSync } from 'fs' | ||
import { dirname } from 'path' | ||
import { rollup, RollupOutput } from 'rollup' | ||
import { Plugin, rollup, RollupOutput } from 'rollup' | ||
import dts, { Options } from 'rollup-plugin-dts' | ||
const CommonExts = | ||
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|json|png|jpe?g|gif|svg|ico|webp|avif|mp4|webm|ogg|mp3|wav|flac|aac|woff2?|eot|ttf|otf|wasm)$/ | ||
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|png|jpe?g|gif|svg|ico|webp|avif|mp4|webm|ogg|mp3|wav|flac|aac|woff2?|eot|ttf|otf|wasm)$/ | ||
@@ -52,3 +51,2 @@ const _options: ts.CompilerOptions = { | ||
input: entry, | ||
output: { file: outfile }, | ||
onwarn(warning, warn) { | ||
@@ -65,3 +63,6 @@ if ( | ||
plugins: [ | ||
json(), | ||
ignore(CommonExts), | ||
json({ | ||
preferConst: true, | ||
}), | ||
dts({ | ||
@@ -72,8 +73,9 @@ respectExternal: true, | ||
}), | ||
fix_trivia(), | ||
], | ||
external: [CommonExts, ...get_external(entry, new Set(include)), ...exclude], | ||
external: [...get_external(entry, new Set(include)), ...exclude], | ||
}) | ||
const result = await bundle.write({ | ||
dir: dirname(outfile), | ||
file: outfile, | ||
format: 'es', | ||
@@ -100,1 +102,21 @@ exports: 'named', | ||
} | ||
function fix_trivia(): Plugin { | ||
return { | ||
name: 'fix-trivia', | ||
renderChunk(code) { | ||
return code.replace(/^(\s*)(const|enum)\s/gm, '$1declare $2 ') | ||
}, | ||
} | ||
} | ||
function ignore(re: RegExp): Plugin { | ||
return { | ||
name: 'ignore', | ||
load(id) { | ||
if (re.test(id)) { | ||
return '' | ||
} | ||
}, | ||
} | ||
} |
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
14025
357