@afterpack/parcel-optimizer 0.2.7 → 1.0.0

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
@@ -38,7 +38,7 @@ directory, so the receipt never ships with the build:
38
38
 
39
39
  ```sh
40
40
  parcel build index.html --reporter @afterpack/parcel-optimizer/reporter
41
- npx afterpack verify dist # in the deploy step, before the upload
41
+ npx afterpack@latest verify dist # in the deploy step, before the upload
42
42
  ```
43
43
 
44
44
  `afterpack verify` fails if a file changed after it was obfuscated, or if there is no receipt. The
@@ -68,7 +68,7 @@ there, ignored by git.
68
68
  | [`identifiers.reserved`][identifiers.reserved] | names never to rename | none |
69
69
  | [`paths.exclude`][paths.exclude] | globs for files to leave untouched | none |
70
70
  | [`sourceMap.enabled`][sourceMap.enabled] | write source maps for the obfuscated output | on in development when an input map exists, off in production |
71
- | [`protectionMap.enabled`][protectionMap.enabled] | write the Protection Map | on when the bundle has a source map |
71
+ | [`protectionMap.enabled`][protectionMap.enabled] | write the Protection Map | on when the bundle has a source map, outside CI |
72
72
  | [`build.autorun`][build.autorun] | `false` turns AfterPack off | `true` |
73
73
 
74
74
  Every other option is in the [configuration reference](https://www.afterpack.dev/docs/config). An
@@ -84,9 +84,10 @@ unknown or misspelled key fails the build and names the right spelling.
84
84
  [build.backup]: https://www.afterpack.dev/docs/config#build-backup
85
85
  [paths.include]: https://www.afterpack.dev/docs/config#paths-include
86
86
 
87
- The plugin writes one [Protection Map](https://www.afterpack.dev/docs/protection-map) per bundle to
88
- `.afterpack/`, which carries its own `.gitignore` and self-ignores. It contains your original
89
- source, so never deploy or commit it.
87
+ When a bundle has a source map, the plugin writes one
88
+ [Protection Map](https://www.afterpack.dev/docs/protection-map) per bundle to `.afterpack/`, which
89
+ carries its own `.gitignore` and self-ignores. Without source maps, or in CI, it is off unless
90
+ `protectionMap.enabled` is `true`. It contains your original source, so never deploy or commit it.
90
91
 
91
92
  ## Things to know
92
93
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { clearBundleRecord, escapeParcelMarkdown, writeBundleRecord } from "./records-Bgj9LonR.js";
1
+ import { clearBundleRecord, escapeParcelMarkdown, writeBundleRecord } from "./records-Caphe8VV.js";
2
2
  import { join } from "node:path";
3
3
  import { text } from "node:stream/consumers";
4
4
  import { processBatch, version } from "@afterpack/core";
@@ -44,7 +44,7 @@ var src_default = new Optimizer({
44
44
  const mergedWithEnvOutrankingFile = mergeConfig(fromFile.config, fromEnv.config);
45
45
  const view = toPluginOptions(mergedWithEnvOutrankingFile);
46
46
  if ((view.paths?.include ?? []).length > 0) throw new ThrowableDiagnostic({ diagnostic: {
47
- message: "`paths.include` is not supported here — an Optimizer is handed each packaged bundle in memory, so there is no output-directory walk for a glob to re-admit anything into. Use `npx afterpack <dir> --paths.include=...` for a disk walk, or drop the key.",
47
+ message: "`paths.include` is not supported here — an Optimizer is handed each packaged bundle in memory, so there is no output-directory walk for a glob to re-admit anything into. Use `npx afterpack@latest <dir> --paths.include=...` for a disk walk, or drop the key.",
48
48
  origin: PLUGIN_NAME
49
49
  } });
50
50
  applyResolvedKey(mergedWithEnvOutrankingFile);
@@ -107,6 +107,7 @@ var src_default = new Optimizer({
107
107
  }
108
108
  },
109
109
  hasBundlerSourcemap: Boolean(bundle.env.sourceMap),
110
+ receipt: { bundler: "parcel" },
110
111
  env: seedEnvCopy,
111
112
  logger: {
112
113
  warn: (message) => logger.warn({ message: escapeParcelMarkdown(message) }),
@@ -144,7 +145,8 @@ var src_default = new Optimizer({
144
145
  engineVersion: receipt.engineVersion,
145
146
  seed: String(receipt.seed),
146
147
  seedOrigin: receipt.seedOrigin,
147
- transformed: receipt.transformed.includes(projectedFilePath)
148
+ transformed: receipt.transformed.includes(projectedFilePath),
149
+ bundler: receipt.bundler
148
150
  });
149
151
  let outCode = out.code;
150
152
  let originalRelativeSourceMap = null;
@@ -39,6 +39,7 @@ function readBundleRecord(projectRoot, bundleId) {
39
39
  if (raw === null || typeof raw !== "object") return null;
40
40
  const record = raw;
41
41
  if (typeof record.tool !== "string" || typeof record.transformed !== "boolean") return null;
42
+ if (record.bundler !== void 0 && typeof record.bundler !== "string") return null;
42
43
  return record;
43
44
  } catch {
44
45
  return null;
package/dist/reporter.js CHANGED
@@ -1,4 +1,4 @@
1
- import { clearBundleRecords, escapeParcelMarkdown, readBundleRecord } from "./records-Bgj9LonR.js";
1
+ import { clearBundleRecords, escapeParcelMarkdown, readBundleRecord } from "./records-Caphe8VV.js";
2
2
  import { relative } from "node:path";
3
3
  import { protectionReceiptPath, sweepOutputTree, writeProtectionReceipt } from "@afterpack/integration-utils";
4
4
  import { Reporter } from "@parcel/plugin";
@@ -62,7 +62,7 @@ var reporter_default = new Reporter({ report({ event, options, logger }) {
62
62
  engineVersion: agreed(records.map((r) => r.engineVersion)),
63
63
  seed: joined(records.map((r) => r.seed)),
64
64
  seedOrigin: joined(records.map((r) => r.seedOrigin)),
65
- bundler: "parcel",
65
+ bundler: records[0].bundler ?? "parcel",
66
66
  buildId: null,
67
67
  files: tree.files,
68
68
  transformed: tree.transformed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterpack/parcel-optimizer",
3
- "version": "0.2.7",
3
+ "version": "1.0.0",
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.8",
29
+ "@afterpack/core": "~1.0.0",
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.7"
33
+ "@afterpack/integration-utils": "1.0.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@biomejs/biome": "2.4.4",
@@ -39,7 +39,7 @@
39
39
  "@types/node": "^22.0.0",
40
40
  "tsdown": "^0.11.0",
41
41
  "typescript": "^5.0.0",
42
- "vitest": "^2.0.0"
42
+ "vitest": "^4.1.12"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=18",