rollup-plugin-esbuild
Advanced tools
Comparing version 5.0.0 to 6.0.0
@@ -5,6 +5,5 @@ import { Plugin } from 'rollup'; | ||
/** Mark some properties as optional, leaving others unchanged */ | ||
declare type MarkOptional<T, K extends keyof T> = T extends T ? Omit<T, K> & Partial<Pick<T, K>> : never; | ||
declare type MarkOptional<Type, Keys extends keyof Type> = Type extends Type ? Omit<Type, Keys> & Partial<Pick<Type, Keys>> : never; | ||
declare type Options$1 = Omit<TransformOptions, 'sourcemap'> & { | ||
type Options$1 = Omit<TransformOptions, 'sourcemap'> & { | ||
sourceMap?: boolean; | ||
@@ -14,3 +13,3 @@ }; | ||
declare type OptimizeDepsOptions = { | ||
type OptimizeDepsOptions = { | ||
include: string[]; | ||
@@ -23,3 +22,3 @@ exclude?: string[]; | ||
declare type Options = Omit<TransformOptions, 'sourcemap' | 'loader' | 'tsconfigRaw'> & { | ||
type Options = Omit<TransformOptions, 'sourcemap' | 'loader'> & { | ||
include?: FilterPattern; | ||
@@ -26,0 +25,0 @@ exclude?: FilterPattern; |
@@ -21,2 +21,6 @@ "use strict"; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
@@ -34,3 +38,3 @@ mod | ||
module.exports = __toCommonJS(src_exports); | ||
var import_fs3 = require("fs"); | ||
var import_fs2 = require("fs"); | ||
var import_path2 = require("path"); | ||
@@ -41,43 +45,2 @@ var import_esbuild4 = require("esbuild"); | ||
// src/options.ts | ||
var import_fs = __toESM(require("fs")); | ||
var import_joycon = __toESM(require("joycon")); | ||
var import_jsonc_parser = require("jsonc-parser"); | ||
var joycon = new import_joycon.default(); | ||
joycon.addLoader({ | ||
test: /\.json$/, | ||
load: async (file) => { | ||
const content = await import_fs.default.promises.readFile(file, "utf8"); | ||
return (0, import_jsonc_parser.parse)(content); | ||
} | ||
}); | ||
var jsxValueMap = { | ||
preserve: { | ||
jsx: "preserve" | ||
}, | ||
react: { | ||
jsx: "transform" | ||
}, | ||
"react-jsx": { | ||
jsx: "automatic" | ||
}, | ||
"react-jsxdev": { | ||
jsx: "automatic", | ||
jsxDev: true | ||
} | ||
}; | ||
var getOptions = async (cwd, tsconfig) => { | ||
const { data, path: path2 } = await joycon.load([tsconfig || "tsconfig.json"], cwd); | ||
if (path2 && data) { | ||
const { jsxFactory, jsxFragmentFactory, target, jsx } = data.compilerOptions || {}; | ||
return { | ||
jsxFactory, | ||
jsxFragment: jsxFragmentFactory, | ||
target: target && target.toLowerCase(), | ||
...jsxValueMap[jsx] | ||
}; | ||
} | ||
return {}; | ||
}; | ||
// src/minify.ts | ||
@@ -144,3 +107,3 @@ var import_esbuild2 = require("esbuild"); | ||
// src/optimizer/optmize-deps.ts | ||
var import_fs2 = __toESM(require("fs")); | ||
var import_fs = __toESM(require("fs")); | ||
var import_path = __toESM(require("path")); | ||
@@ -153,5 +116,5 @@ var import_esbuild3 = require("esbuild"); | ||
const cacheDir = import_path.default.join(options.cwd, "node_modules/.optimize_deps"); | ||
await import_fs2.default.promises.mkdir(cacheDir, { recursive: true }); | ||
await import_fs.default.promises.mkdir(cacheDir, { recursive: true }); | ||
await esModuleLexer.init; | ||
const result = await (0, import_esbuild3.build)({ | ||
await (0, import_esbuild3.build)({ | ||
entryPoints: options.include, | ||
@@ -204,3 +167,3 @@ absWorkingDir: options.cwd, | ||
const { absolute, resolveDir } = args.pluginData; | ||
const contents = await import_fs2.default.promises.readFile(absolute, "utf-8"); | ||
const contents = await import_fs.default.promises.readFile(absolute, "utf-8"); | ||
const [, exported] = esModuleLexer.parse(contents); | ||
@@ -228,2 +191,15 @@ return { | ||
// src/tsconfig.ts | ||
var import_promises = require("fs/promises"); | ||
var import_joycon = __toESM(require("joycon")); | ||
var joycon = new import_joycon.default(); | ||
joycon.addLoader({ | ||
test: /\.json$/, | ||
load: (file) => (0, import_promises.readFile)(file, "utf8") | ||
}); | ||
var getTsconfig = async (cwd, tsconfig) => { | ||
const { data } = await joycon.load([tsconfig || "tsconfig.json"], cwd); | ||
return data; | ||
}; | ||
// src/index.ts | ||
@@ -272,3 +248,3 @@ var debugOptimizeDeps = (0, import_debug.default)("rpe:optimize-deps"); | ||
const file = index ? (0, import_path2.join)(resolved, `index${ext}`) : `${fileWithoutExt}${ext}`; | ||
if ((0, import_fs3.existsSync)(file)) | ||
if ((0, import_fs2.existsSync)(file)) | ||
return file; | ||
@@ -312,3 +288,3 @@ } | ||
return file; | ||
if (!file && (0, import_fs3.existsSync)(resolved) && (0, import_fs3.statSync)(resolved).isDirectory()) { | ||
if (!file && (0, import_fs2.existsSync)(resolved) && (0, import_fs2.statSync)(resolved).isDirectory()) { | ||
file = resolveFile(resolved, true); | ||
@@ -329,12 +305,9 @@ if (file) | ||
} | ||
const defaultOptions = tsconfig === false ? {} : await getOptions((0, import_path2.dirname)(id), tsconfig); | ||
const tsconfigRaw = tsconfig === false ? void 0 : await getTsconfig((0, import_path2.dirname)(id), tsconfig); | ||
const result = await (0, import_esbuild4.transform)(code, { | ||
loader, | ||
target: defaultOptions.target || "es2017", | ||
jsxFactory: defaultOptions.jsxFactory, | ||
jsxFragment: defaultOptions.jsxFragment, | ||
jsx: defaultOptions.jsx, | ||
...defaultOptions.jsxDev ? { jsxDev: true } : {}, | ||
sourcemap: sourceMap, | ||
sourcefile: id, | ||
tsconfigRaw, | ||
target: "es2020", | ||
...esbuildOptions | ||
@@ -341,0 +314,0 @@ }); |
{ | ||
"name": "rollup-plugin-esbuild", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"packageManager": "pnpm@8.7.6", | ||
"main": "dist/index.js", | ||
@@ -8,3 +9,2 @@ "module": "dist/index.mjs", | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
@@ -17,7 +17,5 @@ "default": "./dist/index.js" | ||
"scripts": { | ||
"test": "jest", | ||
"example:rollup-node-resolve": "rollup --bundleConfigAsCjs -c example/rollup.config.js", | ||
"example:esbuild-optimize-deps": "OPTIMIZE=true rollup --bundleConfigAsCjs -c example/rollup.config.js", | ||
"test": "vitest", | ||
"build": "rm -rf dist && tsup src/index.ts --format esm,cjs --dts-resolve", | ||
"prepublishOnly": "npm run build" | ||
"prepublishOnly": "pnpm run build" | ||
}, | ||
@@ -28,36 +26,27 @@ "files": [ | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^23.0.0", | ||
"@rollup/plugin-node-resolve": "^15.0.0", | ||
"@types/debug": "^4.1.7", | ||
"@types/jest": "^29.1.2", | ||
"@types/node": "16.11.66", | ||
"esbuild": "^0.15.11", | ||
"istextorbinary": "^6.0.0", | ||
"jest": "^29.2.0", | ||
"lodash": "^4.17.21", | ||
"prettier": "^2.7.1", | ||
"@types/debug": "^4.1.8", | ||
"@types/node": "20.6.3", | ||
"esbuild": "^0.19.3", | ||
"prettier": "^3.0.3", | ||
"react": "^18.2.0", | ||
"rollup": "^3.2.2", | ||
"three": "^0.145.0", | ||
"ts-essentials": "^9.3.0", | ||
"ts-jest": "^29.0.3", | ||
"tsup": "^6.3.0", | ||
"typescript": "^4.8.4", | ||
"vue": "^3.2.41" | ||
"rollup": "^3.29.2", | ||
"ts-essentials": "^9.4.0", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2", | ||
"vitest": "^0.34.4", | ||
"vue": "^3.3.4" | ||
}, | ||
"dependencies": { | ||
"@rollup/pluginutils": "^5.0.1", | ||
"@rollup/pluginutils": "^5.0.4", | ||
"debug": "^4.3.4", | ||
"es-module-lexer": "^1.0.5", | ||
"joycon": "^3.1.1", | ||
"jsonc-parser": "^3.2.0" | ||
"es-module-lexer": "^1.3.1", | ||
"joycon": "^3.1.1" | ||
}, | ||
"peerDependencies": { | ||
"esbuild": ">=0.10.1", | ||
"esbuild": ">=0.18.0", | ||
"rollup": "^1.20.0 || ^2.0.0 || ^3.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=14.18.0", | ||
"npm": ">=8.0.0" | ||
"node": ">=14.18.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
6
11
222491
7
26158
627
- Removedjsonc-parser@^3.2.0
- Removedjsonc-parser@3.3.1(transitive)
Updated@rollup/pluginutils@^5.0.4
Updatedes-module-lexer@^1.3.1