@jsenv/core 27.0.0-alpha.28 → 27.0.0-alpha.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.0.0-alpha.28",
3
+ "version": "27.0.0-alpha.30",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -91,7 +91,6 @@
91
91
  "@jsenv/assert": "2.5.4",
92
92
  "@jsenv/eslint-config": "16.0.9",
93
93
  "@jsenv/file-size-impact": "12.1.11",
94
- "@jsenv/github-release-package": "1.4.0",
95
94
  "@jsenv/https-local": "1.0.8",
96
95
  "@jsenv/importmap-node-module": "5.1.3",
97
96
  "@jsenv/package-workspace": "0.0.5",
@@ -22,6 +22,7 @@ import {
22
22
  fetchFileSystem,
23
23
  } from "@jsenv/server"
24
24
  import { createLogger } from "@jsenv/logger"
25
+ import { Abort } from "@jsenv/abort"
25
26
 
26
27
  import { initProcessAutorestart } from "@jsenv/utils/file_watcher/process_auto_restart.js"
27
28
  import { createTaskLog } from "@jsenv/utils/logs/task_log.js"
@@ -79,13 +80,17 @@ export const startBuildServer = async ({
79
80
  const logger = createLogger({ logLevel })
80
81
 
81
82
  let buildPromise
82
- let abortController
83
+ let buildAbortController
83
84
  const runBuild = async () => {
85
+ buildAbortController = new AbortController()
86
+ const buildOperation = Abort.startOperation()
87
+ buildOperation.addAbortSignal(signal)
88
+ buildOperation.addAbortSignal(buildAbortController.signal)
84
89
  const buildTask = createTaskLog(logger, `execute build command`)
85
90
  buildPromise = executeCommand(buildCommand, {
86
91
  cwd: rootDirectoryUrl,
87
92
  logLevel: buildCommandLogLevel,
88
- signal,
93
+ signal: buildOperation.signal,
89
94
  })
90
95
  try {
91
96
  await buildPromise
@@ -173,7 +178,7 @@ export const startBuildServer = async ({
173
178
  watchedFilePatterns,
174
179
  cooldownBetweenFileEvents,
175
180
  fileChangeCallback: ({ url, event }) => {
176
- abortController.abort()
181
+ buildAbortController.abort()
177
182
  // setTimeout is to ensure the abortController.abort() above
178
183
  // is properly taken into account so that logs about abort comes first
179
184
  // then logs about re-running the build happens
@@ -191,8 +191,8 @@ export const createRuntimeFromPlaywright = ({
191
191
  navigation: performance.navigation.toJSON(),
192
192
  measures,
193
193
  }
194
- /* eslint-enable no-undef */
195
194
  },
195
+ /* eslint-enable no-undef */
196
196
  )
197
197
  result.performance = performance
198
198
  return result
@@ -1,9 +1,3 @@
1
- /*
2
- * TODO:
3
- * - code should also inject helper when code uses new keyword on "CSSStyleSheet"
4
- * - code should also inject helper when code uses "document.adoptedStylesheets"
5
- */
6
-
7
1
  import { pathToFileURL } from "node:url"
8
2
 
9
3
  import { injectImport } from "@jsenv/utils/js_ast/babel_utils.js"
@@ -27,6 +21,18 @@ export const babelPluginNewStylesheetAsJsenvImport = (
27
21
  }
28
22
  let usesNewStylesheet = false
29
23
  programPath.traverse({
24
+ NewExpression: (path) => {
25
+ usesNewStylesheet = isNewCssStyleSheetCall(path.node)
26
+ if (usesNewStylesheet) {
27
+ path.stop()
28
+ }
29
+ },
30
+ MemberExpression: (path) => {
31
+ usesNewStylesheet = isDocumentAdoptedStyleSheets(path.node)
32
+ if (usesNewStylesheet) {
33
+ path.stop()
34
+ }
35
+ },
30
36
  CallExpression: (path) => {
31
37
  if (path.node.callee.type !== "Import") {
32
38
  // Some other function call, not import();
@@ -90,6 +96,25 @@ export const babelPluginNewStylesheetAsJsenvImport = (
90
96
  }
91
97
  }
92
98
 
99
+ const isNewCssStyleSheetCall = (node) => {
100
+ return (
101
+ node.type === "NewExpression" &&
102
+ node.callee.type === "Identifier" &&
103
+ node.callee.name === "CSSStyleSheet"
104
+ )
105
+ }
106
+
107
+ const isDocumentAdoptedStyleSheets = (node) => {
108
+ const callee = node.callee
109
+ return (
110
+ callee.type === "MemberExpression" &&
111
+ callee.object.type === "Identifier" &&
112
+ callee.object.name === "document" &&
113
+ callee.property.type === "Identifier" &&
114
+ callee.property.name === "adoptedStyleSheets"
115
+ )
116
+ }
117
+
93
118
  const hasCssModuleQueryParam = (path) => {
94
119
  const { node } = path
95
120
  return (