esbuild-plugins-node-modules-polyfill
Advanced tools
Comparing version 1.0.6-next.a6f0ca3.0 to 1.0.6-next.bf7645e.0
@@ -39,3 +39,3 @@ "use strict"; | ||
var escapeRegex = /* @__PURE__ */ __name((str) => { | ||
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d"); | ||
return str.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d"); | ||
}, "escapeRegex"); | ||
@@ -60,6 +60,34 @@ var removeEndingSlash = /* @__PURE__ */ __name((str) => { | ||
// src/lib/plugin.ts | ||
var import_node_module = require("module"); | ||
var import_node_path = __toESM(require("path")); | ||
var import_modern_node_polyfills = require("modern-node-polyfills"); | ||
var import_module = require("module"); | ||
var NAME = "node-modules-polyfills"; | ||
var loader = /* @__PURE__ */ __name(async (args) => { | ||
try { | ||
const isCommonjs = args.namespace.endsWith("commonjs"); | ||
const resolved = await (0, import_modern_node_polyfills.polyfillPath)(removeEndingSlash(args.path)); | ||
const contents = await (0, import_modern_node_polyfills.polyfillContent)(removeEndingSlash(args.path)); | ||
const resolveDir = import_node_path.default.dirname(resolved); | ||
if (isCommonjs) { | ||
return { | ||
loader: "js", | ||
contents: commonJsTemplate({ | ||
importPath: args.path | ||
}), | ||
resolveDir | ||
}; | ||
} | ||
return { | ||
loader: "js", | ||
contents, | ||
resolveDir | ||
}; | ||
} catch (error) { | ||
console.error("node-modules-polyfill", error); | ||
return { | ||
contents: `export {}`, | ||
loader: "js" | ||
}; | ||
} | ||
}, "loader"); | ||
var nodeModulesPolyfillPlugin = /* @__PURE__ */ __name((options = {}) => { | ||
@@ -79,33 +107,5 @@ const { namespace = NAME, name = NAME } = options; | ||
} | ||
const loader = /* @__PURE__ */ __name(async (args) => { | ||
try { | ||
const isCommonjs = args.namespace.endsWith("commonjs"); | ||
const resolved = await (0, import_modern_node_polyfills.polyfillPath)(removeEndingSlash(args.path)); | ||
const contents = await (0, import_modern_node_polyfills.polyfillContent)(removeEndingSlash(args.path)); | ||
const resolveDir = import_node_path.default.dirname(resolved); | ||
if (isCommonjs) { | ||
return { | ||
loader: "js", | ||
contents: commonJsTemplate({ | ||
importPath: args.path | ||
}), | ||
resolveDir | ||
}; | ||
} | ||
return { | ||
loader: "js", | ||
contents, | ||
resolveDir | ||
}; | ||
} catch (e) { | ||
console.error("node-modules-polyfill", e); | ||
return { | ||
contents: `export {}`, | ||
loader: "js" | ||
}; | ||
} | ||
}, "loader"); | ||
onLoad({ filter: /.*/, namespace }, loader); | ||
onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader); | ||
const filter = new RegExp(`(?:node:)?${import_module.builtinModules.map(escapeRegex).join("|")}`); | ||
const filter = new RegExp(`(?:node:)?${import_node_module.builtinModules.map(escapeRegex).join("|")}`); | ||
const resolver = /* @__PURE__ */ __name(async (args) => { | ||
@@ -112,0 +112,0 @@ const ignoreRequire = args.namespace === commonjsNamespace; |
{ | ||
"name": "esbuild-plugins-node-modules-polyfill", | ||
"version": "1.0.6-next.a6f0ca3.0", | ||
"version": "1.0.6-next.bf7645e.0", | ||
"description": "Polyfills nodejs builtin modules for the browser.", | ||
@@ -31,3 +31,6 @@ "main": "dist/index.js", | ||
"esbuild-plugins-node-modules-polyfill", | ||
"node-modules-polyfill" | ||
"node-modules-polyfill", | ||
"esbuild", | ||
"esbuild-plugin", | ||
"polyfill" | ||
], | ||
@@ -37,13 +40,8 @@ "devDependencies": { | ||
"@commitlint/config-conventional": "^17.1.0", | ||
"@favware/cliff-jumper": "^1.8.7", | ||
"@favware/cliff-jumper": "^1.8.8", | ||
"@favware/npm-deprecate": "^1.0.5", | ||
"@sapphire/eslint-config": "^4.3.8", | ||
"@sapphire/prettier-config": "^1.4.4", | ||
"@typescript-eslint/eslint-plugin": "^5.38.0", | ||
"@typescript-eslint/parser": "^5.38.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"esbuild": "^0.15.9", | ||
"eslint": "^8.24.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"esbuild": "^0.15.10", | ||
"eslint": "^8.25.0", | ||
"eslint-config-mahir": "^0.0.8", | ||
"husky": "^8.0.1", | ||
@@ -53,5 +51,4 @@ "lint-staged": "^13.0.3", | ||
"prettier": "^2.7.1", | ||
"pretty-quick": "^3.1.3", | ||
"tsup": "^6.2.3", | ||
"typescript": "^4.8.3" | ||
"typescript": "^4.8.4" | ||
}, | ||
@@ -88,4 +85,3 @@ "files": [ | ||
}, | ||
"packageManager": "yarn@3.2.3", | ||
"prettier": "@sapphire/prettier-config", | ||
"packageManager": "yarn@3.2.4", | ||
"dependencies": { | ||
@@ -92,0 +88,0 @@ "modern-node-polyfills": "^0.0.9" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14
1
26526