@financial-times/dotcom-build-sass 9.3.0 → 9.3.2

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.
@@ -44,6 +44,7 @@ class SassStats {
44
44
  _file.set(this, path_1.default.join(__classPrivateFieldGet(this, _directory), 'sass-stats.json'));
45
45
  _startTime.set(this, void 0);
46
46
  _endTime.set(this, void 0);
47
+ this.buildCount = 0;
47
48
  this.start = () => {
48
49
  __classPrivateFieldGet(this, _read).call(this);
49
50
  __classPrivateFieldSet(this, _startTime, performance.now());
@@ -148,12 +149,12 @@ class SassStats {
148
149
  ? `${minutes.toFixed(0)} minutes`
149
150
  : `${seconds.toFixed(0)} seconds`;
150
151
  const emoji = hours > 2 ? ['🔥', '😭', '😱'] : hours >= 1 ? ['🔥', '😱'] : minutes > 10 ? ['⏱️', '😬'] : ['⏱️'];
151
- let cta = `Share your pain in Slack #sass-to-css, and help fix that! 🎉\n` +
152
+ let cta = `Share your high score in Slack #sass-to-css 🎉 And help us improve that:\n` +
152
153
  `https://origami.ft.com/blog/2024/01/24/sass-build-times/\n\n`;
153
154
  if (!__classPrivateFieldGet(this, _monitorRemotely)) {
154
155
  cta =
155
156
  `Help us improve build times by setting the "FT_SASS_STATS_MONITOR" environment variable.\n` +
156
- `https://github.com/Financial-Times/biz-ops-metrics-api/blob/main/docs/API_DEFINITION.md#sass-build-monitoring \n\n`;
157
+ `https://origami.ft.com/blog/2024/01/24/sass-build-times/ \n\n`;
157
158
  }
158
159
  // eslint-disable-next-line no-console
159
160
  console.log(`\n\ndotcom-build-sass:\nYou have spent at least ${emoji.join(' ')} ${time} ${emoji
@@ -161,7 +162,7 @@ class SassStats {
161
162
  .join(' ')} waiting on FT Sass to compile.\n${cta}`);
162
163
  __classPrivateFieldGet(this, _write).call(this, { noticeDate: Date.now(), totalTimeAtLastNotice: __classPrivateFieldGet(this, _stats).totalTime });
163
164
  });
164
- fs_1.default.mkdirSync(path_1.default.dirname(__classPrivateFieldGet(this, _directory)), { recursive: true });
165
+ fs_1.default.mkdirSync(__classPrivateFieldGet(this, _directory), { recursive: true });
165
166
  }
166
167
  }
167
168
  _monitorRemotely = new WeakMap(), _noticeStrategies = new WeakMap(), _noticeStrategy = new WeakMap(), _noticeThrottleSeconds = new WeakMap(), _noticeThrottlePercentage = new WeakMap(), _stats = new WeakMap(), _directory = new WeakMap(), _file = new WeakMap(), _startTime = new WeakMap(), _endTime = new WeakMap(), _read = new WeakMap(), _write = new WeakMap(), _report = new WeakMap();
@@ -182,9 +183,12 @@ const forgivingProxy = (target, task) => {
182
183
  };
183
184
  const stats = new SassStats();
