@afterpack/esbuild 0.1.0-rc.20260925T1347

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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 AfterPack
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ AfterPack CLI and framework integrations
2
+ Copyright 2026 AfterPack — https://www.afterpack.dev
3
+
4
+ This product includes software developed at AfterPack (https://www.afterpack.dev).
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @afterpack/esbuild
2
+
3
+ An esbuild plugin (esbuild 0.17 and later) that obfuscates your output when the build finishes,
4
+ using the [AfterPack](https://www.afterpack.dev) JavaScript obfuscator.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ npm install --save-dev @afterpack/esbuild
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ts
15
+ // build.ts
16
+ import { build } from "esbuild";
17
+ import { afterpackEsbuild } from "@afterpack/esbuild";
18
+
19
+ await build({
20
+ entryPoints: ["src/index.ts"],
21
+ outdir: "dist",
22
+ bundle: true,
23
+ plugins: [afterpackEsbuild()],
24
+ });
25
+ ```
26
+
27
+ Both `outdir` and `outfile` work. Builds with `write: false`, and builds that already failed, are
28
+ skipped. If obfuscation fails, the build fails.
29
+
30
+ esbuild has no hook to change output before it is written, so the plugin obfuscates the files right
31
+ after esbuild writes them. For a few milliseconds the readable files are on disk, and a failed run
32
+ leaves them there. If that matters to you, use a bundler with an in-memory plugin, such as
33
+ [`@afterpack/vite`](https://www.npmjs.com/package/@afterpack/vite) or
34
+ [`@afterpack/rollup`](https://www.npmjs.com/package/@afterpack/rollup).
35
+
36
+ Each build writes a protection receipt, `.afterpack-protection.json`, into the output directory.
37
+ Run `npx afterpack verify dist` in your deploy step to check that what you ship is what was
38
+ obfuscated.
39
+
40
+ ## Options
41
+
42
+ ```ts
43
+ afterpackEsbuild({ preset: "hard", seed: "git" });
44
+ ```
45
+
46
+ | Option | What it does | Default |
47
+ | --- | --- | --- |
48
+ | [`preset`][preset] | `"minify"`, `"light"`, `"medium"`, `"hard"` or `"extreme"` | `"light"` |
49
+ | [`seed`][seed] | a number or string; `"git"` uses the current commit | a new random seed per build |
50
+ | [`identifiers.reserved`][identifiers.reserved] | names never to rename | none |
51
+ | [`paths.exclude`][paths.exclude] | globs for files to leave untouched | none |
52
+ | [`sourceMap.enabled`][sourceMap.enabled] | write source maps for the obfuscated output | on in development when esbuild emits a map, off in production |
53
+ | [`protectionMap.enabled`][protectionMap.enabled] | write the Protection Map | on when esbuild's `sourcemap` is set |
54
+ | [`build.autorun`][build.autorun] | `false` turns AfterPack off | `true` |
55
+
56
+ Dotted names are nested objects: `sourceMap.enabled` is `{ sourceMap: { enabled: true } }`. Every
57
+ other option is in the [configuration reference](https://www.afterpack.dev/docs/config).
58
+
59
+ [preset]: https://www.afterpack.dev/docs/config#preset
60
+ [seed]: https://www.afterpack.dev/docs/config#seed
61
+ [identifiers.reserved]: https://www.afterpack.dev/docs/config#identifiers-reserved
62
+ [paths.exclude]: https://www.afterpack.dev/docs/config#paths-exclude
63
+ [sourceMap.enabled]: https://www.afterpack.dev/docs/config#sourceMap-enabled
64
+ [protectionMap.enabled]: https://www.afterpack.dev/docs/config#protectionMap-enabled
65
+ [build.autorun]: https://www.afterpack.dev/docs/config#build-autorun
66
+
67
+ `/* @afterpack */` directives need esbuild's `sourcemap: true`, since they are read back from the
68
+ source map. Without it, the plugin skips them and tells you.
69
+
70
+ The [Protection Map](https://www.afterpack.dev/docs/protection-map) is written to `.afterpack/`,
71
+ and the plugin adds its local artifacts to your `.gitignore`. The Protection Map and any backups
72
+ contain your original source, so never deploy or commit them.
73
+
74
+ Options can also live in `afterpack.json` or in `AFTERPACK_*` environment variables. The options
75
+ object wins over the environment, which wins over the file. An unknown or misspelled key fails the
76
+ build and names the right spelling.
77
+
78
+ ## Pro
79
+
80
+ Without a key, AfterPack runs on your machine and applies basic protection. Set
81
+ [`AFTERPACK_KEY`](https://www.afterpack.dev/docs/config#key) in your environment and the same plugin
82
+ sends the build to AfterPack's cloud, which applies much stronger protection. Keep the key out of
83
+ your build script: the plugin rejects it there. See [AfterPack
84
+ Pro](https://www.afterpack.dev/docs/pro).
85
+
86
+ ## Links
87
+
88
+ - [esbuild setup guide](https://www.afterpack.dev/docs/frameworks/esbuild)
89
+ - [Presets and protection levels](https://www.afterpack.dev/docs/presets)
90
+ - [How AfterPack compares to other obfuscators](https://www.afterpack.dev/docs/comparison)
91
+ - [Protecting code that ships to browser extensions](https://www.afterpack.dev/docs/use-cases/browser-extensions)
92
+
93
+ ## License
94
+
95
+ Apache-2.0. The engine it runs, `@afterpack/core`, has its own
96
+ [license](https://www.afterpack.dev/license).
97
+
98
+ ## Feedback
99
+
100
+ Questions, suggestions and bug reports: [afterpack.dev/contact](https://www.afterpack.dev/contact).
101
+ You can also file a bug on [GitHub Issues](https://github.com/afterpack-dev/afterpack/issues).
package/dist/index.cjs ADDED
@@ -0,0 +1,100 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const node_fs = __toESM(require("node:fs"));
25
+ const node_path = __toESM(require("node:path"));
26
+ const __afterpack_core = __toESM(require("@afterpack/core"));
27
+ const __afterpack_integration_utils = __toESM(require("@afterpack/integration-utils"));
28
+
29
+ //#region src/index.ts
30
+ function resolveOutputs(io, cwd, include) {
31
+ if (io.outdir) {
32
+ const dir = (0, node_path.isAbsolute)(io.outdir) ? io.outdir : (0, node_path.resolve)(cwd, io.outdir);
33
+ return {
34
+ files: (0, __afterpack_integration_utils.collectJsFiles)(dir, { include }),
35
+ buildDir: dir
36
+ };
37
+ }
38
+ if (io.outfile) {
39
+ const file = (0, node_path.isAbsolute)(io.outfile) ? io.outfile : (0, node_path.resolve)(cwd, io.outfile);
40
+ return {
41
+ files: (0, node_fs.existsSync)(file) ? [file] : [],
42
+ buildDir: (0, node_path.dirname)(file)
43
+ };
44
+ }
45
+ return {
46
+ files: [],
47
+ buildDir: cwd
48
+ };
49
+ }
50
+ const POST_MINIFY_DIRECTIVE_RECOVERY = true;
51
+ function afterpackEsbuild(options = {}) {
52
+ const resolved = (0, __afterpack_integration_utils.resolvePluginConfig)({
53
+ label: "afterpack-esbuild",
54
+ options
55
+ });
56
+ const settings = resolved.options;
57
+ return {
58
+ name: "afterpack-esbuild",
59
+ setup(build) {
60
+ build.onEnd(async (result) => {
61
+ const autorun = settings.build?.autorun ?? true;
62
+ if (!autorun) return;
63
+ if (result.errors.length > 0) return;
64
+ const io = build.initialOptions;
65
+ if (io.write === false) return;
66
+ const startedBeforeOutputWalk = Date.now();
67
+ const cwd = io.absWorkingDir ?? process.cwd();
68
+ const { files, buildDir } = resolveOutputs(io, cwd, settings.paths?.include);
69
+ if (files.length === 0) return;
70
+ const gitignoredNonServedAfterpackDir = (0, node_path.join)(cwd, ".afterpack");
71
+ await (0, __afterpack_integration_utils.runObfuscationPass)({
72
+ files,
73
+ engine: {
74
+ processBatch: __afterpack_core.processBatch,
75
+ version: __afterpack_core.version
76
+ },
77
+ client: (0, __afterpack_integration_utils.resolveClientIdentity)(require("url").pathToFileURL(__filename).href),
78
+ telemetry: (0, __afterpack_integration_utils.createTelemetryReporter)(),
79
+ label: "afterpack-esbuild",
80
+ gitignoreDir: cwd,
81
+ startedAt: startedBeforeOutputWalk,
82
+ combinedProtectionMap: {
83
+ buildDir,
84
+ afterpackDir: gitignoredNonServedAfterpackDir
85
+ },
86
+ ...(0, __afterpack_integration_utils.passSettings)(resolved),
87
+ hasBundlerSourcemap: Boolean(io.sourcemap),
88
+ postMinify: POST_MINIFY_DIRECTIVE_RECOVERY,
89
+ messages: {
90
+ autoEnableBundlerSourcemap: "protectionMap:true but no bundler sourcemap was found; set `sourcemap: true` so future builds can render original source in the map.",
91
+ directivesNeedClientMaps: "`directives.enabled` is true but no emitted file carried a source map with `sourcesContent`; set `sourcemap: true` so `/* @afterpack ... */` directives can be recovered from the emitted chunks. No directive was applied to this build."
92
+ }
93
+ });
94
+ });
95
+ }
96
+ };
97
+ }
98
+
99
+ //#endregion
100
+ exports.afterpackEsbuild = afterpackEsbuild;
@@ -0,0 +1,8 @@
1
+ import { AfterpackPluginOptions } from "@afterpack/integration-utils";
2
+ import { Plugin } from "esbuild";
3
+
4
+ //#region src/index.d.ts
5
+ type AfterpackEsbuildOptions = AfterpackPluginOptions;
6
+ declare function afterpackEsbuild(options?: AfterpackEsbuildOptions): Plugin;
7
+ //#endregion
8
+ export { AfterpackEsbuildOptions, afterpackEsbuild };
@@ -0,0 +1,8 @@
1
+ import { AfterpackPluginOptions } from "@afterpack/integration-utils";
2
+ import { Plugin } from "esbuild";
3
+
4
+ //#region src/index.d.ts
5
+ type AfterpackEsbuildOptions = AfterpackPluginOptions;
6
+ declare function afterpackEsbuild(options?: AfterpackEsbuildOptions): Plugin;
7
+ //#endregion
8
+ export { AfterpackEsbuildOptions, afterpackEsbuild };
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, isAbsolute, join, resolve } from "node:path";
3
+ import { processBatch, version } from "@afterpack/core";
4
+ import { collectJsFiles, createTelemetryReporter, passSettings, resolveClientIdentity, resolvePluginConfig, runObfuscationPass } from "@afterpack/integration-utils";
5
+
6
+ //#region src/index.ts
7
+ function resolveOutputs(io, cwd, include) {
8
+ if (io.outdir) {
9
+ const dir = isAbsolute(io.outdir) ? io.outdir : resolve(cwd, io.outdir);
10
+ return {
11
+ files: collectJsFiles(dir, { include }),
12
+ buildDir: dir
13
+ };
14
+ }
15
+ if (io.outfile) {
16
+ const file = isAbsolute(io.outfile) ? io.outfile : resolve(cwd, io.outfile);
17
+ return {
18
+ files: existsSync(file) ? [file] : [],
19
+ buildDir: dirname(file)
20
+ };
21
+ }
22
+ return {
23
+ files: [],
24
+ buildDir: cwd
25
+ };
26
+ }
27
+ const POST_MINIFY_DIRECTIVE_RECOVERY = true;
28
+ function afterpackEsbuild(options = {}) {
29
+ const resolved = resolvePluginConfig({
30
+ label: "afterpack-esbuild",
31
+ options
32
+ });
33
+ const settings = resolved.options;
34
+ return {
35
+ name: "afterpack-esbuild",
36
+ setup(build) {
37
+ build.onEnd(async (result) => {
38
+ const autorun = settings.build?.autorun ?? true;
39
+ if (!autorun) return;
40
+ if (result.errors.length > 0) return;
41
+ const io = build.initialOptions;
42
+ if (io.write === false) return;
43
+ const startedBeforeOutputWalk = Date.now();
44
+ const cwd = io.absWorkingDir ?? process.cwd();
45
+ const { files, buildDir } = resolveOutputs(io, cwd, settings.paths?.include);
46
+ if (files.length === 0) return;
47
+ const gitignoredNonServedAfterpackDir = join(cwd, ".afterpack");
48
+ await runObfuscationPass({
49
+ files,
50
+ engine: {
51
+ processBatch,
52
+ version
53
+ },
54
+ client: resolveClientIdentity(import.meta.url),
55
+ telemetry: createTelemetryReporter(),
56
+ label: "afterpack-esbuild",
57
+ gitignoreDir: cwd,
58
+ startedAt: startedBeforeOutputWalk,
59
+ combinedProtectionMap: {
60
+ buildDir,
61
+ afterpackDir: gitignoredNonServedAfterpackDir
62
+ },
63
+ ...passSettings(resolved),
64
+ hasBundlerSourcemap: Boolean(io.sourcemap),
65
+ postMinify: POST_MINIFY_DIRECTIVE_RECOVERY,
66
+ messages: {
67
+ autoEnableBundlerSourcemap: "protectionMap:true but no bundler sourcemap was found; set `sourcemap: true` so future builds can render original source in the map.",
68
+ directivesNeedClientMaps: "`directives.enabled` is true but no emitted file carried a source map with `sourcesContent`; set `sourcemap: true` so `/* @afterpack ... */` directives can be recovered from the emitted chunks. No directive was applied to this build."
69
+ }
70
+ });
71
+ });
72
+ }
73
+ };
74
+ }
75
+
76
+ //#endregion
77
+ export { afterpackEsbuild };
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@afterpack/esbuild",
3
+ "version": "0.1.0-rc.20260925T1347",
4
+ "description": "esbuild plugin for AfterPack: obfuscate your JavaScript output when the esbuild build finishes",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ },
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "LICENSE",
24
+ "NOTICE",
25
+ "dist"
26
+ ],
27
+ "peerDependencies": {
28
+ "esbuild": ">=0.17.0"
29
+ },
30
+ "dependencies": {
31
+ "@afterpack/core": "~0.1.0",
32
+ "@afterpack/integration-utils": "0.1.0-rc.20260925T1347"
33
+ },
34
+ "devDependencies": {
35
+ "@biomejs/biome": "2.4.4",
36
+ "@types/node": "^22.0.0",
37
+ "esbuild": ">=0.17.0",
38
+ "tsdown": "^0.11.0",
39
+ "typescript": "^5.0.0",
40
+ "vitest": "^2.0.0"
41
+ },
42
+ "engines": {
43
+ "node": ">=18"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/afterpack-dev/afterpack.git",
51
+ "directory": "packages/esbuild"
52
+ },
53
+ "keywords": [
54
+ "obfuscator",
55
+ "javascript-obfuscator",
56
+ "obfuscation",
57
+ "code-protection",
58
+ "source-code-protection",
59
+ "javascript-security",
60
+ "anti-reverse-engineering",
61
+ "esbuild",
62
+ "esbuild-plugin",
63
+ "afterpack"
64
+ ],
65
+ "author": "AfterPack (https://www.afterpack.dev)",
66
+ "license": "Apache-2.0",
67
+ "homepage": "https://www.afterpack.dev/docs/frameworks/esbuild",
68
+ "bugs": {
69
+ "url": "https://github.com/afterpack-dev/afterpack/issues"
70
+ },
71
+ "scripts": {
72
+ "build": "tsdown src/index.ts --format esm --format cjs --dts --shims",
73
+ "dev": "tsdown src/index.ts --format esm --format cjs --shims --watch",
74
+ "lint": "biome check .",
75
+ "lint:fix": "biome check --write .",
76
+ "typecheck": "tsc --noEmit",
77
+ "test": "vitest run"
78
+ }
79
+ }