@veryfront/ext-bundler-esbuild 0.1.985

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ Veryfront Code
2
+ Copyright 2026 Veryfront GmbH
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @veryfront/ext-bundler-esbuild
2
+
3
+ > **Category:** Build | **Contracts:** `Bundler`, `ModuleLexer` | **Built-in**
4
+
5
+ Provides ESM bundling and module analysis for Veryfront's runtime build pipeline and module-graph analysis, backed by esbuild and es-module-lexer.
6
+
7
+ Registers two contracts:
8
+
9
+ - **`Bundler`** — esbuild-backed module bundler (`EsbuildBundler`)
10
+ - **`ModuleLexer`** — es-module-lexer-backed ESM scanner (`EsModuleLexer`)
11
+
12
+ Without this extension, both surfaces throw an install-suggestion error.
13
+
14
+ ## Registration
15
+
16
+ This extension is auto-enabled by core bootstrap. Add it to `veryfront.config.ts` only when you need to override the built-in registration:
17
+
18
+ ```ts
19
+ import extEsbuild from "@veryfront/ext-bundler-esbuild";
20
+
21
+ export default defineConfig({
22
+ extensions: [extEsbuild()],
23
+ });
24
+ ```
25
+
26
+ ## Provided contracts
27
+
28
+ | Contract | Implementation | Backed by |
29
+ | ------------- | ---------------- | ----------------- |
30
+ | `Bundler` | `EsbuildBundler` | `esbuild` |
31
+ | `ModuleLexer` | `EsModuleLexer` | `es-module-lexer` |
32
+
33
+ Both classes are also exported by name so callers can construct an instance outside the registry:
34
+
35
+ ```ts
36
+ import { EsbuildBundler, EsModuleLexer } from "@veryfront/ext-bundler-esbuild";
37
+ ```
38
+
39
+ ## Configuration
40
+
41
+ No factory options. The extension reads no environment variables and takes no config.
42
+
43
+ ## Lifecycle
44
+
45
+ The factory's `teardown()` calls `EsbuildBundler.stop()` to release the esbuild service on shutdown.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
+ * but instead of using npm to install additional dependencies,
4
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
+ *
6
+ * Note that this code might be imported multiple times
7
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
+ * or Node.js might dynamically clear the cache and then force a require).
9
+ * Therefore, it's important to avoid redundant writes to global objects.
10
+ * Additionally, consider that commonjs is used alongside esm,
11
+ * so the two ponyfill functions are stored independently in two separate global objects.
12
+ */
13
+ import { createRequire } from "node:module";
14
+ import { type URL } from "node:url";
15
+ declare global {
16
+ interface ImportMeta {
17
+ /** A string representation of the fully qualified module URL. When the
18
+ * module is loaded locally, the value will be a file URL (e.g.
19
+ * `file:///path/module.ts`).
20
+ *
21
+ * You can also parse the string as a URL to determine more information about
22
+ * how the current module was loaded. For example to determine if a module was
23
+ * local or not:
24
+ *
25
+ * ```ts
26
+ * const url = new URL(import.meta.url);
27
+ * if (url.protocol === "file:") {
28
+ * console.log("this module was loaded locally");
29
+ * }
30
+ * ```
31
+ */
32
+ url: string;
33
+ /**
34
+ * A function that returns resolved specifier as if it would be imported
35
+ * using `import(specifier)`.
36
+ *
37
+ * ```ts
38
+ * console.log(import.meta.resolve("./foo.js"));
39
+ * // file:///dev/foo.js
40
+ * ```
41
+ *
42
+ * @param specifier The module specifier to resolve relative to `parent`.
43
+ * @param parent The absolute parent module URL to resolve from.
44
+ * @returns The absolute (`file:`) URL string for the resolved module.
45
+ */
46
+ resolve(specifier: string, parent?: string | URL | undefined): string;
47
+ /** A flag that indicates if the current module is the main module that was
48
+ * called when starting the program under Deno.
49
+ *
50
+ * ```ts
51
+ * if (import.meta.main) {
52
+ * // this was loaded as the main module, maybe do some bootstrapping
53
+ * }
54
+ * ```
55
+ */
56
+ main: boolean;
57
+ /** The absolute path of the current module.
58
+ *
59
+ * This property is only provided for local modules (ie. using `file://` URLs).
60
+ *
61
+ * Example:
62
+ * ```
63
+ * // Unix
64
+ * console.log(import.meta.filename); // /home/alice/my_module.ts
65
+ *
66
+ * // Windows
67
+ * console.log(import.meta.filename); // C:\alice\my_module.ts
68
+ * ```
69
+ */
70
+ filename: string;
71
+ /** The absolute path of the directory containing the current module.
72
+ *
73
+ * This property is only provided for local modules (ie. using `file://` URLs).
74
+ *
75
+ * * Example:
76
+ * ```
77
+ * // Unix
78
+ * console.log(import.meta.dirname); // /home/alice
79
+ *
80
+ * // Windows
81
+ * console.log(import.meta.dirname); // C:\alice
82
+ * ```
83
+ */
84
+ dirname: string;
85
+ }
86
+ }
87
+ type NodeRequest = ReturnType<typeof createRequire>;
88
+ type NodeModule = NonNullable<NodeRequest["main"]>;
89
+ interface ImportMetaPonyfillCommonjs {
90
+ (require: NodeRequest, module: NodeModule): ImportMeta;
91
+ }
92
+ interface ImportMetaPonyfillEsmodule {
93
+ (importMeta: ImportMeta): ImportMeta;
94
+ }
95
+ interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
96
+ }
97
+ export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
98
+ export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
99
+ export declare let import_meta_ponyfill: ImportMetaPonyfill;
100
+ export {};
101
+ //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
+ * but instead of using npm to install additional dependencies,
4
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
+ *
6
+ * Note that this code might be imported multiple times
7
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
+ * or Node.js might dynamically clear the cache and then force a require).
9
+ * Therefore, it's important to avoid redundant writes to global objects.
10
+ * Additionally, consider that commonjs is used alongside esm,
11
+ * so the two ponyfill functions are stored independently in two separate global objects.
12
+ */
13
+ //@ts-ignore
14
+ import { createRequire } from "node:module";
15
+ //@ts-ignore
16
+ import { fileURLToPath, pathToFileURL } from "node:url";
17
+ //@ts-ignore
18
+ import { dirname } from "node:path";
19
+ const defineGlobalPonyfill = (symbolFor, fn) => {
20
+ if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
21
+ Object.defineProperty(globalThis, Symbol.for(symbolFor), {
22
+ configurable: true,
23
+ get() {
24
+ return fn;
25
+ },
26
+ });
27
+ }
28
+ };
29
+ export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
30
+ (() => {
31
+ const moduleImportMetaWM = new WeakMap();
32
+ return (require, module) => {
33
+ let importMetaCache = moduleImportMetaWM.get(module);
34
+ if (importMetaCache == null) {
35
+ const importMeta = Object.assign(Object.create(null), {
36
+ url: pathToFileURL(module.filename).href,
37
+ main: require.main == module,
38
+ resolve: (specifier, parentURL = importMeta.url) => {
39
+ return pathToFileURL((importMeta.url === parentURL
40
+ ? require
41
+ : createRequire(parentURL))
42
+ .resolve(specifier)).href;
43
+ },
44
+ filename: module.filename,
45
+ dirname: module.path,
46
+ });
47
+ moduleImportMetaWM.set(module, importMeta);
48
+ importMetaCache = importMeta;
49
+ }
50
+ return importMetaCache;
51
+ };
52
+ })());
53
+ defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
54
+ export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
55
+ ((importMeta) => {
56
+ const resolveFunStr = String(importMeta.resolve);
57
+ const shimWs = new WeakSet();
58
+ //@ts-ignore
59
+ const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
60
+ .replace(/\/{3,}/, "///");
61
+ const commonShim = (importMeta) => {
62
+ if (typeof importMeta.main !== "boolean") {
63
+ importMeta.main = importMeta.url === mainUrl;
64
+ }
65
+ if (typeof importMeta.filename !== "string") {
66
+ importMeta.filename = fileURLToPath(importMeta.url);
67
+ importMeta.dirname = dirname(importMeta.filename);
68
+ }
69
+ };
70
+ if (
71
+ // v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
72
+ resolveFunStr === "undefined" ||
73
+ // v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
74
+ resolveFunStr.startsWith("async")
75
+ // enable by --experimental-import-meta-resolve flag
76
+ ) {
77
+ import_meta_ponyfill_esmodule = (importMeta) => {
78
+ if (!shimWs.has(importMeta)) {
79
+ shimWs.add(importMeta);
80
+ const importMetaUrlRequire = {
81
+ url: importMeta.url,
82
+ require: createRequire(importMeta.url),
83
+ };
84
+ importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
85
+ return pathToFileURL((importMetaUrlRequire.url === parentURL
86
+ ? importMetaUrlRequire.require
87
+ : createRequire(parentURL)).resolve(specifier)).href;
88
+ };
89
+ commonShim(importMeta);
90
+ }
91
+ return importMeta;
92
+ };
93
+ }
94
+ else {
95
+ /// native support
96
+ import_meta_ponyfill_esmodule = (importMeta) => {
97
+ if (!shimWs.has(importMeta)) {
98
+ shimWs.add(importMeta);
99
+ commonShim(importMeta);
100
+ }
101
+ return importMeta;
102
+ };
103
+ }
104
+ return import_meta_ponyfill_esmodule(importMeta);
105
+ }));
106
+ defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
107
+ export let import_meta_ponyfill = ((...args) => {
108
+ const _MODULE = (() => {
109
+ if (typeof require === "function" && typeof module === "object") {
110
+ return "commonjs";
111
+ }
112
+ else {
113
+ // eval("typeof import.meta");
114
+ return "esmodule";
115
+ }
116
+ })();
117
+ if (_MODULE === "commonjs") {
118
+ //@ts-ignore
119
+ import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
120
+ }
121
+ else {
122
+ //@ts-ignore
123
+ import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
124
+ }
125
+ //@ts-ignore
126
+ return import_meta_ponyfill(...args);
127
+ });
@@ -0,0 +1,12 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ export { crypto, type Crypto, type SubtleCrypto, type AlgorithmIdentifier, type Algorithm, type RsaOaepParams, type BufferSource, type AesCtrParams, type AesCbcParams, type AesGcmParams, type CryptoKey, type KeyAlgorithm, type KeyType, type KeyUsage, type EcdhKeyDeriveParams, type HkdfParams, type HashAlgorithmIdentifier, type Pbkdf2Params, type AesDerivedKeyParams, type HmacImportParams, type JsonWebKey, type RsaOtherPrimesInfo, type KeyFormat, type RsaHashedKeyGenParams, type RsaKeyGenParams, type BigInteger, type EcKeyGenParams, type NamedCurve, type CryptoKeyPair, type AesKeyGenParams, type HmacKeyGenParams, type RsaHashedImportParams, type EcKeyImportParams, type AesKeyAlgorithm, type RsaPssParams, type EcdsaParams } from "@deno/shim-crypto";
4
+ import { setInterval, setTimeout } from "@deno/shim-timers";
5
+ export { setInterval, setTimeout } from "@deno/shim-timers";
6
+ export declare const dntGlobalThis: Omit<typeof globalThis, "setInterval" | "setTimeout" | "crypto" | "Deno"> & {
7
+ Deno: typeof Deno;
8
+ crypto: import("@deno/shim-crypto").Crypto;
9
+ setInterval: typeof setInterval;
10
+ setTimeout: typeof setTimeout;
11
+ };
12
+ //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ5D,eAAO,MAAM,aAAa;;;;;CAA2C,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ import { crypto } from "@deno/shim-crypto";
4
+ export { crypto } from "@deno/shim-crypto";
5
+ import { setInterval, setTimeout } from "@deno/shim-timers";
6
+ export { setInterval, setTimeout } from "@deno/shim-timers";
7
+ const dntGlobals = {
8
+ Deno,
9
+ crypto,
10
+ setInterval,
11
+ setTimeout,
12
+ };
13
+ export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
14
+ function createMergeProxy(baseObj, extObj) {
15
+ return new Proxy(baseObj, {
16
+ get(_target, prop, _receiver) {
17
+ if (prop in extObj) {
18
+ return extObj[prop];
19
+ }
20
+ else {
21
+ return baseObj[prop];
22
+ }
23
+ },
24
+ set(_target, prop, value) {
25
+ if (prop in extObj) {
26
+ delete extObj[prop];
27
+ }
28
+ baseObj[prop] = value;
29
+ return true;
30
+ },
31
+ deleteProperty(_target, prop) {
32
+ let success = false;
33
+ if (prop in extObj) {
34
+ delete extObj[prop];
35
+ success = true;
36
+ }
37
+ if (prop in baseObj) {
38
+ delete baseObj[prop];
39
+ success = true;
40
+ }
41
+ return success;
42
+ },
43
+ ownKeys(_target) {
44
+ const baseKeys = Reflect.ownKeys(baseObj);
45
+ const extKeys = Reflect.ownKeys(extObj);
46
+ const extKeysSet = new Set(extKeys);
47
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
48
+ },
49
+ defineProperty(_target, prop, desc) {
50
+ if (prop in extObj) {
51
+ delete extObj[prop];
52
+ }
53
+ Reflect.defineProperty(baseObj, prop, desc);
54
+ return true;
55
+ },
56
+ getOwnPropertyDescriptor(_target, prop) {
57
+ if (prop in extObj) {
58
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
59
+ }
60
+ else {
61
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
62
+ }
63
+ },
64
+ has(_target, prop) {
65
+ return prop in extObj || prop in baseObj;
66
+ },
67
+ });
68
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Idempotent one-shot setup — copies the esbuild binary out of the VFS (if
3
+ * running in `deno compile`) and sets ESBUILD_BINARY_PATH. No-op on normal
4
+ * Deno or when the env var is already set.
5
+ */
6
+ export declare function ensureEsbuildBinary(): Promise<void>;
7
+ //# sourceMappingURL=binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":"AAmHA;;;;GAIG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiCzD"}
package/esm/binary.js ADDED
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Binary extraction for `deno compile` VFS.
3
+ *
4
+ * Ported from src/platform/compat/esbuild.ts + esbuild-shared.ts. When the
5
+ * framework runs as a compiled Deno binary, the esbuild native binary lives
6
+ * inside the VFS and must be copied to a writable path before esbuild's
7
+ * child-process spawn can find it.
8
+ *
9
+ * On normal Deno (not `deno compile`) or when ESBUILD_BINARY_PATH is already
10
+ * set, `ensureEsbuildBinary()` is a no-op.
11
+ *
12
+ * @module extensions/ext-bundler-esbuild/binary
13
+ */
14
+ import * as dntShim from "./_dnt.shims.js";
15
+ import { isDenoCompiled } from "./runtime.js";
16
+ const ESBUILD_VERSION = "0.28.1";
17
+ function getTempDir() {
18
+ try {
19
+ return (dntShim.Deno.env.get("TMPDIR") ?? dntShim.Deno.env.get("TEMP") ?? dntShim.Deno.env.get("TMP") ?? "/tmp");
20
+ }
21
+ catch {
22
+ return "/tmp";
23
+ }
24
+ }
25
+ function getEsbuildBinaryName() {
26
+ const archMap = { x86_64: "x64", aarch64: "arm64" };
27
+ const arch = archMap[dntShim.Deno.build.arch] ?? dntShim.Deno.build.arch;
28
+ return `@esbuild/${dntShim.Deno.build.os}-${arch}`;
29
+ }
30
+ function getVFSBasePath(filePath, tempDir) {
31
+ const denoCompileMatch = filePath.match(/^(.*\/deno-compile-[^/]+)\//);
32
+ if (denoCompileMatch?.[1])
33
+ return denoCompileMatch[1];
34
+ const parts = filePath.split("/");
35
+ const srcIndex = parts.lastIndexOf("src");
36
+ if (srcIndex > 0)
37
+ return parts.slice(0, srcIndex).join("/");
38
+ return `${tempDir}/deno-compile-veryfront`;
39
+ }
40
+ async function isFile(path) {
41
+ try {
42
+ const stat = await dntShim.Deno.stat(path);
43
+ return stat.isFile;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ }
49
+ async function findEsbuildInVFS() {
50
+ const binaryName = getEsbuildBinaryName();
51
+ const vfsBase = getVFSBasePath(new URL(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url).pathname, getTempDir());
52
+ const possiblePaths = [
53
+ `${vfsBase}/node_modules/${binaryName}/bin/esbuild`,
54
+ `${vfsBase}/node_modules/.deno/${binaryName}@${ESBUILD_VERSION}/node_modules/${binaryName}/bin/esbuild`,
55
+ `${vfsBase}/node_modules/.deno/esbuild@${ESBUILD_VERSION}/node_modules/${binaryName}/bin/esbuild`,
56
+ `${vfsBase}/node_modules/esbuild/bin/esbuild`,
57
+ `${vfsBase}/node_modules/.package/esbuild@${ESBUILD_VERSION}/bin/esbuild`,
58
+ `${vfsBase}/node_modules/.package/${binaryName}@${ESBUILD_VERSION}/bin/esbuild`,
59
+ ];
60
+ for (const p of possiblePaths) {
61
+ if (await isFile(p))
62
+ return p;
63
+ }
64
+ try {
65
+ const nodeModulesPath = `${vfsBase}/node_modules`;
66
+ for await (const entry of dntShim.Deno.readDir(nodeModulesPath)) {
67
+ if (entry.name !== binaryName && !entry.name.startsWith("@esbuild"))
68
+ continue;
69
+ const binPath = `${nodeModulesPath}/${entry.name}/bin/esbuild`;
70
+ if (await isFile(binPath))
71
+ return binPath;
72
+ }
73
+ }
74
+ catch {
75
+ /* node_modules not readable in VFS */
76
+ }
77
+ return null;
78
+ }
79
+ async function extractEsbuildBinary() {
80
+ const cacheDir = `${getTempDir()}/veryfront-esbuild`;
81
+ const targetPath = `${cacheDir}/esbuild-${ESBUILD_VERSION}`;
82
+ try {
83
+ const stat = await dntShim.Deno.stat(targetPath);
84
+ if (stat.isFile && stat.mode && (stat.mode & 0o111))
85
+ return targetPath;
86
+ }
87
+ catch {
88
+ /* cache miss */
89
+ }
90
+ const vfsPath = await findEsbuildInVFS();
91
+ if (!vfsPath) {
92
+ throw new Error(`[ext-bundler-esbuild] Could not find esbuild binary in deno compile VFS. ` +
93
+ `Platform: ${getEsbuildBinaryName()}. ` +
94
+ `Ensure esbuild is in dependencies and deno compile includes node_modules.`);
95
+ }
96
+ await dntShim.Deno.mkdir(cacheDir, { recursive: true });
97
+ const binary = await dntShim.Deno.readFile(vfsPath);
98
+ await dntShim.Deno.writeFile(targetPath, binary, { mode: 0o755 });
99
+ return targetPath;
100
+ }
101
+ let setupComplete = false;
102
+ let setupPromise = null;
103
+ /**
104
+ * Idempotent one-shot setup — copies the esbuild binary out of the VFS (if
105
+ * running in `deno compile`) and sets ESBUILD_BINARY_PATH. No-op on normal
106
+ * Deno or when the env var is already set.
107
+ */
108
+ export async function ensureEsbuildBinary() {
109
+ if (setupComplete)
110
+ return;
111
+ if (setupPromise) {
112
+ await setupPromise;
113
+ return;
114
+ }
115
+ setupPromise = (async () => {
116
+ try {
117
+ if (dntShim.Deno.env.get("ESBUILD_BINARY_PATH") || !isDenoCompiled) {
118
+ setupComplete = true;
119
+ return;
120
+ }
121
+ try {
122
+ const binaryPath = await extractEsbuildBinary();
123
+ dntShim.Deno.env.set("ESBUILD_BINARY_PATH", binaryPath);
124
+ // esbuild reads process.env (not Deno.env) on some code paths.
125
+ const proc = dntShim.dntGlobalThis.process;
126
+ if (proc?.env)
127
+ proc.env.ESBUILD_BINARY_PATH = binaryPath;
128
+ }
129
+ catch (err) {
130
+ console.error("[ext-bundler-esbuild] Binary extraction failed:", err);
131
+ }
132
+ }
133
+ finally {
134
+ setupComplete = true;
135
+ }
136
+ })();
137
+ try {
138
+ await setupPromise;
139
+ }
140
+ finally {
141
+ setupPromise = null;
142
+ }
143
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * es-module-lexer-backed implementation of the {@link ModuleLexer} contract.
3
+ *
4
+ * es-module-lexer@2 exports `init` as a Promise in its ESM build but older
5
+ * typings expect a function. We tolerate both shapes (as the in-tree
6
+ * src/transforms/esm/lexer.ts did).
7
+ *
8
+ * @module extensions/ext-bundler-esbuild/es-module-lexer
9
+ */
10
+ import type { ImportSpecifier, ModuleLexer } from "veryfront/extensions/bundler";
11
+ /** es-module-lexer-backed {@link ModuleLexer} implementation. */
12
+ export declare class EsModuleLexer implements ModuleLexer {
13
+ private initPromise;
14
+ init(): Promise<void>;
15
+ parse(code: string): readonly ImportSpecifier[];
16
+ }
17
+ //# sourceMappingURL=es-module-lexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"es-module-lexer.d.ts","sourceRoot":"","sources":["../src/es-module-lexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGjF,iEAAiE;AACjE,qBAAa,aAAc,YAAW,WAAW;IAC/C,OAAO,CAAC,WAAW,CAA8B;IAE3C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAY3B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,eAAe,EAAE;CAIhD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * es-module-lexer-backed implementation of the {@link ModuleLexer} contract.
3
+ *
4
+ * es-module-lexer@2 exports `init` as a Promise in its ESM build but older
5
+ * typings expect a function. We tolerate both shapes (as the in-tree
6
+ * src/transforms/esm/lexer.ts did).
7
+ *
8
+ * @module extensions/ext-bundler-esbuild/es-module-lexer
9
+ */
10
+ import { init, parse } from "es-module-lexer";
11
+ /** es-module-lexer-backed {@link ModuleLexer} implementation. */
12
+ export class EsModuleLexer {
13
+ initPromise = null;
14
+ async init() {
15
+ if (this.initPromise) {
16
+ await this.initPromise;
17
+ return;
18
+ }
19
+ const anyInit = init;
20
+ this.initPromise = typeof anyInit === "function"
21
+ ? anyInit()
22
+ : anyInit;
23
+ await this.initPromise;
24
+ }
25
+ parse(code) {
26
+ const [imports] = parse(code);
27
+ return imports;
28
+ }
29
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * esbuild-backed implementation of the {@link Bundler} contract.
3
+ *
4
+ * Lazy-initializes the esbuild binary (including `deno compile` VFS
5
+ * extraction) on first use. All options pass through to esbuild unchanged
6
+ * because the {@link BundleOptions} shape was designed to be esbuild-compatible;
7
+ * the only translation is converting {@link BundlerPlugin}s into esbuild
8
+ * plugins via {@link toEsbuildPlugin}.
9
+ *
10
+ * @module extensions/ext-bundler-esbuild/esbuild-bundler
11
+ */
12
+ import type { BuildContext, BundleOptions, Bundler, BundleResult, TransformOptions, TransformResult } from "veryfront/extensions/bundler";
13
+ /** esbuild-backed {@link Bundler} implementation. */
14
+ export declare class EsbuildBundler implements Bundler {
15
+ bundle(options: BundleOptions): Promise<BundleResult>;
16
+ transform(options: TransformOptions): Promise<TransformResult>;
17
+ context(options: BundleOptions): Promise<BuildContext>;
18
+ stop(): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=esbuild-bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild-bundler.d.ts","sourceRoot":"","sources":["../src/esbuild-bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAEb,OAAO,EACP,YAAY,EAGZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAoDtC,qDAAqD;AACrD,qBAAa,cAAe,YAAW,OAAO;IACtC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAWrD,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAW9D,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAiBtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAM5B"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * esbuild-backed implementation of the {@link Bundler} contract.
3
+ *
4
+ * Lazy-initializes the esbuild binary (including `deno compile` VFS
5
+ * extraction) on first use. All options pass through to esbuild unchanged
6
+ * because the {@link BundleOptions} shape was designed to be esbuild-compatible;
7
+ * the only translation is converting {@link BundlerPlugin}s into esbuild
8
+ * plugins via {@link toEsbuildPlugin}.
9
+ *
10
+ * @module extensions/ext-bundler-esbuild/esbuild-bundler
11
+ */
12
+ import { ensureEsbuildBinary } from "./binary.js";
13
+ import { toEsbuildPlugin } from "./plugin-adapter.js";
14
+ let esbuildModule = null;
15
+ async function getEsbuild() {
16
+ await ensureEsbuildBinary();
17
+ if (esbuildModule)
18
+ return esbuildModule;
19
+ esbuildModule = await import("esbuild");
20
+ return esbuildModule;
21
+ }
22
+ // deno-lint-ignore no-explicit-any
23
+ function toMessage(m) {
24
+ return {
25
+ text: m.text,
26
+ location: m.location ?? null,
27
+ notes: m.notes,
28
+ pluginName: m.pluginName,
29
+ detail: m.detail,
30
+ };
31
+ }
32
+ // deno-lint-ignore no-explicit-any
33
+ function toMessages(ms) {
34
+ return (ms ?? []).map(toMessage);
35
+ }
36
+ // deno-lint-ignore no-explicit-any
37
+ function toOutput(f) {
38
+ return {
39
+ path: f.path,
40
+ contents: f.contents,
41
+ text: f.text,
42
+ hash: f.hash,
43
+ };
44
+ }
45
+ function mapOptions(options) {
46
+ const { plugins, ...rest } = options;
47
+ const mapped = { ...rest };
48
+ if (plugins && plugins.length > 0) {
49
+ mapped.plugins = plugins.map(toEsbuildPlugin);
50
+ }
51
+ return mapped;
52
+ }
53
+ /** esbuild-backed {@link Bundler} implementation. */
54
+ export class EsbuildBundler {
55
+ async bundle(options) {
56
+ const esbuild = await getEsbuild();
57
+ const result = await esbuild.build(mapOptions(options));
58
+ return {
59
+ outputFiles: (result.outputFiles ?? []).map(toOutput),
60
+ warnings: toMessages(result.warnings),
61
+ errors: toMessages(result.errors),
62
+ metafile: result.metafile,
63
+ };
64
+ }
65
+ async transform(options) {
66
+ const esbuild = await getEsbuild();
67
+ const { code, ...rest } = options;
68
+ const result = await esbuild.transform(code, rest);
69
+ return {
70
+ code: result.code,
71
+ map: result.map,
72
+ warnings: toMessages(result.warnings).map((m) => m.text),
73
+ };
74
+ }
75
+ async context(options) {
76
+ const esbuild = await getEsbuild();
77
+ const ctx = await esbuild.context(mapOptions(options));
78
+ return {
79
+ rebuild: async () => {
80
+ const result = await ctx.rebuild();
81
+ return {
82
+ outputFiles: (result.outputFiles ?? []).map(toOutput),
83
+ warnings: toMessages(result.warnings),
84
+ errors: toMessages(result.errors),
85
+ metafile: result.metafile,
86
+ };
87
+ },
88
+ dispose: () => ctx.dispose(),
89
+ };
90
+ }
91
+ async stop() {
92
+ const m = esbuildModule;
93
+ if (!m)
94
+ return;
95
+ esbuildModule = null;
96
+ await m.stop();
97
+ }
98
+ }
package/esm/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ext-bundler-esbuild — Bundler + ModuleLexer contract implementations backed by
3
+ * esbuild and es-module-lexer.
4
+ *
5
+ * @module extensions/ext-bundler-esbuild
6
+ */
7
+ import "./_dnt.polyfills.js";
8
+ import type { ExtensionFactory } from "veryfront/extensions";
9
+ import { EsbuildBundler } from "./esbuild-bundler.js";
10
+ import { EsModuleLexer } from "./es-module-lexer.js";
11
+ /**
12
+ * Default export — the ext-bundler-esbuild extension factory.
13
+ *
14
+ * Registers both the `Bundler` (esbuild-backed) and `ModuleLexer`
15
+ * (es-module-lexer-backed) contracts.
16
+ */
17
+ declare const extEsbuild: ExtensionFactory;
18
+ export default extEsbuild;
19
+ export { EsbuildBundler, EsModuleLexer };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;GAKG;AACH,QAAA,MAAM,UAAU,EAAE,gBAwBjB,CAAC;AAEF,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
package/esm/index.js ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * ext-bundler-esbuild — Bundler + ModuleLexer contract implementations backed by
3
+ * esbuild and es-module-lexer.
4
+ *
5
+ * @module extensions/ext-bundler-esbuild
6
+ */
7
+ import "./_dnt.polyfills.js";
8
+ import { EsbuildBundler } from "./esbuild-bundler.js";
9
+ import { EsModuleLexer } from "./es-module-lexer.js";
10
+ /**
11
+ * Default export — the ext-bundler-esbuild extension factory.
12
+ *
13
+ * Registers both the `Bundler` (esbuild-backed) and `ModuleLexer`
14
+ * (es-module-lexer-backed) contracts.
15
+ */
16
+ const extEsbuild = () => {
17
+ const bundler = new EsbuildBundler();
18
+ const lexer = new EsModuleLexer();
19
+ return {
20
+ name: "ext-bundler-esbuild",
21
+ version: "0.1.0",
22
+ contracts: {
23
+ provides: ["Bundler", "ModuleLexer"],
24
+ },
25
+ capabilities: [],
26
+ setup(ctx) {
27
+ if (!ctx.get("Bundler")) {
28
+ ctx.provide("Bundler", bundler);
29
+ }
30
+ if (!ctx.get("ModuleLexer")) {
31
+ ctx.provide("ModuleLexer", lexer);
32
+ }
33
+ ctx.logger.info("[ext-bundler-esbuild] Bundler + ModuleLexer registered");
34
+ },
35
+ async teardown() {
36
+ await bundler.stop?.();
37
+ },
38
+ };
39
+ };
40
+ export default extEsbuild;
41
+ export { EsbuildBundler, EsModuleLexer };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Plugin adapter — converts {@link BundlerPlugin} (the bundler-agnostic
3
+ * contract shape) into an esbuild `Plugin`. The contract's onResolve /
4
+ * onLoad shapes were deliberately designed to match esbuild's, so the
5
+ * translation is near-1:1; this module exists to isolate the esbuild
6
+ * import from the rest of the extension.
7
+ *
8
+ * @module extensions/ext-bundler-esbuild/plugin-adapter
9
+ */
10
+ import type { BundlerPlugin } from "veryfront/extensions/bundler";
11
+ type EsbuildPlugin = any;
12
+ export declare function toEsbuildPlugin(plugin: BundlerPlugin): EsbuildPlugin;
13
+ export {};
14
+ //# sourceMappingURL=plugin-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-adapter.d.ts","sourceRoot":"","sources":["../src/plugin-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,8BAA8B,CAAC;AAEtC,KAAK,aAAa,GAAG,GAAG,CAAC;AAEzB,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CA4CpE"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Plugin adapter — converts {@link BundlerPlugin} (the bundler-agnostic
3
+ * contract shape) into an esbuild `Plugin`. The contract's onResolve /
4
+ * onLoad shapes were deliberately designed to match esbuild's, so the
5
+ * translation is near-1:1; this module exists to isolate the esbuild
6
+ * import from the rest of the extension.
7
+ *
8
+ * @module extensions/ext-bundler-esbuild/plugin-adapter
9
+ */
10
+ export function toEsbuildPlugin(plugin) {
11
+ return {
12
+ name: plugin.name,
13
+ // deno-lint-ignore no-explicit-any
14
+ setup(build) {
15
+ const bridged = {
16
+ onResolve(options, callback) {
17
+ // deno-lint-ignore no-explicit-any
18
+ build.onResolve(options, async (args) => {
19
+ const resolveArgs = {
20
+ path: args.path,
21
+ importer: args.importer,
22
+ namespace: args.namespace,
23
+ resolveDir: args.resolveDir,
24
+ kind: args.kind,
25
+ pluginData: args.pluginData,
26
+ };
27
+ const result = await callback(resolveArgs);
28
+ if (result == null)
29
+ return result ?? null;
30
+ return result;
31
+ });
32
+ },
33
+ onLoad(options, callback) {
34
+ // deno-lint-ignore no-explicit-any
35
+ build.onLoad(options, async (args) => {
36
+ const loadArgs = {
37
+ path: args.path,
38
+ namespace: args.namespace,
39
+ suffix: args.suffix,
40
+ pluginData: args.pluginData,
41
+ };
42
+ const result = await callback(loadArgs);
43
+ if (result == null)
44
+ return result ?? null;
45
+ return result;
46
+ });
47
+ },
48
+ onDispose(callback) {
49
+ build.onDispose(callback);
50
+ },
51
+ };
52
+ plugin.setup(bridged);
53
+ },
54
+ };
55
+ }
@@ -0,0 +1,4 @@
1
+ export declare const isDeno: boolean;
2
+ /** True if running inside a `deno compile`'d binary (needs VFS extraction). */
3
+ export declare const isDenoCompiled: boolean;
4
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,MAAM,EAAE,OAA+D,CAAC;AAkBrF,+EAA+E;AAC/E,eAAO,MAAM,cAAc,EAAE,OAA0C,CAAC"}
package/esm/runtime.js ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Runtime detection — inlined from src/platform/compat/runtime.ts so the
3
+ * extension stays dependency-free on core.
4
+ *
5
+ * Only the bits needed by the esbuild binary extractor are included here.
6
+ *
7
+ * @module extensions/ext-bundler-esbuild/runtime
8
+ */
9
+ import * as dntShim from "./_dnt.shims.js";
10
+ function hasRealDeno() {
11
+ return (typeof dntShim.Deno !== "undefined" &&
12
+ typeof dntShim.Deno.version === "object" &&
13
+ typeof dntShim.Deno.build === "object" &&
14
+ typeof dntShim.Deno.build.os === "string");
15
+ }
16
+ function hasBunGlobal() {
17
+ return dntShim.dntGlobalThis.Bun != null;
18
+ }
19
+ function hasNodeProcess() {
20
+ const g = dntShim.dntGlobalThis;
21
+ return g.process?.versions?.node != null && !g.process?.versions?.deno;
22
+ }
23
+ export const isDeno = !hasNodeProcess() && !hasBunGlobal() && hasRealDeno();
24
+ function testDenoCompiledDetection(execPath) {
25
+ if (!execPath)
26
+ return false;
27
+ const binary = execPath.split(/[/\\]/).pop()?.toLowerCase();
28
+ if (!binary)
29
+ return false;
30
+ return binary !== "deno" && binary !== "deno.exe";
31
+ }
32
+ function isDenoCompiledBinary() {
33
+ if (!hasRealDeno())
34
+ return false;
35
+ try {
36
+ return testDenoCompiledDetection(dntShim.Deno.execPath());
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ }
42
+ /** True if running inside a `deno compile`'d binary (needs VFS extraction). */
43
+ export const isDenoCompiled = isDeno && isDenoCompiledBinary();
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@veryfront/ext-bundler-esbuild",
3
+ "version": "0.1.985",
4
+ "description": "Veryfront first-party extension package for ext-bundler-esbuild",
5
+ "keywords": [
6
+ "veryfront",
7
+ "extension",
8
+ "ext-bundler-esbuild"
9
+ ],
10
+ "author": "Veryfront",
11
+ "homepage": "https://github.com/veryfront/veryfront-code/tree/main/extensions/ext-bundler-esbuild",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/veryfront/veryfront-code.git",
15
+ "directory": "extensions/ext-bundler-esbuild"
16
+ },
17
+ "license": "Apache-2.0",
18
+ "bugs": {
19
+ "url": "https://github.com/veryfront/veryfront-code/issues"
20
+ },
21
+ "module": "./esm/index.js",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./esm/index.js",
25
+ "types": "./esm/index.d.ts"
26
+ }
27
+ },
28
+ "scripts": {},
29
+ "engines": {
30
+ "node": ">=18.0.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "veryfront": {
36
+ "extension": true,
37
+ "contracts": {
38
+ "provides": [
39
+ "Bundler",
40
+ "ModuleLexer"
41
+ ]
42
+ },
43
+ "capabilities": []
44
+ },
45
+ "dependencies": {
46
+ "@deno/shim-deno": "~0.18.0",
47
+ "@deno/shim-crypto": "~0.3.1",
48
+ "@deno/shim-timers": "~0.1.0",
49
+ "es-module-lexer": "2.0.0",
50
+ "esbuild": "0.28.1"
51
+ },
52
+ "peerDependencies": {
53
+ "veryfront": "^0.1.985"
54
+ },
55
+ "type": "module",
56
+ "types": "./esm/index.d.ts",
57
+ "files": [
58
+ "esm",
59
+ "LICENSE",
60
+ "NOTICE",
61
+ "README.md"
62
+ ]
63
+ }