184
185
  const monitoredSassLoaderProxy = forgivingProxy(sass_loader_1.default, (target, sassLoaderThis, argumentsList) => {
186
+ stats.buildCount++;
185
187
  // Start the timer, sass-loader has been called with Sass content.
186
188
  // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L19
187
- stats.start();
189
+ if (stats.buildCount === 1) {
190
+ stats.start();
191
+ }
188
192
  // Assign our proxy to sass-loaders async function.
189
193
  // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L29
190
194
  const sassLoaderAsyncProxy = forgivingProxy(sassLoaderThis.async, (target, thisArg, argumentsList) => {
@@ -195,9 +199,12 @@ const monitoredSassLoaderProxy = forgivingProxy(sass_loader_1.default, (target,
195
199
  return forgivingProxy(sassLoaderCallback, (target, thisArg, argumentsList) => {
196
200
  // sass-loader's callback has been... called.
197
201
  // Either we have sass, or the build failed.
198
- stats.end();
199
- stats.reportAccordingToNoticeStrategy();
200
- stats.sendMetric();
202
+ stats.buildCount--;
203
+ if (stats.buildCount === 0) {
204
+ stats.end();
205
+ stats.reportAccordingToNoticeStrategy();
206
+ stats.sendMetric();
207
+ }
201
208
  return Reflect.apply(target, thisArg, argumentsList);
202
209
  });
203
210
  });
@@ -457,7 +457,7 @@
457
457
  "affectsGlobalScope": false
458
458
  },
459
459
  "../src/monitored-sass-loader.ts": {
460
- "version": "284b63b2fe068813dab4f81fa6016322237f4fe86ec49632102784ebd8bb291e",
460
+ "version": "7792194c38b38dc79682dd8bdc9ad91ddce6a578bad9a06065292208ddd75d48",
461
461
  "signature": "d6c7e7fe7e8f3b80e77d715b5d0d632a6bdb41bfa6c96d464997d2f698366e9b",
462
462
  "affectsGlobalScope": false
463
463
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-build-sass",
3
- "version": "9.3.0",
3
+ "version": "9.3.2",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "types": "dist/node/index.d.ts",
@@ -30,9 +30,10 @@ class SassStats {
30
30
  #file = path.join(this.#directory, 'sass-stats.json')
31
31
  #startTime
32
32
  #endTime
33
+ buildCount: number = 0
33
34
 
34
35
  constructor() {
35
- fs.mkdirSync(path.dirname(this.#directory), { recursive: true })
36
+ fs.mkdirSync(this.#directory, { recursive: true })
36
37
  }
37
38
 
38
39
  start = () => {
@@ -165,13 +166,13 @@ class SassStats {
165
166
  hours > 2 ? ['🔥', '😭', '😱'] : hours >= 1 ? ['🔥', '😱'] : minutes > 10 ? ['⏱️', '😬'] : ['⏱️']
166
167
 
167
168
  let cta =
168
- `Share your pain in Slack #sass-to-css, and help fix that! 🎉\n` +
169
+ `Share your high score in Slack #sass-to-css 🎉 And help us improve that:\n` +
169
170
  `https://origami.ft.com/blog/2024/01/24/sass-build-times/\n\n`
170
171
 
171
172
  if (!this.#monitorRemotely) {
172
173
  cta =
173
174
  `Help us improve build times by setting the "FT_SASS_STATS_MONITOR" environment variable.\n` +
174
- `https://github.com/Financial-Times/biz-ops-metrics-api/blob/main/docs/API_DEFINITION.md#sass-build-monitoring \n\n`
175
+ `https://origami.ft.com/blog/2024/01/24/sass-build-times/ \n\n`
175
176
  }
176
177
 
177
178
  // eslint-disable-next-line no-console
@@ -202,9 +203,13 @@ const forgivingProxy = (target, task) => {
202
203
 
203
204
  const stats = new SassStats()
204
205
  const monitoredSassLoaderProxy = forgivingProxy(sassLoader, (target, sassLoaderThis, argumentsList) => {
206
+ stats.buildCount++
205
207
  // Start the timer, sass-loader has been called with Sass content.
206
208
  // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L19
207
- stats.start()
209
+ if (stats.buildCount === 1) {
210
+ stats.start()
211
+ }
212
+
208
213
  // Assign our proxy to sass-loaders async function.
209
214
  // https://github.com/webpack-contrib/sass-loader/blob/03773152760434a2dd845008c504a09c0eb3fd91/src/index.js#L29
210
215
  const sassLoaderAsyncProxy = forgivingProxy(sassLoaderThis.async, (target, thisArg, argumentsList) => {
@@ -215,9 +220,12 @@ const monitoredSassLoaderProxy = forgivingProxy(sassLoader, (target, sassLoaderT
215
220
  return forgivingProxy(sassLoaderCallback, (target, thisArg, argumentsList) => {
216
221
  // sass-loader's callback has been... called.
217
222
  // Either we have sass, or the build failed.
218
- stats.end()
219
- stats.reportAccordingToNoticeStrategy()
220
- stats.sendMetric()
223
+ stats.buildCount--
224
+ if (stats.buildCount === 0) {
225
+ stats.end()
226
+ stats.reportAccordingToNoticeStrategy()
227
+ stats.sendMetric()
228
+ }
221
229
  return Reflect.apply(target, thisArg, argumentsList)
222
230
  })
223
231
  })