summaryrefslogtreecommitdiff
path: root/node_modules/@esbuild-plugins/node-modules-polyfill
diff options
context:
space:
mode:
authorakiyamn2023-09-24 23:22:21 +1000
committerakiyamn2023-09-24 23:22:21 +1000
commit4e87195739f2a5d9a05451b48773c8afdc680765 (patch)
tree9cba501844a4a11dcbdffc4050ed8189561c55ed /node_modules/@esbuild-plugins/node-modules-polyfill
downloadprice-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.tar.gz
price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.zip
Initial commit (by create-cloudflare CLI)
Diffstat (limited to 'node_modules/@esbuild-plugins/node-modules-polyfill')
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts8
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js127
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts2
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js183
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts2
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js61
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts8
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js120
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts2
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js178
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts2
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js57
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js.map1
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/package.json33
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/src/index.test.ts200
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/src/index.ts133
-rw-r--r--node_modules/@esbuild-plugins/node-modules-polyfill/src/polyfills.ts151
28 files changed, 1279 insertions, 0 deletions
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts
new file mode 100644
index 0000000..65d4193
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts
@@ -0,0 +1,8 @@
+import { Plugin } from 'esbuild';
+export interface NodePolyfillsOptions {
+ name?: string;
+ namespace?: string;
+}
+export declare function NodeModulesPolyfillPlugin(options?: NodePolyfillsOptions): Plugin;
+export default NodeModulesPolyfillPlugin;
+//# sourceMappingURL=index.d.ts.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts.map b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts.map
new file mode 100644
index 0000000..c1151f9
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAA;AAkB/C,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,yBAAyB,CACrC,OAAO,GAAE,oBAAyB,GACnC,MAAM,CAwFR;AAmBD,eAAe,yBAAyB,CAAA"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js
new file mode 100644
index 0000000..51f4d1a
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js
@@ -0,0 +1,127 @@
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.NodeModulesPolyfillPlugin = void 0;
+const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
+const fs_1 = __importDefault(require("fs"));
+const path_1 = __importDefault(require("path"));
+const polyfills_1 = require("./polyfills");
+// import { NodeResolvePlugin } from '@esbuild-plugins/node-resolve'
+const NAME = 'node-modules-polyfills';
+const NAMESPACE = NAME;
+function removeEndingSlash(importee) {
+ if (importee && importee.slice(-1) === '/') {
+ importee = importee.slice(0, -1);
+ }
+ return importee;
+}
+function NodeModulesPolyfillPlugin(options = {}) {
+ const { namespace = NAMESPACE, name = NAME } = options;
+ if (namespace.endsWith('commonjs')) {
+ throw new Error(`namespace ${namespace} must not end with commonjs`);
+ }
+ // this namespace is needed to make ES modules expose their default export to require: require('assert') will give you import('assert').default
+ const commonjsNamespace = namespace + '-commonjs';
+ const polyfilledBuiltins = polyfills_1.builtinsPolyfills();
+ const polyfilledBuiltinsNames = [...polyfilledBuiltins.keys()];
+ return {
+ name,
+ setup: function setup({ onLoad, onResolve, initialOptions }) {
+ var _a;
+ // polyfills contain global keyword, it must be defined
+ if ((initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define) && !((_a = initialOptions.define) === null || _a === void 0 ? void 0 : _a.global)) {
+ initialOptions.define['global'] = 'globalThis';
+ }
+ else if (!(initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define)) {
+ initialOptions.define = { global: 'globalThis' };
+ }
+ // TODO these polyfill module cannot import anything, is that ok?
+ function loader(args) {
+ return __awaiter(this, void 0, void 0, function* () {
+ try {
+ const argsPath = args.path.replace(/^node:/, '');
+ const isCommonjs = args.namespace.endsWith('commonjs');
+ const resolved = polyfilledBuiltins.get(removeEndingSlash(argsPath));
+ const contents = yield (yield fs_1.default.promises.readFile(resolved)).toString();
+ let resolveDir = path_1.default.dirname(resolved);
+ if (isCommonjs) {
+ return {
+ loader: 'js',
+ contents: commonJsTemplate({
+ importPath: argsPath,
+ }),
+ resolveDir,
+ };
+ }
+ return {
+ loader: 'js',
+ contents,
+ resolveDir,
+ };
+ }
+ catch (e) {
+ console.error('node-modules-polyfill', e);
+ return {
+ contents: `export {}`,
+ loader: 'js',
+ };
+ }
+ });
+ }
+ onLoad({ filter: /.*/, namespace }, loader);
+ onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);
+ const filter = new RegExp([
+ ...polyfilledBuiltinsNames,
+ ...polyfilledBuiltinsNames.map((n) => `node:${n}`),
+ ]
+ .map(escape_string_regexp_1.default)
+ .join('|'));
+ function resolver(args) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const argsPath = args.path.replace(/^node:/, '');
+ const ignoreRequire = args.namespace === commonjsNamespace;
+ if (!polyfilledBuiltins.has(argsPath)) {
+ return;
+ }
+ const isCommonjs = !ignoreRequire && args.kind === 'require-call';
+ return {
+ namespace: isCommonjs ? commonjsNamespace : namespace,
+ path: argsPath,
+ };
+ });
+ }
+ onResolve({ filter }, resolver);
+ // onResolve({ filter: /.*/, namespace }, resolver)
+ },
+ };
+}
+exports.NodeModulesPolyfillPlugin = NodeModulesPolyfillPlugin;
+function commonJsTemplate({ importPath }) {
+ return `
+const polyfill = require('${importPath}')
+
+if (polyfill && polyfill.default) {
+ module.exports = polyfill.default
+ for (let k in polyfill) {
+ module.exports[k] = polyfill[k]
+ }
+} else if (polyfill) {
+ module.exports = polyfill
+}
+
+
+`;
+}
+exports.default = NodeModulesPolyfillPlugin;
+//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js.map b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js.map
new file mode 100644
index 0000000..c4bf9e4
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,gFAAqD;AACrD,4CAAmB;AACnB,gDAAuB;AAEvB,2CAA+C;AAE/C,oEAAoE;AACpE,MAAM,IAAI,GAAG,wBAAwB,CAAA;AACrC,MAAM,SAAS,GAAG,IAAI,CAAA;AAEtB,SAAS,iBAAiB,CAAC,QAAQ;IAC/B,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACxC,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,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;oBAChD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,KAAK,iBAAiB,CAAA;oBAE1D,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;wBACnC,OAAM;qBACT;oBAED,MAAM,UAAU,GACZ,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;oBAElD,OAAO;wBACH,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;wBACrD,IAAI,EAAE,QAAQ;qBACjB,CAAA;gBACL,CAAC;aAAA;YACD,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;YAC/B,mDAAmD;QACvD,CAAC;KACJ,CAAA;AACL,CAAC;AA1FD,8DA0FC;AAED,SAAS,gBAAgB,CAAC,EAAE,UAAU,EAAE;IACpC,OAAO;4BACiB,UAAU;;;;;;;;;;;;CAYrC,CAAA;AACD,CAAC;AAED,kBAAe,yBAAyB,CAAA"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts
new file mode 100644
index 0000000..121d59b
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts
@@ -0,0 +1,2 @@
+export {};
+//# sourceMappingURL=index.test.d.ts.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts.map b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts.map
new file mode 100644
index 0000000..b5774e1
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js
new file mode 100644
index 0000000..2923eec
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js
@@ -0,0 +1,183 @@
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const esbuild_1 = require("esbuild");
+const test_support_1 = require("test-support");
+const fs_1 = __importDefault(require("fs"));
+const _1 = __importDefault(require("."));
+const node_globals_polyfill_1 = __importDefault(require("@esbuild-plugins/node-globals-polyfill"));
+require('debug').enable(require('../package.json').name);
+test('works', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default()],
+ });
+ eval(res.outputFiles[0].text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test('works with SafeBuffer and other package consumers', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `import {Buffer as SafeBuffer} from './safe-buffer'; console.log(SafeBuffer);`,
+ 'safe-buffer.ts': fs_1.default
+ .readFileSync(require.resolve('safe-buffer'))
+ .toString(),
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default()],
+ });
+ // console.log(
+ // res.outputFiles[0].text
+ // .split('\n')
+ // .map((x, i) => i + ' ' + x)
+ // .join('\n'),
+ // )
+ eval(res.outputFiles[0].text);
+ unlink();
+}));
+test('events works', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `
+ import EventEmitter from 'events';
+
+ class Test extends EventEmitter {
+ constructor() { };
+ }
+ console.log(Test)
+ `,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default()],
+ });
+ // console.log(res.outputFiles[0].text)
+ eval(res.outputFiles[0].text);
+ unlink();
+}));
+test('require can use default export', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `
+ const assert = require('assert')
+ // console.log(assert)
+ assert('ok')
+ `,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default()],
+ });
+ // console.log(res.outputFiles[0].text)
+ eval(res.outputFiles[0].text);
+ unlink();
+}));
+test.skip('crypto', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `import { randomBytes } from 'crypto'; console.log(randomBytes(20).toString('hex'))`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default()],
+ });
+ eval(res.outputFiles[0].text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test.skip('fs', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `import { readFile } from 'fs'; console.log(readFile(''))`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default()],
+ });
+ eval(res.outputFiles[0].text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test('does not include global keyword', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default()],
+ });
+ const text = res.outputFiles[0].text;
+ eval(text);
+ expect(text).not.toContain(/\bglobal\b/);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test('works with globals polyfills', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield esbuild_1.build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [_1.default(), node_globals_polyfill_1.default()],
+ });
+ const text = res.outputFiles[0].text;
+ eval(text);
+ console.log(text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+//# sourceMappingURL=index.test.js.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js.map b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js.map
new file mode 100644
index 0000000..e8a76e6
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qCAA+B;AAC/B,+CAAyC;AACzC,4CAAmB;AACnB,yCAA0C;AAC1C,mGAA+E;AAE/E,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAA;AAExD,IAAI,CAAC,OAAO,EAAE,GAAS,EAAE;IACrB,MAAM,EACF,MAAM,EACN,KAAK,EAAE,CAAC,KAAK,CAAC,GACjB,GAAG,MAAM,yBAAU,CAAC;QACjB,UAAU,EAAE,4CAA4C;QACxD,UAAU,EAAE,uHAAuH;KACtI,CAAC,CAAA;IACF,qCAAqC;IACrC,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC;QACpB,WAAW,EAAE,CAAC,KAAK,CAAC;QACpB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,CAAC,UAA0B,EAAE,CAAC;KAC1C,CAAC,CAAA;IACF,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAC7B,uCAAuC;IACvC,MAAM,EAAE,CAAA;AACZ,CAAC,CAAA,CAAC,CAAA;AAEF,IAAI,CAAC,mDAAmD,EAAE,GAAS,EAAE;IACjE,MAAM,EACF,MAAM,EACN,KAAK,EAAE,CAAC,KAAK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AAEF,IAAI,CAAC,8BAA8B,EAAE,GAAS,EAAE;IAC5C,MAAM,EACF,MAAM,EACN,KAAK,EAAE,CAAC,KAAK,CAAC,GACjB,GAAG,MAAM,yBAAU,CAAC;QACjB,UAAU,EAAE,4CAA4C;QACxD,UAAU,EAAE,uHAAuH;KACtI,CAAC,CAAA;IACF,qCAAqC;IACrC,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC;QACpB,WAAW,EAAE,CAAC,KAAK,CAAC;QACpB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,CAAC,UAA0B,EAAE,EAAE,+BAA0B,EAAE,CAAC;KACxE,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACpC,IAAI,CAAC,IAAI,CAAC,CAAA;IACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACjB,uCAAuC;IACvC,MAAM,EAAE,CAAA;AACZ,CAAC,CAAA,CAAC,CAAA"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts
new file mode 100644
index 0000000..564adc1
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts
@@ -0,0 +1,2 @@
+export declare function builtinsPolyfills(): Map<any, any>;
+//# sourceMappingURL=polyfills.d.ts.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts.map b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts.map
new file mode 100644
index 0000000..2f7b592
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAQA,wBAAgB,iBAAiB,kBA8IhC"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js
new file mode 100644
index 0000000..4f4f953
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js
@@ -0,0 +1,61 @@
+"use strict";
+// Taken from https://github.com/ionic-team/rollup-plugin-node-polyfills/blob/master/src/modules.ts
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.builtinsPolyfills = void 0;
+const EMPTY_PATH = require.resolve('rollup-plugin-node-polyfills/polyfills/empty.js');
+function builtinsPolyfills() {
+ const libs = new Map();
+ libs.set('process', require.resolve('rollup-plugin-node-polyfills/polyfills/process-es6'));
+ libs.set('buffer', require.resolve('rollup-plugin-node-polyfills/polyfills/buffer-es6'));
+ libs.set('util', require.resolve('rollup-plugin-node-polyfills/polyfills/util'));
+ libs.set('sys', libs.get('util'));
+ libs.set('events', require.resolve('rollup-plugin-node-polyfills/polyfills/events'));
+ libs.set('stream', require.resolve('rollup-plugin-node-polyfills/polyfills/stream'));
+ libs.set('path', require.resolve('rollup-plugin-node-polyfills/polyfills/path'));
+ libs.set('querystring', require.resolve('rollup-plugin-node-polyfills/polyfills/qs'));
+ libs.set('punycode', require.resolve('rollup-plugin-node-polyfills/polyfills/punycode'));
+ libs.set('url', require.resolve('rollup-plugin-node-polyfills/polyfills/url'));
+ libs.set('string_decoder', require.resolve('rollup-plugin-node-polyfills/polyfills/string-decoder'));
+ libs.set('http', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
+ libs.set('https', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
+ libs.set('os', require.resolve('rollup-plugin-node-polyfills/polyfills/os'));
+ libs.set('assert', require.resolve('rollup-plugin-node-polyfills/polyfills/assert'));
+ libs.set('constants', require.resolve('rollup-plugin-node-polyfills/polyfills/constants'));
+ libs.set('_stream_duplex', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/duplex'));
+ libs.set('_stream_passthrough', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough'));
+ libs.set('_stream_readable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/readable'));
+ libs.set('_stream_writable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/writable'));
+ libs.set('_stream_transform', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/transform'));
+ libs.set('timers', require.resolve('rollup-plugin-node-polyfills/polyfills/timers'));
+ libs.set('console', require.resolve('rollup-plugin-node-polyfills/polyfills/console'));
+ libs.set('vm', require.resolve('rollup-plugin-node-polyfills/polyfills/vm'));
+ libs.set('zlib', require.resolve('rollup-plugin-node-polyfills/polyfills/zlib'));
+ libs.set('tty', require.resolve('rollup-plugin-node-polyfills/polyfills/tty'));
+ libs.set('domain', require.resolve('rollup-plugin-node-polyfills/polyfills/domain'));
+ // not shimmed
+ libs.set('dns', EMPTY_PATH);
+ libs.set('dgram', EMPTY_PATH);
+ libs.set('child_process', EMPTY_PATH);
+ libs.set('cluster', EMPTY_PATH);
+ libs.set('module', EMPTY_PATH);
+ libs.set('net', EMPTY_PATH);
+ libs.set('readline', EMPTY_PATH);
+ libs.set('repl', EMPTY_PATH);
+ libs.set('tls', EMPTY_PATH);
+ libs.set('fs', EMPTY_PATH);
+ libs.set('crypto', EMPTY_PATH);
+ // libs.set(
+ // 'fs',
+ // require.resolve('rollup-plugin-node-polyfills/polyfills/browserify-fs'),
+ // )
+ // TODO enable crypto and fs https://github.com/ionic-team/rollup-plugin-node-polyfills/issues/20
+ // libs.set(
+ // 'crypto',
+ // require.resolve(
+ // 'rollup-plugin-node-polyfills/polyfills/crypto-browserify',
+ // ),
+ // )
+ return libs;
+}
+exports.builtinsPolyfills = builtinsPolyfills;
+//# sourceMappingURL=polyfills.js.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js.map b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js.map
new file mode 100644
index 0000000..a7ef0e3
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":";AAAA,mGAAmG;;;AAInG,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAC9B,iDAAiD,CACpD,CAAA;AAED,SAAgB,iBAAiB;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;IAEtB,IAAI,CAAC,GAAG,CACJ,SAAS,EACT,OAAO,CAAC,OAAO,CAAC,oDAAoD,CAAC,CACxE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,mDAAmD,CAAC,CACvE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,MAAM,EACN,OAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CACjE,CAAA;IACD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,+CAA+C,CAAC,CACnE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,+CAA+C,CAAC,CACnE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,MAAM,EACN,OAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CACjE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,aAAa,EACb,OAAO,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAC/D,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,UAAU,EACV,OAAO,CAAC,OAAO,CAAC,iDAAiD,CAAC,CACrE,CAAA;IACD,IAAI,CAAC,G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AEJ,OAAO,IAAI,CAAA;AACf,CAAC;AA9ID,8CA8IC"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts
new file mode 100644
index 0000000..65d4193
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts
@@ -0,0 +1,8 @@
+import { Plugin } from 'esbuild';
+export interface NodePolyfillsOptions {
+ name?: string;
+ namespace?: string;
+}
+export declare function NodeModulesPolyfillPlugin(options?: NodePolyfillsOptions): Plugin;
+export default NodeModulesPolyfillPlugin;
+//# sourceMappingURL=index.d.ts.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts.map b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts.map
new file mode 100644
index 0000000..c1151f9
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAA;AAkB/C,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,yBAAyB,CACrC,OAAO,GAAE,oBAAyB,GACnC,MAAM,CAwFR;AAmBD,eAAe,yBAAyB,CAAA"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js
new file mode 100644
index 0000000..69526b5
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js
@@ -0,0 +1,120 @@
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+import escapeStringRegexp from 'escape-string-regexp';
+import fs from 'fs';
+import path from 'path';
+import { builtinsPolyfills } from './polyfills';
+// import { NodeResolvePlugin } from '@esbuild-plugins/node-resolve'
+const NAME = 'node-modules-polyfills';
+const NAMESPACE = NAME;
+function removeEndingSlash(importee) {
+ if (importee && importee.slice(-1) === '/') {
+ importee = importee.slice(0, -1);
+ }
+ return importee;
+}
+export function NodeModulesPolyfillPlugin(options = {}) {
+ const { namespace = NAMESPACE, name = NAME } = options;
+ if (namespace.endsWith('commonjs')) {
+ throw new Error(`namespace ${namespace} must not end with commonjs`);
+ }
+ // this namespace is needed to make ES modules expose their default export to require: require('assert') will give you import('assert').default
+ const commonjsNamespace = namespace + '-commonjs';
+ const polyfilledBuiltins = builtinsPolyfills();
+ const polyfilledBuiltinsNames = [...polyfilledBuiltins.keys()];
+ return {
+ name,
+ setup: function setup({ onLoad, onResolve, initialOptions }) {
+ var _a;
+ // polyfills contain global keyword, it must be defined
+ if ((initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define) && !((_a = initialOptions.define) === null || _a === void 0 ? void 0 : _a.global)) {
+ initialOptions.define['global'] = 'globalThis';
+ }
+ else if (!(initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define)) {
+ initialOptions.define = { global: 'globalThis' };
+ }
+ // TODO these polyfill module cannot import anything, is that ok?
+ function loader(args) {
+ return __awaiter(this, void 0, void 0, function* () {
+ try {
+ const argsPath = args.path.replace(/^node:/, '');
+ const isCommonjs = args.namespace.endsWith('commonjs');
+ const resolved = polyfilledBuiltins.get(removeEndingSlash(argsPath));
+ const contents = yield (yield fs.promises.readFile(resolved)).toString();
+ let resolveDir = path.dirname(resolved);
+ if (isCommonjs) {
+ return {
+ loader: 'js',
+ contents: commonJsTemplate({
+ importPath: argsPath,
+ }),
+ resolveDir,
+ };
+ }
+ return {
+ loader: 'js',
+ contents,
+ resolveDir,
+ };
+ }
+ catch (e) {
+ console.error('node-modules-polyfill', e);
+ return {
+ contents: `export {}`,
+ loader: 'js',
+ };
+ }
+ });
+ }
+ onLoad({ filter: /.*/, namespace }, loader);
+ onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);
+ const filter = new RegExp([
+ ...polyfilledBuiltinsNames,
+ ...polyfilledBuiltinsNames.map((n) => `node:${n}`),
+ ]
+ .map(escapeStringRegexp)
+ .join('|'));
+ function resolver(args) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const argsPath = args.path.replace(/^node:/, '');
+ const ignoreRequire = args.namespace === commonjsNamespace;
+ if (!polyfilledBuiltins.has(argsPath)) {
+ return;
+ }
+ const isCommonjs = !ignoreRequire && args.kind === 'require-call';
+ return {
+ namespace: isCommonjs ? commonjsNamespace : namespace,
+ path: argsPath,
+ };
+ });
+ }
+ onResolve({ filter }, resolver);
+ // onResolve({ filter: /.*/, namespace }, resolver)
+ },
+ };
+}
+function commonJsTemplate({ importPath }) {
+ return `
+const polyfill = require('${importPath}')
+
+if (polyfill && polyfill.default) {
+ module.exports = polyfill.default
+ for (let k in polyfill) {
+ module.exports[k] = polyfill[k]
+ }
+} else if (polyfill) {
+ module.exports = polyfill
+}
+
+
+`;
+}
+export default NodeModulesPolyfillPlugin;
+//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js.map b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js.map
new file mode 100644
index 0000000..c8544ab
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],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,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,EAAE,MAAM,CAAC,CAAA;YAC9D,MAAM,MAAM,GAAG,IAAI,MAAM,CACrB;gBACI,GAAG,uBAAuB;gBAC1B,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;aACrD;iBACI,GAAG,CAAC,kBAAkB,CAAC;iBACvB,IAAI,CAAC,GAAG,CAAC,CACjB,CAAA;YACD,SAAe,QAAQ,CAAC,IAAmB;;oBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;oBAChD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,KAAK,iBAAiB,CAAA;oBAE1D,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;wBACnC,OAAM;qBACT;oBAED,MAAM,UAAU,GACZ,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;oBAElD,OAAO;wBACH,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;wBACrD,IAAI,EAAE,QAAQ;qBACjB,CAAA;gBACL,CAAC;aAAA;YACD,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;YAC/B,mDAAmD;QACvD,CAAC;KACJ,CAAA;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAE,UAAU,EAAE;IACpC,OAAO;4BACiB,UAAU;;;;;;;;;;;;CAYrC,CAAA;AACD,CAAC;AAED,eAAe,yBAAyB,CAAA"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts
new file mode 100644
index 0000000..121d59b
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts
@@ -0,0 +1,2 @@
+export {};
+//# sourceMappingURL=index.test.d.ts.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts.map b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts.map
new file mode 100644
index 0000000..b5774e1
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js
new file mode 100644
index 0000000..b4ff899
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js
@@ -0,0 +1,178 @@
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+import { build } from 'esbuild';
+import { writeFiles } from 'test-support';
+import fs from 'fs';
+import NodeModulesPolyfillsPlugin from '.';
+import NodeGlobalsPolyfillsPlugin from '@esbuild-plugins/node-globals-polyfill';
+require('debug').enable(require('../package.json').name);
+test('works', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ });
+ eval(res.outputFiles[0].text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test('works with SafeBuffer and other package consumers', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `import {Buffer as SafeBuffer} from './safe-buffer'; console.log(SafeBuffer);`,
+ 'safe-buffer.ts': fs
+ .readFileSync(require.resolve('safe-buffer'))
+ .toString(),
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ });
+ // console.log(
+ // res.outputFiles[0].text
+ // .split('\n')
+ // .map((x, i) => i + ' ' + x)
+ // .join('\n'),
+ // )
+ eval(res.outputFiles[0].text);
+ unlink();
+}));
+test('events works', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `
+ import EventEmitter from 'events';
+
+ class Test extends EventEmitter {
+ constructor() { };
+ }
+ console.log(Test)
+ `,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ });
+ // console.log(res.outputFiles[0].text)
+ eval(res.outputFiles[0].text);
+ unlink();
+}));
+test('require can use default export', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `
+ const assert = require('assert')
+ // console.log(assert)
+ assert('ok')
+ `,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ });
+ // console.log(res.outputFiles[0].text)
+ eval(res.outputFiles[0].text);
+ unlink();
+}));
+test.skip('crypto', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `import { randomBytes } from 'crypto'; console.log(randomBytes(20).toString('hex'))`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ });
+ eval(res.outputFiles[0].text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test.skip('fs', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `import { readFile } from 'fs'; console.log(readFile(''))`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ });
+ eval(res.outputFiles[0].text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test('does not include global keyword', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ });
+ const text = res.outputFiles[0].text;
+ eval(text);
+ expect(text).not.toContain(/\bglobal\b/);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+test('works with globals polyfills', () => __awaiter(void 0, void 0, void 0, function* () {
+ const { unlink, paths: [ENTRY], } = yield writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ });
+ // const outfile = randomOutputFile()
+ const res = yield build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin(), NodeGlobalsPolyfillsPlugin()],
+ });
+ const text = res.outputFiles[0].text;
+ eval(text);
+ console.log(text);
+ // console.log(res.outputFiles[0].text)
+ unlink();
+}));
+//# sourceMappingURL=index.test.js.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js.map b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js.map
new file mode 100644
index 0000000..9e80cfd
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,0BAA0B,MAAM,GAAG,CAAA;AAC1C,OAAO,0BAA0B,MAAM,wCAAwC,CAAA;AAE/E,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAA;AAExD,IAAI,CAAC,OAAO,EAAE,GAAS,EAAE;IACrB,MAAM,EACF,MAAM,EACN,KAAK,EAAE,CAAC,KAAK,CAAC,GACjB,GAAG,MAAM,UAAU,CAAC;QACjB,UAAU,EAAE,4CAA4C;QACxD,UAAU,EAAE,uHAAuH;KACtI,CAAC,CAAA;IACF,qCAAqC;IACrC,MAAM,GAAG,GAAG,MAAM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uild-plugins/node-modules-polyfill/esm/polyfills.d.ts
new file mode 100644
index 0000000..564adc1
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts
@@ -0,0 +1,2 @@
+export declare function builtinsPolyfills(): Map<any, any>;
+//# sourceMappingURL=polyfills.d.ts.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts.map b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts.map
new file mode 100644
index 0000000..2f7b592
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAQA,wBAAgB,iBAAiB,kBA8IhC"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js
new file mode 100644
index 0000000..28b0ea7
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js
@@ -0,0 +1,57 @@
+// Taken from https://github.com/ionic-team/rollup-plugin-node-polyfills/blob/master/src/modules.ts
+const EMPTY_PATH = require.resolve('rollup-plugin-node-polyfills/polyfills/empty.js');
+export function builtinsPolyfills() {
+ const libs = new Map();
+ libs.set('process', require.resolve('rollup-plugin-node-polyfills/polyfills/process-es6'));
+ libs.set('buffer', require.resolve('rollup-plugin-node-polyfills/polyfills/buffer-es6'));
+ libs.set('util', require.resolve('rollup-plugin-node-polyfills/polyfills/util'));
+ libs.set('sys', libs.get('util'));
+ libs.set('events', require.resolve('rollup-plugin-node-polyfills/polyfills/events'));
+ libs.set('stream', require.resolve('rollup-plugin-node-polyfills/polyfills/stream'));
+ libs.set('path', require.resolve('rollup-plugin-node-polyfills/polyfills/path'));
+ libs.set('querystring', require.resolve('rollup-plugin-node-polyfills/polyfills/qs'));
+ libs.set('punycode', require.resolve('rollup-plugin-node-polyfills/polyfills/punycode'));
+ libs.set('url', require.resolve('rollup-plugin-node-polyfills/polyfills/url'));
+ libs.set('string_decoder', require.resolve('rollup-plugin-node-polyfills/polyfills/string-decoder'));
+ libs.set('http', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
+ libs.set('https', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
+ libs.set('os', require.resolve('rollup-plugin-node-polyfills/polyfills/os'));
+ libs.set('assert', require.resolve('rollup-plugin-node-polyfills/polyfills/assert'));
+ libs.set('constants', require.resolve('rollup-plugin-node-polyfills/polyfills/constants'));
+ libs.set('_stream_duplex', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/duplex'));
+ libs.set('_stream_passthrough', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough'));
+ libs.set('_stream_readable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/readable'));
+ libs.set('_stream_writable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/writable'));
+ libs.set('_stream_transform', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/transform'));
+ libs.set('timers', require.resolve('rollup-plugin-node-polyfills/polyfills/timers'));
+ libs.set('console', require.resolve('rollup-plugin-node-polyfills/polyfills/console'));
+ libs.set('vm', require.resolve('rollup-plugin-node-polyfills/polyfills/vm'));
+ libs.set('zlib', require.resolve('rollup-plugin-node-polyfills/polyfills/zlib'));
+ libs.set('tty', require.resolve('rollup-plugin-node-polyfills/polyfills/tty'));
+ libs.set('domain', require.resolve('rollup-plugin-node-polyfills/polyfills/domain'));
+ // not shimmed
+ libs.set('dns', EMPTY_PATH);
+ libs.set('dgram', EMPTY_PATH);
+ libs.set('child_process', EMPTY_PATH);
+ libs.set('cluster', EMPTY_PATH);
+ libs.set('module', EMPTY_PATH);
+ libs.set('net', EMPTY_PATH);
+ libs.set('readline', EMPTY_PATH);
+ libs.set('repl', EMPTY_PATH);
+ libs.set('tls', EMPTY_PATH);
+ libs.set('fs', EMPTY_PATH);
+ libs.set('crypto', EMPTY_PATH);
+ // libs.set(
+ // 'fs',
+ // require.resolve('rollup-plugin-node-polyfills/polyfills/browserify-fs'),
+ // )
+ // TODO enable crypto and fs https://github.com/ionic-team/rollup-plugin-node-polyfills/issues/20
+ // libs.set(
+ // 'crypto',
+ // require.resolve(
+ // 'rollup-plugin-node-polyfills/polyfills/crypto-browserify',
+ // ),
+ // )
+ return libs;
+}
+//# sourceMappingURL=polyfills.js.map \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js.map b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js.map
new file mode 100644
index 0000000..3c35ae4
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAInG,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAC9B,iDAAiD,CACpD,CAAA;AAED,MAAM,UAAU,iBAAiB;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;IAEtB,IAAI,CAAC,GAAG,CACJ,SAAS,EACT,OAAO,CAAC,OAAO,CAAC,oDAAoD,CAAC,CACxE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,mDAAmD,CAAC,CACvE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,MAAM,EACN,OAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CACjE,CAAA;IACD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,+CAA+C,CAAC,CACnE,CAAA;IACD,IAAI,CAAC,G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MAAM,EAAE,UAAU,CAAC,CAAA;IAC5B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IAC3B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAC1B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IAE9B,YAAY;IACZ,YAAY;IACZ,+EAA+E;IAC/E,IAAI;IAEJ,iGAAiG;IACjG,YAAY;IACZ,gBAAgB;IAChB,uBAAuB;IACvB,sEAAsE;IACtE,SAAS;IACT,IAAI;IAEJ,OAAO,IAAI,CAAA;AACf,CAAC"} \ No newline at end of file
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/package.json b/node_modules/@esbuild-plugins/node-modules-polyfill/package.json
new file mode 100644
index 0000000..d9a6e41
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "@esbuild-plugins/node-modules-polyfill",
+ "version": "0.2.2",
+ "description": "",
+ "main": "dist/index.js",
+ "module": "esm/index.js",
+ "types": "dist/index.d.ts",
+ "repository": "https://github.com/remorses/esbuild-plugins.git",
+ "scripts": {
+ "build": "tsc && tsc -m es6 --outDir esm",
+ "watch": "tsc -w"
+ },
+ "files": [
+ "dist",
+ "src",
+ "esm"
+ ],
+ "keywords": [],
+ "author": "Tommaso De Rossi, morse <beats.by.morse@gmail.com>",
+ "license": "ISC",
+ "devDependencies": {
+ "safe-buffer": "^5.2.1",
+ "test-support": "*",
+ "@esbuild-plugins/node-globals-polyfill": "*"
+ },
+ "dependencies": {
+ "escape-string-regexp": "^4.0.0",
+ "rollup-plugin-node-polyfills": "^0.2.1"
+ },
+ "peerDependencies": {
+ "esbuild": "*"
+ }
+}
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.test.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.test.ts
new file mode 100644
index 0000000..92792e6
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.test.ts
@@ -0,0 +1,200 @@
+import { build } from 'esbuild'
+import { writeFiles } from 'test-support'
+import fs from 'fs'
+import NodeModulesPolyfillsPlugin from '.'
+import NodeGlobalsPolyfillsPlugin from '@esbuild-plugins/node-globals-polyfill'
+
+require('debug').enable(require('../package.json').name)
+
+test('works', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ })
+ eval(res.outputFiles[0].text)
+ // console.log(res.outputFiles[0].text)
+ unlink()
+})
+
+test('works with SafeBuffer and other package consumers', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `import {Buffer as SafeBuffer} from './safe-buffer'; console.log(SafeBuffer);`,
+ 'safe-buffer.ts': fs
+ .readFileSync(require.resolve('safe-buffer'))
+ .toString(),
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ })
+ // console.log(
+ // res.outputFiles[0].text
+ // .split('\n')
+ // .map((x, i) => i + ' ' + x)
+ // .join('\n'),
+ // )
+ eval(res.outputFiles[0].text)
+ unlink()
+})
+
+test('events works', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `
+ import EventEmitter from 'events';
+
+ class Test extends EventEmitter {
+ constructor() { };
+ }
+ console.log(Test)
+ `,
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ })
+ // console.log(res.outputFiles[0].text)
+ eval(res.outputFiles[0].text)
+ unlink()
+})
+
+test('require can use default export', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `
+ const assert = require('assert')
+ // console.log(assert)
+ assert('ok')
+ `,
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ })
+ // console.log(res.outputFiles[0].text)
+ eval(res.outputFiles[0].text)
+ unlink()
+})
+
+test.skip('crypto', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `import { randomBytes } from 'crypto'; console.log(randomBytes(20).toString('hex'))`,
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ })
+ eval(res.outputFiles[0].text)
+ // console.log(res.outputFiles[0].text)
+ unlink()
+})
+test.skip('fs', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `import { readFile } from 'fs'; console.log(readFile(''))`,
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ })
+ eval(res.outputFiles[0].text)
+ // console.log(res.outputFiles[0].text)
+ unlink()
+})
+
+test('does not include global keyword', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin()],
+ })
+ const text = res.outputFiles[0].text
+ eval(text)
+ expect(text).not.toContain(/\bglobal\b/)
+ // console.log(res.outputFiles[0].text)
+ unlink()
+})
+
+test('works with globals polyfills', async () => {
+ const {
+ unlink,
+ paths: [ENTRY],
+ } = await writeFiles({
+ 'entry.ts': `import {x} from './utils'; console.log(x);`,
+ 'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
+ })
+ // const outfile = randomOutputFile()
+ const res = await build({
+ entryPoints: [ENTRY],
+ write: false,
+ format: 'esm',
+ target: 'es2017',
+ bundle: true,
+ plugins: [NodeModulesPolyfillsPlugin(), NodeGlobalsPolyfillsPlugin()],
+ })
+ const text = res.outputFiles[0].text
+ eval(text)
+ console.log(text)
+ // console.log(res.outputFiles[0].text)
+ unlink()
+})
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.ts
new file mode 100644
index 0000000..f7397e4
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.ts
@@ -0,0 +1,133 @@
+import { OnResolveArgs, Plugin } from 'esbuild'
+import escapeStringRegexp from 'escape-string-regexp'
+import fs from 'fs'
+import path from 'path'
+import esbuild from 'esbuild'
+import { builtinsPolyfills } from './polyfills'
+
+// import { NodeResolvePlugin } from '@esbuild-plugins/node-resolve'
+const NAME = 'node-modules-polyfills'
+const NAMESPACE = NAME
+
+function removeEndingSlash(importee) {
+ if (importee && importee.slice(-1) === '/') {
+ importee = importee.slice(0, -1)
+ }
+ return importee
+}
+
+export interface NodePolyfillsOptions {
+ name?: string
+ namespace?: string
+}
+
+export function NodeModulesPolyfillPlugin(
+ options: NodePolyfillsOptions = {},
+): Plugin {
+ const { namespace = NAMESPACE, name = NAME } = options
+ if (namespace.endsWith('commonjs')) {
+ throw new Error(`namespace ${namespace} must not end with commonjs`)
+ }
+ // this namespace is needed to make ES modules expose their default export to require: require('assert') will give you import('assert').default
+ const commonjsNamespace = namespace + '-commonjs'
+ const polyfilledBuiltins = builtinsPolyfills()
+ const polyfilledBuiltinsNames = [...polyfilledBuiltins.keys()]
+
+ return {
+ name,
+ setup: function setup({ onLoad, onResolve, initialOptions }) {
+ // polyfills contain global keyword, it must be defined
+ if (initialOptions?.define && !initialOptions.define?.global) {
+ initialOptions.define['global'] = 'globalThis'
+ } else if (!initialOptions?.define) {
+ initialOptions.define = { global: 'globalThis' }
+ }
+
+ // TODO these polyfill module cannot import anything, is that ok?
+ async function loader(
+ args: esbuild.OnLoadArgs,
+ ): Promise<esbuild.OnLoadResult> {
+ try {
+ const argsPath = args.path.replace(/^node:/, '')
+ const isCommonjs = args.namespace.endsWith('commonjs')
+
+ const resolved = polyfilledBuiltins.get(
+ removeEndingSlash(argsPath),
+ )
+ const contents = await (
+ await fs.promises.readFile(resolved)
+ ).toString()
+ let resolveDir = path.dirname(resolved)
+
+ if (isCommonjs) {
+ return {
+ loader: 'js',
+ contents: commonJsTemplate({
+ importPath: argsPath,
+ }),
+ resolveDir,
+ }
+ }
+ return {
+ loader: 'js',
+ contents,
+ resolveDir,
+ }
+ } catch (e) {
+ console.error('node-modules-polyfill', e)
+ return {
+ contents: `export {}`,
+ loader: 'js',
+ }
+ }
+ }
+ onLoad({ filter: /.*/, namespace }, loader)
+ onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader)
+ const filter = new RegExp(
+ [
+ ...polyfilledBuiltinsNames,
+ ...polyfilledBuiltinsNames.map((n) => `node:${n}`),
+ ]
+ .map(escapeStringRegexp)
+ .join('|'), // TODO builtins could end with slash, keep in mind in regex
+ )
+ async function resolver(args: OnResolveArgs) {
+ const argsPath = args.path.replace(/^node:/, '')
+ const ignoreRequire = args.namespace === commonjsNamespace
+
+ if (!polyfilledBuiltins.has(argsPath)) {
+ return
+ }
+
+ const isCommonjs =
+ !ignoreRequire && args.kind === 'require-call'
+
+ return {
+ namespace: isCommonjs ? commonjsNamespace : namespace,
+ path: argsPath,
+ }
+ }
+ onResolve({ filter }, resolver)
+ // onResolve({ filter: /.*/, namespace }, resolver)
+ },
+ }
+}
+
+function commonJsTemplate({ importPath }) {
+ return `
+const polyfill = require('${importPath}')
+
+if (polyfill && polyfill.default) {
+ module.exports = polyfill.default
+ for (let k in polyfill) {
+ module.exports[k] = polyfill[k]
+ }
+} else if (polyfill) {
+ module.exports = polyfill
+}
+
+
+`
+}
+
+export default NodeModulesPolyfillPlugin
diff --git a/node_modules/@esbuild-plugins/node-modules-polyfill/src/polyfills.ts b/node_modules/@esbuild-plugins/node-modules-polyfill/src/polyfills.ts
new file mode 100644
index 0000000..cea5f8d
--- /dev/null
+++ b/node_modules/@esbuild-plugins/node-modules-polyfill/src/polyfills.ts
@@ -0,0 +1,151 @@
+// Taken from https://github.com/ionic-team/rollup-plugin-node-polyfills/blob/master/src/modules.ts
+
+import { NodePolyfillsOptions } from '.'
+
+const EMPTY_PATH = require.resolve(
+ 'rollup-plugin-node-polyfills/polyfills/empty.js',
+)
+
+export function builtinsPolyfills() {
+ const libs = new Map()
+
+ libs.set(
+ 'process',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/process-es6'),
+ )
+ libs.set(
+ 'buffer',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/buffer-es6'),
+ )
+ libs.set(
+ 'util',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/util'),
+ )
+ libs.set('sys', libs.get('util'))
+ libs.set(
+ 'events',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/events'),
+ )
+ libs.set(
+ 'stream',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/stream'),
+ )
+ libs.set(
+ 'path',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/path'),
+ )
+ libs.set(
+ 'querystring',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/qs'),
+ )
+ libs.set(
+ 'punycode',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/punycode'),
+ )
+ libs.set(
+ 'url',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/url'),
+ )
+ libs.set(
+ 'string_decoder',
+ require.resolve(
+ 'rollup-plugin-node-polyfills/polyfills/string-decoder',
+ ),
+ )
+ libs.set(
+ 'http',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/http'),
+ )
+ libs.set(
+ 'https',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/http'),
+ )
+ libs.set('os', require.resolve('rollup-plugin-node-polyfills/polyfills/os'))
+ libs.set(
+ 'assert',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/assert'),
+ )
+ libs.set(
+ 'constants',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/constants'),
+ )
+ libs.set(
+ '_stream_duplex',
+ require.resolve(
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/duplex',
+ ),
+ )
+ libs.set(
+ '_stream_passthrough',
+ require.resolve(
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough',
+ ),
+ )
+ libs.set(
+ '_stream_readable',
+ require.resolve(
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/readable',
+ ),
+ )
+ libs.set(
+ '_stream_writable',
+ require.resolve(
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/writable',
+ ),
+ )
+ libs.set(
+ '_stream_transform',
+ require.resolve(
+ 'rollup-plugin-node-polyfills/polyfills/readable-stream/transform',
+ ),
+ )
+ libs.set(
+ 'timers',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/timers'),
+ )
+ libs.set(
+ 'console',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/console'),
+ )
+ libs.set('vm', require.resolve('rollup-plugin-node-polyfills/polyfills/vm'))
+ libs.set(
+ 'zlib',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/zlib'),
+ )
+ libs.set(
+ 'tty',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/tty'),
+ )
+ libs.set(
+ 'domain',
+ require.resolve('rollup-plugin-node-polyfills/polyfills/domain'),
+ )
+
+ // not shimmed
+ libs.set('dns', EMPTY_PATH)
+ libs.set('dgram', EMPTY_PATH)
+ libs.set('child_process', EMPTY_PATH)
+ libs.set('cluster', EMPTY_PATH)
+ libs.set('module', EMPTY_PATH)
+ libs.set('net', EMPTY_PATH)
+ libs.set('readline', EMPTY_PATH)
+ libs.set('repl', EMPTY_PATH)
+ libs.set('tls', EMPTY_PATH)
+ libs.set('fs', EMPTY_PATH)
+ libs.set('crypto', EMPTY_PATH)
+
+ // libs.set(
+ // 'fs',
+ // require.resolve('rollup-plugin-node-polyfills/polyfills/browserify-fs'),
+ // )
+
+ // TODO enable crypto and fs https://github.com/ionic-team/rollup-plugin-node-polyfills/issues/20
+ // libs.set(
+ // 'crypto',
+ // require.resolve(
+ // 'rollup-plugin-node-polyfills/polyfills/crypto-browserify',
+ // ),
+ // )
+
+ return libs
+}