@epublishing/grunt-epublishing 1.2.4 → 1.2.6

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.
@@ -141,7 +141,21 @@ async function ensureDir(filePath) {
141
141
  }
142
142
 
143
143
  /**
144
- * Compile a single Sass file
144
+ * Compile a single Sass file in an isolated dart-sass compiler instance.
145
+ *
146
+ * Uses `sass.initAsyncCompiler()` instead of the module-level
147
+ * `sass.compileAsync()` to guarantee no shared state between concurrent
148
+ * compilations. The module-level singleton queues all calls through a
149
+ * single long-running dart-sass worker; in that model any subtle stateful
150
+ * behavior (import caching, in-flight deps, etc.) can bleed from one
151
+ * compilation's output into another's when we run a chunk in parallel.
152
+ *
153
+ * The symptom was stylesheets ending up with rules that their source
154
+ * file never imported (e.g. achrnews `application-v2.css` getting print
155
+ * rules from `jade-bnp-print.scss`). With a per-file isolated compiler,
156
+ * each file is compiled in its own worker, disposed when done — no
157
+ * possible cross-contamination vector.
158
+ *
145
159
  * @param {string} src - Source file path
146
160
  * @param {string} dest - Destination file path
147
161
  * @param {Object} options - Compilation options
@@ -163,8 +177,10 @@ async function compileFile(src, dest, options = {}) {
163
177
  importers.push(adaptLegacyImporter(legacyImporter));
164
178
  }
165
179
 
180
+ let compiler = null;
166
181
  try {
167
- const result = await sass.compileAsync(src, {
182
+ compiler = await sass.initAsyncCompiler();
183
+ const result = await compiler.compileAsync(src, {
168
184
  style,
169
185
  sourceMap,
170
186
  loadPaths,
@@ -187,6 +203,14 @@ async function compileFile(src, dest, options = {}) {
187
203
  return { src, dest, success: true };
188
204
  } catch (error) {
189
205
  return { src, dest, success: false, error };
206
+ } finally {
207
+ if (compiler) {
208
+ try {
209
+ await compiler.dispose();
210
+ } catch {
211
+ // Disposal errors are not actionable; compiler is going away.
212
+ }
213
+ }
190
214
  }
191
215
  }
192
216
 
@@ -198,7 +222,11 @@ async function compileFile(src, dest, options = {}) {
198
222
  */
199
223
  async function compileSass(config, options = {}) {
200
224
  const {
201
- maxConcurrency = 2, // Limit for memory optimization
225
+ // Serial by default. compileFile() now spawns an isolated dart-sass
226
+ // compiler per file so concurrency wouldn't actually share state, but
227
+ // running serial gives us deterministic output ordering and bounded
228
+ // memory use. --parallel in cli.js still bumps this to 4 if needed.
229
+ maxConcurrency = 1,
202
230
  verbose = false,
203
231
  } = options;
204
232
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epublishing/grunt-epublishing",
3
3
  "description": "Modern front-end build tools for ePublishing Jade and client sites.",
4
- "version": "1.2.4",
4
+ "version": "1.2.6",
5
5
  "homepage": "https://www.epublishing.com",
6
6
  "contributors": [
7
7
  {
@@ -58,7 +58,6 @@
58
58
  "prettyjson": "^1.2.5",
59
59
  "read-pkg": "^5.2.0",
60
60
  "sass-embedded": "^1.80.0",
61
- "sass-embedded-linux-x64": "^1.80.0",
62
61
  "style-loader": "^4.0.0",
63
62
  "susy": "^2.2.14",
64
63
  "swc-loader": "^0.2.6",
@@ -74,7 +73,8 @@
74
73
  "@swc/core-linux-arm64-gnu": "^1.7.0",
75
74
  "sass-embedded-darwin-arm64": "^1.80.0",
76
75
  "sass-embedded-darwin-x64": "^1.80.0",
77
- "sass-embedded-linux-arm64": "^1.80.0"
76
+ "sass-embedded-linux-arm64": "^1.80.0",
77
+ "sass-embedded-linux-x64": "^1.80.0"
78
78
  },
79
79
  "keywords": [
80
80
  "webpack",