mirror of
https://github.com/JonasunderscoreJones/api.jonasjones.dev.git
synced 2025-10-23 12:09:19 +02:00
Initial commit (by create-cloudflare CLI)
This commit is contained in:
commit
58a42872a0
1745 changed files with 741893 additions and 0 deletions
2168
node_modules/@esbuild-plugins/node-globals-polyfill/Buffer.js
generated
vendored
Normal file
2168
node_modules/@esbuild-plugins/node-globals-polyfill/Buffer.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export { Buffer } from '_node-buffer-polyfill_.js'
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/_process.js
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/_process.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export { process } from '_node-process-polyfill_.js'
|
7
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.d.ts
generated
vendored
Normal file
7
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import * as esbuild from 'esbuild';
|
||||
export declare function NodeGlobalsPolyfillPlugin({ buffer, process, }?: {
|
||||
buffer?: boolean | undefined;
|
||||
process?: boolean | undefined;
|
||||
}): esbuild.Plugin;
|
||||
export default NodeGlobalsPolyfillPlugin;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAElC,wBAAgB,yBAAyB,CAAC,EACtC,MAAc,EAEd,OAAc,GACjB;;;CAAK,GAAG,OAAO,CAAC,MAAM,CAyEtB;AAED,eAAe,yBAAyB,CAAA"}
|
80
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.js
generated
vendored
Normal file
80
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NodeGlobalsPolyfillPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
function NodeGlobalsPolyfillPlugin({ buffer = false,
|
||||
// define = {},
|
||||
process = true, } = {}) {
|
||||
return {
|
||||
name: 'node-globals-polyfill',
|
||||
setup({ initialOptions, onResolve, onLoad }) {
|
||||
onResolve({ filter: /_node-buffer-polyfill_\.js/ }, (arg) => {
|
||||
return {
|
||||
path: path_1.default.resolve(__dirname, '../Buffer.js'),
|
||||
};
|
||||
});
|
||||
onResolve({ filter: /_node-process-polyfill_\.js/ }, (arg) => {
|
||||
return {
|
||||
path: path_1.default.resolve(__dirname, '../process.js'),
|
||||
};
|
||||
});
|
||||
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
||||
// onLoad({ filter: /_virtual-process-polyfill_\.js/ }, (arg) => {
|
||||
// const data = fs
|
||||
// .readFileSync(path.resolve(__dirname, '../process.js'))
|
||||
// .toString()
|
||||
// const keys = Object.keys(define)
|
||||
// return {
|
||||
// loader: 'js',
|
||||
// contents: data.replace(
|
||||
// `const defines = {}`,
|
||||
// 'const defines = {\n' +
|
||||
// keys
|
||||
// .filter((x) => x.startsWith('process.'))
|
||||
// .sort((a, b) => a.length - b.length)
|
||||
// .map(
|
||||
// (k) =>
|
||||
// ` ${JSON.stringify(k).replace(
|
||||
// 'process.',
|
||||
// '',
|
||||
// )}: ${define[k]},`,
|
||||
// )
|
||||
// .join('\n') +
|
||||
// '\n}',
|
||||
// ),
|
||||
// }
|
||||
// })
|
||||
onResolve({ filter: /_virtual-process-polyfill_\.js/ }, () => {
|
||||
return {
|
||||
path: path_1.default.resolve(__dirname, '../process.js'),
|
||||
};
|
||||
});
|
||||
onResolve({ filter: /_virtual-buffer-polyfill_\.js/ }, () => {
|
||||
return {
|
||||
path: path_1.default.resolve(__dirname, '../_buffer.js'),
|
||||
};
|
||||
});
|
||||
const polyfills = [];
|
||||
if (process) {
|
||||
polyfills.push(path_1.default.resolve(__dirname, '../_virtual-process-polyfill_.js'));
|
||||
}
|
||||
if (buffer) {
|
||||
polyfills.push(path_1.default.resolve(__dirname, '../_virtual-buffer-polyfill_.js'));
|
||||
}
|
||||
if (initialOptions.inject) {
|
||||
initialOptions.inject.push(...polyfills);
|
||||
// handle duplicate plugin
|
||||
initialOptions.inject = [...new Set(initialOptions.inject)];
|
||||
}
|
||||
else {
|
||||
initialOptions.inject = [...polyfills];
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.NodeGlobalsPolyfillPlugin = NodeGlobalsPolyfillPlugin;
|
||||
exports.default = NodeGlobalsPolyfillPlugin;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAIvB,SAAgB,yBAAyB,CAAC,EACtC,MAAM,GAAG,KAAK;AACd,eAAe;AACf,OAAO,GAAG,IAAI,GACjB,GAAG,EAAE;IACF,OAAO;QACH,IAAI,EAAE,uBAAuB;QAC7B,KAAK,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE;YACvC,SAAS,CAAC,EAAE,MAAM,EAAE,4BAA4B,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AAA;aACJ;YACD,IAAI,MAAM,EAAE;gBACR,SAAS,CAAC,IAAI,CACV,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAC7D,CAAA;aACJ;YACD,IAAI,cAAc,CAAC,MAAM,EAAE;gBACvB,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAA;gBACxC,0BAA0B;gBAC1B,cAAc,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;aAC9D;iBAAM;gBACH,cAAc,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAA;aACzC;QACL,CAAC;KACJ,CAAA;AACL,CAAC;AA7ED,8DA6EC;AAED,kBAAe,yBAAyB,CAAA"}
|
2
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.d.ts
generated
vendored
Normal file
2
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
export {};
|
||||
//# sourceMappingURL=index.test.d.ts.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.d.ts.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
139
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.js
generated
vendored
Normal file
139
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.js
generated
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
"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());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const esbuild_1 = require("esbuild");
|
||||
const test_support_1 = require("test-support");
|
||||
const _1 = require(".");
|
||||
require('debug').enable(require('../package.json').name);
|
||||
test('process works', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
||||
'entry.ts': `process.version`,
|
||||
});
|
||||
const res = yield esbuild_1.build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../process')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('process is tree shaken', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
||||
'entry.ts': `console.log('hei')`,
|
||||
});
|
||||
const res = yield esbuild_1.build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../process')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
expect(output).not.toContain('process');
|
||||
unlink();
|
||||
}));
|
||||
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
||||
test('process env vars are replaced with ones from define', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
||||
'entry.ts': `if (process.env.VAR !== 'hello') { throw new Error('process.env.VAR not right: ' + process.env.VAR) }`,
|
||||
});
|
||||
const res = yield esbuild_1.build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
define: {
|
||||
'process.env.VAR': '"hello"',
|
||||
},
|
||||
plugins: [_1.NodeGlobalsPolyfillPlugin({})],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('Buffer works', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
||||
'entry.ts': `console.log(Buffer.from('xxx').toString())`,
|
||||
});
|
||||
const res = yield esbuild_1.build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../Buffer')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('Buffer is tree shaken', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
||||
'entry.ts': `console.log('hei')`,
|
||||
});
|
||||
const res = yield esbuild_1.build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../Buffer')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
expect(output).not.toContain('Buffer');
|
||||
unlink();
|
||||
}));
|
||||
test('Buffer works using plugin', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
||||
'entry.ts': `
|
||||
let buf = new Buffer(256);
|
||||
let len = buf.write("Simply Easy Learning");
|
||||
console.log("Octets written : "+ len);`,
|
||||
});
|
||||
const res = yield esbuild_1.build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
plugins: [_1.NodeGlobalsPolyfillPlugin({ buffer: true })],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('process works using plugin', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
||||
'entry.ts': `console.log(process.cwd())`,
|
||||
});
|
||||
const res = yield esbuild_1.build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
plugins: [_1.NodeGlobalsPolyfillPlugin({ process: true })],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
//# sourceMappingURL=index.test.js.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.js.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/dist/index.test.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qCAA+B;AAC/B,+CAAyC;AACzC,wBAA6C;AAE7C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAA;AAExD,IAAI,CAAC,eAAe,EAAE,GAAS,EAAE;IAC7B,MAAM,EACF,MAAM,EACN,KAAK,EAAE,CAAC,KAAK,CAAC,GACjB,GAAG,MAAM,yBAAU,CAAC;QACjB,UAAU,EAAE,iBAAiB;KAChC,CAAC,CAAA;IACF,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC;QACpB,WAAW,EAAE,CAAC,KAAK,CAAC;QACpB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KA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CAAA;IACF,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,4BAAyB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;KAC1D,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACtC,sBAAsB;IACtB,IAAI,CAAC,MAAM,CAAC,CAAA;IACZ,MAAM,EAAE,CAAA;AACZ,CAAC,CAAA,CAAC,CAAA"}
|
7
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.d.ts
generated
vendored
Normal file
7
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import * as esbuild from 'esbuild';
|
||||
export declare function NodeGlobalsPolyfillPlugin({ buffer, process, }?: {
|
||||
buffer?: boolean | undefined;
|
||||
process?: boolean | undefined;
|
||||
}): esbuild.Plugin;
|
||||
export default NodeGlobalsPolyfillPlugin;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAElC,wBAAgB,yBAAyB,CAAC,EACtC,MAAc,EAEd,OAAc,GACjB;;;CAAK,GAAG,OAAO,CAAC,MAAM,CAyEtB;AAED,eAAe,yBAAyB,CAAA"}
|
73
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.js
generated
vendored
Normal file
73
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.js
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
import path from 'path';
|
||||
export function NodeGlobalsPolyfillPlugin({ buffer = false,
|
||||
// define = {},
|
||||
process = true, } = {}) {
|
||||
return {
|
||||
name: 'node-globals-polyfill',
|
||||
setup({ initialOptions, onResolve, onLoad }) {
|
||||
onResolve({ filter: /_node-buffer-polyfill_\.js/ }, (arg) => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../Buffer.js'),
|
||||
};
|
||||
});
|
||||
onResolve({ filter: /_node-process-polyfill_\.js/ }, (arg) => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../process.js'),
|
||||
};
|
||||
});
|
||||
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
||||
// onLoad({ filter: /_virtual-process-polyfill_\.js/ }, (arg) => {
|
||||
// const data = fs
|
||||
// .readFileSync(path.resolve(__dirname, '../process.js'))
|
||||
// .toString()
|
||||
// const keys = Object.keys(define)
|
||||
// return {
|
||||
// loader: 'js',
|
||||
// contents: data.replace(
|
||||
// `const defines = {}`,
|
||||
// 'const defines = {\n' +
|
||||
// keys
|
||||
// .filter((x) => x.startsWith('process.'))
|
||||
// .sort((a, b) => a.length - b.length)
|
||||
// .map(
|
||||
// (k) =>
|
||||
// ` ${JSON.stringify(k).replace(
|
||||
// 'process.',
|
||||
// '',
|
||||
// )}: ${define[k]},`,
|
||||
// )
|
||||
// .join('\n') +
|
||||
// '\n}',
|
||||
// ),
|
||||
// }
|
||||
// })
|
||||
onResolve({ filter: /_virtual-process-polyfill_\.js/ }, () => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../process.js'),
|
||||
};
|
||||
});
|
||||
onResolve({ filter: /_virtual-buffer-polyfill_\.js/ }, () => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../_buffer.js'),
|
||||
};
|
||||
});
|
||||
const polyfills = [];
|
||||
if (process) {
|
||||
polyfills.push(path.resolve(__dirname, '../_virtual-process-polyfill_.js'));
|
||||
}
|
||||
if (buffer) {
|
||||
polyfills.push(path.resolve(__dirname, '../_virtual-buffer-polyfill_.js'));
|
||||
}
|
||||
if (initialOptions.inject) {
|
||||
initialOptions.inject.push(...polyfills);
|
||||
// handle duplicate plugin
|
||||
initialOptions.inject = [...new Set(initialOptions.inject)];
|
||||
}
|
||||
else {
|
||||
initialOptions.inject = [...polyfills];
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
export default NodeGlobalsPolyfillPlugin;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.js.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAIvB,MAAM,UAAU,yBAAyB,CAAC,EACtC,MAAM,GAAG,KAAK;AACd,eAAe;AACf,OAAO,GAAG,IAAI,GACjB,GAAG,EAAE;IACF,OAAO;QACH,IAAI,EAAE,uBAAuB;QAC7B,KAAK,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE;YACvC,SAAS,CAAC,EAAE,MAAM,EAAE,4BAA4B,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;gBACxD,OAAO;oBACH,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC;iBAChD,CAAA;YACL,CAAC,CAAC,CAAA;YACF,SAAS,CAAC,EAAE,MAAM,EAAE,6BAA6B,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;gBACzD,OAAO;oBACH,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC;iBACjD,CAAA;YACL,CAAC,CAAC,CAAA;YAEF,mGAAmG;YACnG,kEAAkE;Y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AAC,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAA;aACzC;QACL,CAAC;KACJ,CAAA;AACL,CAAC;AAED,eAAe,yBAAyB,CAAA"}
|
2
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.d.ts
generated
vendored
Normal file
2
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
export {};
|
||||
//# sourceMappingURL=index.test.d.ts.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.d.ts.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
137
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.js
generated
vendored
Normal file
137
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.js
generated
vendored
Normal file
|
@ -0,0 +1,137 @@
|
|||
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 { NodeGlobalsPolyfillPlugin } from '.';
|
||||
require('debug').enable(require('../package.json').name);
|
||||
test('process works', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
||||
'entry.ts': `process.version`,
|
||||
});
|
||||
const res = yield build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../process')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('process is tree shaken', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
||||
'entry.ts': `console.log('hei')`,
|
||||
});
|
||||
const res = yield build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../process')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
expect(output).not.toContain('process');
|
||||
unlink();
|
||||
}));
|
||||
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
||||
test('process env vars are replaced with ones from define', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
||||
'entry.ts': `if (process.env.VAR !== 'hello') { throw new Error('process.env.VAR not right: ' + process.env.VAR) }`,
|
||||
});
|
||||
const res = yield build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
define: {
|
||||
'process.env.VAR': '"hello"',
|
||||
},
|
||||
plugins: [NodeGlobalsPolyfillPlugin({})],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('Buffer works', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
||||
'entry.ts': `console.log(Buffer.from('xxx').toString())`,
|
||||
});
|
||||
const res = yield build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../Buffer')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('Buffer is tree shaken', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
||||
'entry.ts': `console.log('hei')`,
|
||||
});
|
||||
const res = yield build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../Buffer')],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
expect(output).not.toContain('Buffer');
|
||||
unlink();
|
||||
}));
|
||||
test('Buffer works using plugin', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
||||
'entry.ts': `
|
||||
let buf = new Buffer(256);
|
||||
let len = buf.write("Simply Easy Learning");
|
||||
console.log("Octets written : "+ len);`,
|
||||
});
|
||||
const res = yield build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
plugins: [NodeGlobalsPolyfillPlugin({ buffer: true })],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
test('process works using plugin', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
||||
'entry.ts': `console.log(process.cwd())`,
|
||||
});
|
||||
const res = yield build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
plugins: [NodeGlobalsPolyfillPlugin({ process: true })],
|
||||
});
|
||||
const output = res.outputFiles[0].text;
|
||||
// console.log(output)
|
||||
eval(output);
|
||||
unlink();
|
||||
}));
|
||||
//# sourceMappingURL=index.test.js.map
|
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.js.map
generated
vendored
Normal file
1
node_modules/@esbuild-plugins/node-globals-polyfill/esm/index.test.js.map
generated
vendored
Normal file
|
@ -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,yBAAyB,EAAE,MAAM,GAAG,CAAA;AAE7C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAA;AAExD,IAAI,CAAC,eAAe,EAAE,GAAS,EAAE;IAC7B,MAAM,EACF,MAAM,EACN,KAAK,EAAE,CAAC,KAAK,CAAC,GACjB,GAAG,MAAM,UAAU,CAAC;QACjB,UAAU,EAAE,iBAAiB;KAChC,CAAC,CAAA;IACF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC;QACpB,WAAW,EAAE,CAAC,KAAK,CAAC;QACpB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;KAC1C,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACtC,sBAAsB;IACtB,IAAI,CAAC,MAAM,CAAC,CAAA;IACZ,MAAM,EAAE,CAAA;AACZ,CAAC,CAAA,CAAC,CAAA;AAEF,IAAI,CAAC,wBAAwB,EAAE,GAAS,EAAE;IACtC,MAAM,EACF,MAAM,EACN,KAAK,EAAE,CAAC,KAAK,CAAC,GACjB,GAAG,MAAM,UAAU,CA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CAAA"}
|
34
node_modules/@esbuild-plugins/node-globals-polyfill/package.json
generated
vendored
Normal file
34
node_modules/@esbuild-plugins/node-globals-polyfill/package.json
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "@esbuild-plugins/node-globals-polyfill",
|
||||
"version": "0.2.3",
|
||||
"description": "",
|
||||
"preferUnplugged": true,
|
||||
"sideEffects": false,
|
||||
"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",
|
||||
"Buffer.js",
|
||||
"process.js",
|
||||
"_buffer.js",
|
||||
"_process.js"
|
||||
],
|
||||
"keywords": [],
|
||||
"author": "Tommaso De Rossi, morse <beats.by.morse@gmail.com>",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"test-support": "*"
|
||||
},
|
||||
"dependencies": {},
|
||||
"peerDependencies": {
|
||||
"esbuild": "*"
|
||||
}
|
||||
}
|
245
node_modules/@esbuild-plugins/node-globals-polyfill/process.js
generated
vendored
Normal file
245
node_modules/@esbuild-plugins/node-globals-polyfill/process.js
generated
vendored
Normal file
|
@ -0,0 +1,245 @@
|
|||
// shim for using process in browser
|
||||
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js
|
||||
|
||||
function defaultSetTimout() {
|
||||
throw new Error('setTimeout has not been defined')
|
||||
}
|
||||
function defaultClearTimeout() {
|
||||
throw new Error('clearTimeout has not been defined')
|
||||
}
|
||||
var cachedSetTimeout = defaultSetTimout
|
||||
var cachedClearTimeout = defaultClearTimeout
|
||||
if (typeof global.setTimeout === 'function') {
|
||||
cachedSetTimeout = setTimeout
|
||||
}
|
||||
if (typeof global.clearTimeout === 'function') {
|
||||
cachedClearTimeout = clearTimeout
|
||||
}
|
||||
|
||||
function runTimeout(fun) {
|
||||
if (cachedSetTimeout === setTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return setTimeout(fun, 0)
|
||||
}
|
||||
// if setTimeout wasn't available but was latter defined
|
||||
if (
|
||||
(cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) &&
|
||||
setTimeout
|
||||
) {
|
||||
cachedSetTimeout = setTimeout
|
||||
return setTimeout(fun, 0)
|
||||
}
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedSetTimeout(fun, 0)
|
||||
} catch (e) {
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedSetTimeout.call(null, fun, 0)
|
||||
} catch (e) {
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
||||
return cachedSetTimeout.call(this, fun, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
function runClearTimeout(marker) {
|
||||
if (cachedClearTimeout === clearTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return clearTimeout(marker)
|
||||
}
|
||||
// if clearTimeout wasn't available but was latter defined
|
||||
if (
|
||||
(cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) &&
|
||||
clearTimeout
|
||||
) {
|
||||
cachedClearTimeout = clearTimeout
|
||||
return clearTimeout(marker)
|
||||
}
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedClearTimeout(marker)
|
||||
} catch (e) {
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedClearTimeout.call(null, marker)
|
||||
} catch (e) {
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
||||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
||||
return cachedClearTimeout.call(this, marker)
|
||||
}
|
||||
}
|
||||
}
|
||||
var queue = []
|
||||
var draining = false
|
||||
var currentQueue
|
||||
var queueIndex = -1
|
||||
|
||||
function cleanUpNextTick() {
|
||||
if (!draining || !currentQueue) {
|
||||
return
|
||||
}
|
||||
draining = false
|
||||
if (currentQueue.length) {
|
||||
queue = currentQueue.concat(queue)
|
||||
} else {
|
||||
queueIndex = -1
|
||||
}
|
||||
if (queue.length) {
|
||||
drainQueue()
|
||||
}
|
||||
}
|
||||
|
||||
function drainQueue() {
|
||||
if (draining) {
|
||||
return
|
||||
}
|
||||
var timeout = runTimeout(cleanUpNextTick)
|
||||
draining = true
|
||||
|
||||
var len = queue.length
|
||||
while (len) {
|
||||
currentQueue = queue
|
||||
queue = []
|
||||
while (++queueIndex < len) {
|
||||
if (currentQueue) {
|
||||
currentQueue[queueIndex].run()
|
||||
}
|
||||
}
|
||||
queueIndex = -1
|
||||
len = queue.length
|
||||
}
|
||||
currentQueue = null
|
||||
draining = false
|
||||
runClearTimeout(timeout)
|
||||
}
|
||||
function nextTick(fun) {
|
||||
var args = new Array(arguments.length - 1)
|
||||
if (arguments.length > 1) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
args[i - 1] = arguments[i]
|
||||
}
|
||||
}
|
||||
queue.push(new Item(fun, args))
|
||||
if (queue.length === 1 && !draining) {
|
||||
runTimeout(drainQueue)
|
||||
}
|
||||
}
|
||||
// v8 likes predictible objects
|
||||
function Item(fun, array) {
|
||||
this.fun = fun
|
||||
this.array = array
|
||||
}
|
||||
Item.prototype.run = function() {
|
||||
this.fun.apply(null, this.array)
|
||||
}
|
||||
var title = 'browser'
|
||||
var platform = 'browser'
|
||||
var browser = true
|
||||
var env = {}
|
||||
var argv = []
|
||||
var version = '' // empty string to avoid regexp issues
|
||||
var versions = {}
|
||||
var release = {}
|
||||
var config = {}
|
||||
|
||||
function noop() {}
|
||||
|
||||
var on = noop
|
||||
var addListener = noop
|
||||
var once = noop
|
||||
var off = noop
|
||||
var removeListener = noop
|
||||
var removeAllListeners = noop
|
||||
var emit = noop
|
||||
|
||||
function binding(name) {
|
||||
throw new Error('process.binding is not supported')
|
||||
}
|
||||
|
||||
function cwd() {
|
||||
return '/'
|
||||
}
|
||||
function chdir(dir) {
|
||||
throw new Error('process.chdir is not supported')
|
||||
}
|
||||
function umask() {
|
||||
return 0
|
||||
}
|
||||
|
||||
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
||||
var performance = global.performance || {}
|
||||
var performanceNow =
|
||||
performance.now ||
|
||||
performance.mozNow ||
|
||||
performance.msNow ||
|
||||
performance.oNow ||
|
||||
performance.webkitNow ||
|
||||
function() {
|
||||
return new Date().getTime()
|
||||
}
|
||||
|
||||
// generate timestamp or delta
|
||||
// see http://nodejs.org/api/process.html#process_process_hrtime
|
||||
function hrtime(previousTimestamp) {
|
||||
var clocktime = performanceNow.call(performance) * 1e-3
|
||||
var seconds = Math.floor(clocktime)
|
||||
var nanoseconds = Math.floor((clocktime % 1) * 1e9)
|
||||
if (previousTimestamp) {
|
||||
seconds = seconds - previousTimestamp[0]
|
||||
nanoseconds = nanoseconds - previousTimestamp[1]
|
||||
if (nanoseconds < 0) {
|
||||
seconds--
|
||||
nanoseconds += 1e9
|
||||
}
|
||||
}
|
||||
return [seconds, nanoseconds]
|
||||
}
|
||||
|
||||
var startTime = new Date()
|
||||
function uptime() {
|
||||
var currentTime = new Date()
|
||||
var dif = currentTime - startTime
|
||||
return dif / 1000
|
||||
}
|
||||
|
||||
export var process = {
|
||||
nextTick: nextTick,
|
||||
title: title,
|
||||
browser: browser,
|
||||
env: env,
|
||||
argv: argv,
|
||||
version: version,
|
||||
versions: versions,
|
||||
on: on,
|
||||
addListener: addListener,
|
||||
once: once,
|
||||
off: off,
|
||||
removeListener: removeListener,
|
||||
removeAllListeners: removeAllListeners,
|
||||
emit: emit,
|
||||
binding: binding,
|
||||
cwd: cwd,
|
||||
chdir: chdir,
|
||||
umask: umask,
|
||||
hrtime: hrtime,
|
||||
platform: platform,
|
||||
release: release,
|
||||
config: config,
|
||||
uptime: uptime,
|
||||
}
|
||||
|
||||
// replace process.env.VAR with define
|
||||
|
||||
const defines = {}
|
||||
Object.keys(defines).forEach((key) => {
|
||||
const segs = key.split('.')
|
||||
let target = process
|
||||
for (let i = 0; i < segs.length; i++) {
|
||||
const seg = segs[i]
|
||||
if (i === segs.length - 1) {
|
||||
target[seg] = defines[key]
|
||||
} else {
|
||||
target = target[seg] || (target[seg] = {})
|
||||
}
|
||||
}
|
||||
})
|
155
node_modules/@esbuild-plugins/node-globals-polyfill/src/index.test.ts
generated
vendored
Normal file
155
node_modules/@esbuild-plugins/node-globals-polyfill/src/index.test.ts
generated
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
import { build } from 'esbuild'
|
||||
import { writeFiles } from 'test-support'
|
||||
import { NodeGlobalsPolyfillPlugin } from '.'
|
||||
|
||||
require('debug').enable(require('../package.json').name)
|
||||
|
||||
test('process works', async () => {
|
||||
const {
|
||||
unlink,
|
||||
paths: [ENTRY],
|
||||
} = await writeFiles({
|
||||
'entry.ts': `process.version`,
|
||||
})
|
||||
const res = await build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../process')],
|
||||
})
|
||||
const output = res.outputFiles[0].text
|
||||
// console.log(output)
|
||||
eval(output)
|
||||
unlink()
|
||||
})
|
||||
|
||||
test('process is tree shaken', async () => {
|
||||
const {
|
||||
unlink,
|
||||
paths: [ENTRY],
|
||||
} = await writeFiles({
|
||||
'entry.ts': `console.log('hei')`,
|
||||
})
|
||||
const res = await build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../process')],
|
||||
})
|
||||
const output = res.outputFiles[0].text
|
||||
expect(output).not.toContain('process')
|
||||
unlink()
|
||||
})
|
||||
|
||||
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
||||
test('process env vars are replaced with ones from define', async () => {
|
||||
const {
|
||||
unlink,
|
||||
paths: [ENTRY],
|
||||
} = await writeFiles({
|
||||
'entry.ts': `if (process.env.VAR !== 'hello') { throw new Error('process.env.VAR not right: ' + process.env.VAR) }`,
|
||||
})
|
||||
const res = await build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
define: {
|
||||
'process.env.VAR': '"hello"',
|
||||
},
|
||||
plugins: [NodeGlobalsPolyfillPlugin({})],
|
||||
})
|
||||
const output = res.outputFiles[0].text
|
||||
eval(output)
|
||||
unlink()
|
||||
})
|
||||
|
||||
test('Buffer works', async () => {
|
||||
const {
|
||||
unlink,
|
||||
paths: [ENTRY],
|
||||
} = await writeFiles({
|
||||
'entry.ts': `console.log(Buffer.from('xxx').toString())`,
|
||||
})
|
||||
const res = await build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../Buffer')],
|
||||
})
|
||||
const output = res.outputFiles[0].text
|
||||
// console.log(output)
|
||||
eval(output)
|
||||
unlink()
|
||||
})
|
||||
|
||||
test('Buffer is tree shaken', async () => {
|
||||
const {
|
||||
unlink,
|
||||
paths: [ENTRY],
|
||||
} = await writeFiles({
|
||||
'entry.ts': `console.log('hei')`,
|
||||
})
|
||||
const res = await build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
inject: [require.resolve('../Buffer')],
|
||||
})
|
||||
const output = res.outputFiles[0].text
|
||||
expect(output).not.toContain('Buffer')
|
||||
unlink()
|
||||
})
|
||||
|
||||
test('Buffer works using plugin', async () => {
|
||||
const {
|
||||
unlink,
|
||||
paths: [ENTRY],
|
||||
} = await writeFiles({
|
||||
'entry.ts': `
|
||||
let buf = new Buffer(256);
|
||||
let len = buf.write("Simply Easy Learning");
|
||||
console.log("Octets written : "+ len);`,
|
||||
})
|
||||
const res = await build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
plugins: [NodeGlobalsPolyfillPlugin({ buffer: true })],
|
||||
})
|
||||
const output = res.outputFiles[0].text
|
||||
// console.log(output)
|
||||
eval(output)
|
||||
unlink()
|
||||
})
|
||||
test('process works using plugin', async () => {
|
||||
const {
|
||||
unlink,
|
||||
paths: [ENTRY],
|
||||
} = await writeFiles({
|
||||
'entry.ts': `console.log(process.cwd())`,
|
||||
})
|
||||
const res = await build({
|
||||
entryPoints: [ENTRY],
|
||||
write: false,
|
||||
format: 'esm',
|
||||
target: 'es2017',
|
||||
bundle: true,
|
||||
plugins: [NodeGlobalsPolyfillPlugin({ process: true })],
|
||||
})
|
||||
const output = res.outputFiles[0].text
|
||||
// console.log(output)
|
||||
eval(output)
|
||||
unlink()
|
||||
})
|
84
node_modules/@esbuild-plugins/node-globals-polyfill/src/index.ts
generated
vendored
Normal file
84
node_modules/@esbuild-plugins/node-globals-polyfill/src/index.ts
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import * as esbuild from 'esbuild'
|
||||
|
||||
export function NodeGlobalsPolyfillPlugin({
|
||||
buffer = false,
|
||||
// define = {},
|
||||
process = true,
|
||||
} = {}): esbuild.Plugin {
|
||||
return {
|
||||
name: 'node-globals-polyfill',
|
||||
setup({ initialOptions, onResolve, onLoad }) {
|
||||
onResolve({ filter: /_node-buffer-polyfill_\.js/ }, (arg) => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../Buffer.js'),
|
||||
}
|
||||
})
|
||||
onResolve({ filter: /_node-process-polyfill_\.js/ }, (arg) => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../process.js'),
|
||||
}
|
||||
})
|
||||
|
||||
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
||||
// onLoad({ filter: /_virtual-process-polyfill_\.js/ }, (arg) => {
|
||||
// const data = fs
|
||||
// .readFileSync(path.resolve(__dirname, '../process.js'))
|
||||
// .toString()
|
||||
|
||||
// const keys = Object.keys(define)
|
||||
// return {
|
||||
// loader: 'js',
|
||||
// contents: data.replace(
|
||||
// `const defines = {}`,
|
||||
// 'const defines = {\n' +
|
||||
// keys
|
||||
// .filter((x) => x.startsWith('process.'))
|
||||
// .sort((a, b) => a.length - b.length)
|
||||
// .map(
|
||||
// (k) =>
|
||||
// ` ${JSON.stringify(k).replace(
|
||||
// 'process.',
|
||||
// '',
|
||||
// )}: ${define[k]},`,
|
||||
// )
|
||||
// .join('\n') +
|
||||
// '\n}',
|
||||
// ),
|
||||
// }
|
||||
// })
|
||||
onResolve({ filter: /_virtual-process-polyfill_\.js/ }, () => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../process.js'),
|
||||
}
|
||||
})
|
||||
onResolve({ filter: /_virtual-buffer-polyfill_\.js/ }, () => {
|
||||
return {
|
||||
path: path.resolve(__dirname, '../_buffer.js'),
|
||||
}
|
||||
})
|
||||
|
||||
const polyfills: string[] = []
|
||||
if (process) {
|
||||
polyfills.push(
|
||||
path.resolve(__dirname, '../_virtual-process-polyfill_.js'),
|
||||
)
|
||||
}
|
||||
if (buffer) {
|
||||
polyfills.push(
|
||||
path.resolve(__dirname, '../_virtual-buffer-polyfill_.js'),
|
||||
)
|
||||
}
|
||||
if (initialOptions.inject) {
|
||||
initialOptions.inject.push(...polyfills)
|
||||
// handle duplicate plugin
|
||||
initialOptions.inject = [...new Set(initialOptions.inject)]
|
||||
} else {
|
||||
initialOptions.inject = [...polyfills]
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default NodeGlobalsPolyfillPlugin
|
Loading…
Add table
Add a link
Reference in a new issue