vanilla-jet 1.5.0 → 1.5.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ All notable project changes are documented in this file.
4
4
 
5
5
  The format follows a structure inspired by Keep a Changelog and semantic versioning.
6
6
 
7
+ ## [1.5.1] - 2026-06-28
8
+
9
+ ### Changed
10
+
11
+ - **Service worker precache is now fully derived from `vanillaJet.package.json`.** `scripts/generate_sw.js`
12
+ reads the Dipper's full local registry (`coreDependencies` + `dependencies` + `styles` that resolve to
13
+ `/public/...`) instead of only the enqueued subset, so first-party assets like `coreLib/*` are precached
14
+ automatically. Consumers no longer need to hardcode a `service_worker.precache` list.
15
+ - Added `service_worker.precache_exclude` (opt-out by path) for declared assets you don't want cached.
16
+ `service_worker.precache` remains as an optional escape hatch for extras not declared in the package file.
17
+
18
+ ### Compatibility notes
19
+
20
+ - Backward compatible: an explicit `service_worker.precache` still works (merged with the derived set).
21
+
7
22
  ## [1.5.0] - 2026-06-27
8
23
 
9
24
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-jet",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "VannilaJet framework",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -63,9 +63,11 @@ function isLocalPublicPath(url) {
63
63
  return typeof url === 'string' && url.startsWith('/public/') && !url.startsWith('//');
64
64
  }
65
65
 
66
- // Best-effort: read the resources the Dipper enqueues for this app, so consumer
67
- // plugins/styles get precached automatically. Any failure falls back to core only.
68
- function deriveEnqueuedAssets(root, opts, shared) {
66
+ // Source of truth = vanillaJet.package.json. We hydrate the Dipper and read its full
67
+ // registry (coreDependencies + dependencies + styles), keeping every LOCAL resource.
68
+ // This way the precache list is derived from the declared deps, with no raw paths in
69
+ // the consumer config. Any failure falls back to core only.
70
+ function deriveLocalAssets(root, opts, shared) {
69
71
  try {
70
72
  const Dipper = require('../framework/dipper.js');
71
73
  const Functions = require('../framework/functions.js');
@@ -73,16 +75,16 @@ function deriveEnqueuedAssets(root, opts, shared) {
73
75
  Functions.hydrate(dipper);
74
76
 
75
77
  const assets = [];
76
- const collect = (registry, enqueued) => {
77
- Object.keys(enqueued || {}).forEach((name) => {
78
+ const collect = (registry) => {
79
+ Object.keys(registry || {}).forEach((name) => {
78
80
  const entry = registry[name];
79
81
  if (entry && isLocalPublicPath(entry.resource)) {
80
82
  assets.push(stripQuery(entry.resource));
81
83
  }
82
84
  });
83
85
  };
84
- collect(dipper.styles, dipper.enqueued_styles);
85
- collect(dipper.scripts, dipper.enqueued_scripts);
86
+ collect(dipper.styles);
87
+ collect(dipper.scripts);
86
88
  return assets;
87
89
  } catch (err) {
88
90
  return [];
@@ -90,15 +92,18 @@ function deriveEnqueuedAssets(root, opts, shared) {
90
92
  }
91
93
 
92
94
  function buildPrecacheList(root, opts, shared) {
93
- const configured = (opts.service_worker && Array.isArray(opts.service_worker.precache))
94
- ? opts.service_worker.precache
95
- : [];
95
+ const sw = opts.service_worker || {};
96
+ // `precache` = optional extras NOT declared in vanillaJet.package.json.
97
+ const configured = Array.isArray(sw.precache) ? sw.precache : [];
98
+ // `precache_exclude` = opt-out for declared-but-don't-cache assets (heavy/rare).
99
+ const exclude = (Array.isArray(sw.precache_exclude) ? sw.precache_exclude : []).map(stripQuery);
96
100
 
97
101
  const candidates = CORE_PRECACHE
98
- .concat(deriveEnqueuedAssets(root, opts, shared))
102
+ .concat(deriveLocalAssets(root, opts, shared))
99
103
  .concat(configured)
100
104
  .map(stripQuery)
101
- .filter(isLocalPublicPath);
105
+ .filter(isLocalPublicPath)
106
+ .filter((assetPath) => !exclude.includes(assetPath));
102
107
 
103
108
  const seen = new Set();
104
109
  const precache = [];