@afterpack/parcel-optimizer 0.2.2 → 0.2.4

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/README.md CHANGED
@@ -30,8 +30,11 @@ build fails.
30
30
 
31
31
  ## Check a deploy
32
32
 
33
- Add the plugin's reporter to the build command, and each build writes `.afterpack-protection.json`
34
- into the target's output directory, a receipt with a hash per obfuscated bundle:
33
+ Add the plugin's reporter to the build command, and each build writes a receipt with a hash per
34
+ obfuscated bundle to `.afterpack/receipts/`, one per target output directory
35
+ (`.afterpack/receipts/dist.json` for `dist`). `.afterpack/` sits next to your project's lockfile,
36
+ `afterpack.json` or `.git` (failing those, its `package.json`), otherwise beside the output
37
+ directory, so the receipt never ships with the build:
35
38
 
36
39
  ```sh
37
40
  parcel build index.html --reporter @afterpack/parcel-optimizer/reporter
package/dist/index.js CHANGED
@@ -75,7 +75,6 @@ var src_default = new Optimizer({
75
75
  inlineSources: true,
76
76
  format: "string"
77
77
  })) : null;
78
- const gitignoredNonServedAfterpackDir = join(options.projectRoot, ".afterpack");
79
78
  const seedEnvCopy = { ...options.env };
80
79
  const result = await runObfuscationPass({
81
80
  files: [projectedFilePath],
@@ -95,10 +94,10 @@ var src_default = new Optimizer({
95
94
  startedAt,
96
95
  combinedProtectionMap: {
97
96
  buildDir: bundle.target.distDir,
98
- afterpackDir: gitignoredNonServedAfterpackDir,
99
97
  fileName: `${bundleLegIdentity}.protectionMap.html`
100
98
  },
101
99
  buildLeg: bundleLegIdentity,
100
+ outputSweep: false,
102
101
  sourceType: sourceTypeForOutputFormat(bundle.env.outputFormat),
103
102
  artifactOptions: {
104
103
  ...config.options.artifactOptions,
package/dist/reporter.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { clearBundleRecords, escapeParcelMarkdown, readBundleRecord } from "./records-Bgj9LonR.js";
2
- import { join, relative } from "node:path";
3
- import { PROTECTION_RECEIPT_FILE, writeProtectionReceipt } from "@afterpack/integration-utils";
2
+ import { relative } from "node:path";
3
+ import { protectionReceiptPath, sweepOutputTree, writeProtectionReceipt } from "@afterpack/integration-utils";
4
4
  import { Reporter } from "@parcel/plugin";
5
5
  import { rmSync } from "node:fs";
6
6
 
@@ -47,7 +47,8 @@ var reporter_default = new Reporter({ report({ event, options, logger }) {
47
47
  if (event.type !== "buildSuccess") return;
48
48
  const trees = collectDistTrees(event.bundleGraph.getBundles(), options.projectRoot);
49
49
  for (const [dir, tree] of trees) {
50
- const receiptPath = join(dir, PROTECTION_RECEIPT_FILE);
50
+ sweepOutputTree(dir, dir, LABEL);
51
+ const receiptPath = protectionReceiptPath(dir);
51
52
  if (tree.unrecorded.length > 0) {
52
53
  rmSync(receiptPath, { force: true });
53
54
  logger.warn({ message: escapeParcelMarkdown(`[${LABEL}] no protection receipt for ${relative(options.projectRoot, dir)}: AfterPack has no record of obfuscating ${tree.unrecorded.join(", ")} in this build. Keep @afterpack/parcel-optimizer in .parcelrc and build.autorun on; a bundle Parcel reused from .parcel-cache has no record either, so clear .parcel-cache and rebuild.`) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterpack/parcel-optimizer",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Parcel 2 optimizer for AfterPack: obfuscate each JavaScript bundle in memory during parcel build",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,11 +26,11 @@
26
26
  "@parcel/core": ">=2.9.0"
27
27
  },
28
28
  "dependencies": {
29
- "@afterpack/core": "~0.2.3",
29
+ "@afterpack/core": "~0.2.5",
30
30
  "@parcel/diagnostic": "^2.9.0",
31
31
  "@parcel/plugin": "^2.9.0",
32
32
  "@parcel/source-map": "^2.1.1",
33
- "@afterpack/integration-utils": "0.2.2"
33
+ "@afterpack/integration-utils": "0.2.4"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@biomejs/biome": "2.4.4",