Socket
Socket
Sign inDemoInstall

bunchee

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunchee - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

6

dist/bin/cli.js

@@ -5,2 +5,3 @@ #!/usr/bin/env node

var fs = require('fs/promises');
var bunchee = require('bunchee');

@@ -58,3 +59,3 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var version = "4.2.0";
var version = "4.2.1";

@@ -170,7 +171,6 @@ const helpMessage = `

const entry = source ? path__default.default.resolve(cwd, source) : '';
const bundle = require('../index').bundle;
let timeStart = Date.now();
let timeEnd;
try {
await bundle(entry, bundleConfig);
await bunchee.bundle(entry, bundleConfig);
timeEnd = Date.now();

@@ -177,0 +177,0 @@ } catch (err) {

@@ -594,2 +594,8 @@ Object.defineProperty(exports, '__esModule', { value: true });

const entriesAlias = getEntriesAlias(entries);
const reversedAlias = {};
for (const [key, value] of Object.entries(entriesAlias)){
if (value !== entry) {
reversedAlias[value] = key;
}
}
const hasNoExternal = options.external === null;

@@ -635,8 +641,2 @@ var _options_external;

const sizePlugin = pluginContext.sizeCollector.plugin(cwd);
const reversedAlias = {};
for (const [key, value] of Object.entries(entriesAlias)){
if (value !== entry) {
reversedAlias[value] = key;
}
}
// common plugins for both dts and ts assets that need to be processed

@@ -737,3 +737,4 @@ const commonPlugins = [

'UNRESOLVED_IMPORT',
'THIS_IS_UNDEFINED'
'THIS_IS_UNDEFINED',
'INVALID_ANNOTATION'
].includes(code)) return;

@@ -760,11 +761,3 @@ // If the circular dependency warning is from node_modules, ignore it

}
const splitChunks = (id, ctx)=>{
const moduleInfo = ctx.getModuleInfo(id);
if (!moduleInfo) {
return;
}
const moduleMeta = moduleInfo.meta;
if (!moduleMeta) {
return;
}
function getModuleLater(moduleMeta) {
const directives = (moduleMeta.preserveDirectives || {

@@ -774,9 +767,49 @@ directives: []

const moduleLayer = directives[0];
if (moduleLayer && !moduleMeta.isEntry) {
const chunkName = path__default.default.basename(id, path__default.default.extname(id));
return `${chunkName}-${moduleLayer}`;
}
return;
};
function buildOutputConfigs(pkg, exportPaths, options, exportCondition, cwd, { tsCompilerOptions }, dts) {
return moduleLayer;
}
// dependencyGraphMap: Map<subModuleId, Set<entryParentId>>
function createSplitChunks(dependencyGraphMap) {
return function splitChunks(id, ctx) {
const moduleInfo = ctx.getModuleInfo(id);
if (!moduleInfo) {
return;
}
const { isEntry } = moduleInfo;
const moduleMeta = moduleInfo.meta;
const moduleLayer = getModuleLater(moduleMeta);
// Collect the sub modules of the entry, if they're having layer, and the same layer with the entry, push them to the dependencyGraphMap.
if (isEntry) {
const subModuleIds = ctx.getModuleIds();
for (const subId of subModuleIds){
const subModuleInfo = ctx.getModuleInfo(subId);
if (!subModuleInfo) {
continue;
}
const subModuleLayer = getModuleLater(moduleMeta);
if (subModuleLayer === moduleLayer) {
if (!dependencyGraphMap.has(subId)) {
dependencyGraphMap.set(subId, new Set());
}
dependencyGraphMap.get(subId).add(id);
}
}
}
// If current module has a layer, and it's not an entry
if (moduleLayer && !isEntry) {
// If the module is imported by the entry:
// when the module layer is same as entry layer, keep it as part of entry and don't split it;
// when the module layer is different from entry layer, split the module into a separate chunk as a separate boundary.
if (dependencyGraphMap.has(id)) {
const parentModuleLayers = Array.from(dependencyGraphMap.get(id));
if (parentModuleLayers.every((layer)=>layer === moduleLayer)) {
return;
}
const chunkName = path__default.default.basename(id, path__default.default.extname(id));
return `${chunkName}-${moduleLayer}`;
}
}
return;
};
}
function buildOutputConfigs(pkg, exportPaths, options, exportCondition, cwd, { tsCompilerOptions }, pluginContext, dts) {
const { format } = options;

@@ -807,3 +840,3 @@ // Add esm mark and interop helper if esm export is detected

sourcemap: options.sourcemap,
manualChunks: splitChunks,
manualChunks: createSplitChunks(pluginContext.moduleDirectiveLayerMap),
chunkFileNames: '[name]-[hash].js',

@@ -920,3 +953,4 @@ // By default in rollup, when creating multiple chunks, transitive imports of entry chunks

};
const inputOptions = await buildInputConfig(exportCondition.source, entries, pkg, options, cwd, tsOptions, pluginContext, dts);
const entry = exportCondition.source;
const inputOptions = await buildInputConfig(entry, entries, pkg, options, cwd, tsOptions, pluginContext, dts);
const outputExports = getExportConditionDist(pkg, exportCondition, cwd);

@@ -927,8 +961,8 @@ let outputConfigs = [];

const typeOutputExports = getExportTypeDist(exportCondition, cwd);
outputConfigs = typeOutputExports.map((v)=>buildOutputConfigs(pkg, exportPaths, {
outputConfigs = typeOutputExports.map((typeFile)=>buildOutputConfigs(pkg, exportPaths, {
...bundleConfig,
format: 'es',
useTypescript,
file: v
}, exportCondition, cwd, tsOptions, dts));
file: typeFile
}, exportCondition, cwd, tsOptions, pluginContext, dts));
} else {

@@ -942,3 +976,3 @@ // multi outputs with specified format

useTypescript
}, exportCondition, cwd, tsOptions, dts);
}, exportCondition, cwd, tsOptions, pluginContext, dts);
});

@@ -955,3 +989,3 @@ // CLI output option is always prioritized

useTypescript
}, exportCondition, cwd, tsOptions, dts)
}, exportCondition, cwd, tsOptions, pluginContext, dts)
];

@@ -1202,3 +1236,4 @@ }

const pluginContext = {
sizeCollector
sizeCollector,
moduleDirectiveLayerMap: new Map()
};

@@ -1205,0 +1240,0 @@ const buildConfigs = await buildEntryConfig(entries, pkg, exportPaths, options, cwd, defaultTsOptions, pluginContext, false);

{
"name": "bunchee",
"version": "4.2.0",
"version": "4.2.1",
"description": "zero config bundler for js/ts/jsx libraries",

@@ -89,3 +89,4 @@ "bin": "./dist/bin/cli.js",

"tsx": "^4.6.2",
"typescript": "^5.3.2"
"typescript": "^5.3.2",
"bunchee": "link:./"
},

@@ -92,0 +93,0 @@ "lint-staged": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc