@dxos/esbuild-plugins 0.6.13 → 0.6.14-main.1366248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/node-external-plugin.d.ts +10 -0
- package/dist/src/node-external-plugin.d.ts.map +1 -0
- package/dist/src/node-external-plugin.js +57 -0
- package/dist/src/node-external-plugin.js.map +1 -0
- package/package.json +2 -1
- package/project.json +2 -2
- package/src/index.ts +1 -1
- package/src/node-external-plugin.ts +64 -0
- package/tsconfig.json +1 -1
- package/dist/src/fix-memdown-plugin.d.ts +0 -6
- package/dist/src/fix-memdown-plugin.d.ts.map +0 -1
- package/dist/src/fix-memdown-plugin.js +0 -21
- package/dist/src/fix-memdown-plugin.js.map +0 -1
- package/src/fix-memdown-plugin.ts +0 -19
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAC;AACzC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
__exportStar(require("./fix-graceful-fs-plugin"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./node-external-plugin"), exports);
|
|
22
22
|
__exportStar(require("./node-globals-polyfill-plugin"), exports);
|
|
23
23
|
__exportStar(require("./node-modules-plugin"), exports);
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;AAEF,2DAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;AAEF,2DAAyC;AACzC,yDAAuC;AACvC,iEAA+C;AAC/C,wDAAsC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Plugin } from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* Rewrite `node:` imports to `@dxos/node-std` package and mark them as external.
|
|
4
|
+
*/
|
|
5
|
+
export declare const NodeExternalPlugin: ({ injectGlobals, importGlobals, nodeStd }?: {
|
|
6
|
+
injectGlobals?: boolean | undefined;
|
|
7
|
+
importGlobals?: boolean | undefined;
|
|
8
|
+
nodeStd?: boolean | undefined;
|
|
9
|
+
}) => Plugin;
|
|
10
|
+
//# sourceMappingURL=node-external-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-external-plugin.d.ts","sourceRoot":"","sources":["../../src/node-external-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAKtC;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;MAA6E,MAmD1G,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2024 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NodeExternalPlugin = void 0;
|
|
7
|
+
// Keep in sync with packages/common/node-std/src/inject-globals.js
|
|
8
|
+
const GLOBALS = ['global', 'Buffer', 'process'];
|
|
9
|
+
/**
|
|
10
|
+
* Rewrite `node:` imports to `@dxos/node-std` package and mark them as external.
|
|
11
|
+
*/
|
|
12
|
+
const NodeExternalPlugin = ({ injectGlobals = false, importGlobals = false, nodeStd = false } = {}) => ({
|
|
13
|
+
name: 'node-external',
|
|
14
|
+
setup: ({ initialOptions, onResolve, onLoad }) => {
|
|
15
|
+
if (initialOptions.platform === 'node') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (importGlobals && injectGlobals) {
|
|
19
|
+
if (!nodeStd) {
|
|
20
|
+
throw new Error('Missing @dxos/node-std dependency.');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (importGlobals) {
|
|
24
|
+
initialOptions.inject = ['@inject-globals'];
|
|
25
|
+
}
|
|
26
|
+
if (injectGlobals) {
|
|
27
|
+
initialOptions.banner || (initialOptions.banner = {});
|
|
28
|
+
initialOptions.banner.js = 'import "@dxos/node-std/globals";';
|
|
29
|
+
}
|
|
30
|
+
onResolve({ filter: /^@inject-globals*/ }, (args) => {
|
|
31
|
+
return { path: '@inject-globals', namespace: 'inject-globals' };
|
|
32
|
+
});
|
|
33
|
+
onLoad({ filter: /^@inject-globals/, namespace: 'inject-globals' }, async (args) => {
|
|
34
|
+
return {
|
|
35
|
+
contents: `
|
|
36
|
+
export {
|
|
37
|
+
${GLOBALS.join(',\n')}
|
|
38
|
+
} from '@dxos/node-std/inject-globals';
|
|
39
|
+
// Empty source map so that esbuild does not inject virtual source file names.
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==
|
|
41
|
+
`,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
onResolve({ filter: /^@dxos\/node-std\/inject-globals$/ }, (args) => {
|
|
45
|
+
return { external: true, path: '@dxos/node-std/inject-globals' };
|
|
46
|
+
});
|
|
47
|
+
onResolve({ filter: /^node:.*/ }, (args) => {
|
|
48
|
+
if (!nodeStd) {
|
|
49
|
+
return { errors: [{ text: 'Missing @dxos/node-std dependency.' }] };
|
|
50
|
+
}
|
|
51
|
+
const module = args.path.replace(/^node:/, '');
|
|
52
|
+
return { external: true, path: `@dxos/node-std/${module}` };
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
exports.NodeExternalPlugin = NodeExternalPlugin;
|
|
57
|
+
//# sourceMappingURL=node-external-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-external-plugin.js","sourceRoot":"","sources":["../../src/node-external-plugin.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAIF,mEAAmE;AACnE,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEhD;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAAC,EAAE,aAAa,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,EAAE,EAAU,EAAE,CAAC,CAAC;IACrH,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE;QAC/C,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAED,IAAI,aAAa,IAAI,aAAa,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,cAAc,CAAC,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC9C,CAA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AmD5B"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/esbuild-plugins",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14-main.1366248",
|
|
4
4
|
"homepage": "https://dxos.org",
|
|
5
5
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "DXOS.org",
|
|
8
|
+
"sideEffects": true,
|
|
8
9
|
"main": "./dist/src/index.js",
|
|
9
10
|
"types": "./dist/src/index.d.ts",
|
|
10
11
|
"dependencies": {
|
package/project.json
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"executor": "@nx/js:tsc",
|
|
12
12
|
"options": {
|
|
13
13
|
"main": "{projectRoot}/src/index.ts",
|
|
14
|
-
"outputPath": "
|
|
14
|
+
"outputPath": "{projectRoot}/dist",
|
|
15
15
|
"transformers": [
|
|
16
16
|
"@dxos/log-hook/transformer"
|
|
17
17
|
],
|
|
18
|
-
"tsConfig": "
|
|
18
|
+
"tsConfig": "{projectRoot}/tsconfig.json"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"lint": {}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { Plugin } from 'esbuild';
|
|
6
|
+
|
|
7
|
+
// Keep in sync with packages/common/node-std/src/inject-globals.js
|
|
8
|
+
const GLOBALS = ['global', 'Buffer', 'process'];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Rewrite `node:` imports to `@dxos/node-std` package and mark them as external.
|
|
12
|
+
*/
|
|
13
|
+
export const NodeExternalPlugin = ({ injectGlobals = false, importGlobals = false, nodeStd = false } = {}): Plugin => ({
|
|
14
|
+
name: 'node-external',
|
|
15
|
+
setup: ({ initialOptions, onResolve, onLoad }) => {
|
|
16
|
+
if (initialOptions.platform === 'node') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (importGlobals && injectGlobals) {
|
|
21
|
+
if (!nodeStd) {
|
|
22
|
+
throw new Error('Missing @dxos/node-std dependency.');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (importGlobals) {
|
|
27
|
+
initialOptions.inject = ['@inject-globals'];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (injectGlobals) {
|
|
31
|
+
initialOptions.banner ||= {};
|
|
32
|
+
initialOptions.banner.js = 'import "@dxos/node-std/globals";';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
onResolve({ filter: /^@inject-globals*/ }, (args) => {
|
|
36
|
+
return { path: '@inject-globals', namespace: 'inject-globals' };
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
onLoad({ filter: /^@inject-globals/, namespace: 'inject-globals' }, async (args) => {
|
|
40
|
+
return {
|
|
41
|
+
contents: `
|
|
42
|
+
export {
|
|
43
|
+
${GLOBALS.join(',\n')}
|
|
44
|
+
} from '@dxos/node-std/inject-globals';
|
|
45
|
+
// Empty source map so that esbuild does not inject virtual source file names.
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==
|
|
47
|
+
`,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
onResolve({ filter: /^@dxos\/node-std\/inject-globals$/ }, (args) => {
|
|
52
|
+
return { external: true, path: '@dxos/node-std/inject-globals' };
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
onResolve({ filter: /^node:.*/ }, (args) => {
|
|
56
|
+
if (!nodeStd) {
|
|
57
|
+
return { errors: [{ text: 'Missing @dxos/node-std dependency.' }] };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const module = args.path.replace(/^node:/, '');
|
|
61
|
+
return { external: true, path: `@dxos/node-std/${module}` };
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix-memdown-plugin.d.ts","sourceRoot":"","sources":["../../src/fix-memdown-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,MASlC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2021 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FixMemdownPlugin = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Some odd path resolution in memdown package.
|
|
9
|
-
*/
|
|
10
|
-
const FixMemdownPlugin = () => ({
|
|
11
|
-
name: 'fix-memdown-plugin',
|
|
12
|
-
setup: ({ onResolve }) => {
|
|
13
|
-
onResolve({ filter: /^immediate$/ }, (arg) => {
|
|
14
|
-
return {
|
|
15
|
-
path: require.resolve(arg.path, { paths: [arg.resolveDir] }),
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
exports.FixMemdownPlugin = FixMemdownPlugin;
|
|
21
|
-
//# sourceMappingURL=fix-memdown-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix-memdown-plugin.js","sourceRoot":"","sources":["../../src/fix-memdown-plugin.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAIF;;GAEG;AACI,MAAM,gBAAgB,GAAG,GAAW,EAAE,CAAC,CAAC;IAC7C,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;YAC3C,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;aAC7D,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC;AATU,QAAA,gBAAgB,oBAS1B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2021 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import type { Plugin } from 'esbuild';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Some odd path resolution in memdown package.
|
|
9
|
-
*/
|
|
10
|
-
export const FixMemdownPlugin = (): Plugin => ({
|
|
11
|
-
name: 'fix-memdown-plugin',
|
|
12
|
-
setup: ({ onResolve }) => {
|
|
13
|
-
onResolve({ filter: /^immediate$/ }, (arg) => {
|
|
14
|
-
return {
|
|
15
|
-
path: require.resolve(arg.path, { paths: [arg.resolveDir] }),
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
});
|