Comparing version 3.4.1 to 3.5.0
@@ -100,3 +100,3 @@ #!/usr/bin/env node | ||
var version = "3.4.1"; | ||
var version = "3.5.0"; | ||
@@ -103,0 +103,0 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
@@ -9,3 +9,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
var commonjs = require('@rollup/plugin-commonjs'); | ||
var shebang = require('rollup-plugin-preserve-shebang'); | ||
var json = require('@rollup/plugin-json'); | ||
@@ -15,2 +14,3 @@ var pluginNodeResolve = require('@rollup/plugin-node-resolve'); | ||
var prettyBytes = require('pretty-bytes'); | ||
var MagicString = require('magic-string'); | ||
var module$1 = require('module'); | ||
@@ -23,6 +23,6 @@ | ||
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs); | ||
var shebang__default = /*#__PURE__*/_interopDefault(shebang); | ||
var json__default = /*#__PURE__*/_interopDefault(json); | ||
var replace__default = /*#__PURE__*/_interopDefault(replace); | ||
var prettyBytes__default = /*#__PURE__*/_interopDefault(prettyBytes); | ||
var MagicString__default = /*#__PURE__*/_interopDefault(MagicString); | ||
@@ -67,2 +67,34 @@ function chunkSizeCollector() { | ||
function preserveDirectivePlugin() { | ||
const directives = new Set(); | ||
return { | ||
name: 'use-directive', | ||
transform (code, id) { | ||
const regex = /^(?:['"]use[^'"]+['"][^\n]*|#![^\n]*)/gm; | ||
const replacedCode = code.replace(regex, (match)=>{ | ||
// replace double quotes with single quotes | ||
directives.add(match.replace(/["]/g, "'")); | ||
return ''; | ||
}); | ||
return { | ||
code: replacedCode, | ||
map: null | ||
}; | ||
}, | ||
renderChunk (code, _, { sourcemap }) { | ||
if (!directives.size) return null; | ||
const s = new MagicString__default.default(code); | ||
s.prepend(`${[ | ||
...directives | ||
].join('\n')}\n`); | ||
return { | ||
code: s.toString(), | ||
map: sourcemap ? s.generateMap({ | ||
hires: true | ||
}) : null | ||
}; | ||
} | ||
}; | ||
} | ||
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) { | ||
@@ -525,3 +557,3 @@ try { | ||
const commonPlugins = [ | ||
shebang__default.default(), | ||
preserveDirectivePlugin(), | ||
sizePlugin | ||
@@ -528,0 +560,0 @@ ]; |
{ | ||
"name": "bunchee", | ||
"version": "3.4.1", | ||
"version": "3.5.0", | ||
"description": "zero config bundler for js/ts/jsx libraries", | ||
@@ -56,2 +56,3 @@ "bin": { | ||
"arg": "5.0.2", | ||
"magic-string": "0.30.0", | ||
"pretty-bytes": "5.6.0", | ||
@@ -61,3 +62,2 @@ "publint": "0.1.11", | ||
"rollup-plugin-dts": "5.3.0", | ||
"rollup-plugin-preserve-shebang": "1.0.1", | ||
"rollup-plugin-swc3": "0.8.1", | ||
@@ -67,3 +67,3 @@ "tslib": "2.5.0" | ||
"peerDependencies": { | ||
"typescript": ">=4.1.0 <5.0.0 || >=5.0.0 <6.0.0" | ||
"typescript": "^4.1 || ^5.0" | ||
}, | ||
@@ -70,0 +70,0 @@ "peerDependenciesMeta": { |
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
58720
1374
+ Addedmagic-string@0.30.0
+ Addedmagic-string@0.30.0(transitive)
- Removedrollup-plugin-preserve-shebang@1.0.1
- Removedmagic-string@0.25.90.30.11(transitive)
- Removedrollup-plugin-preserve-shebang@1.0.1(transitive)
- Removedsourcemap-codec@1.4.8(transitive)