@jsenv/core 27.3.2 → 27.3.3

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.
@@ -125,7 +125,6 @@ const rollupPluginJsenv = ({
125
125
  usesImport:
126
126
  rollupFileInfo.imports.length > 0 ||
127
127
  rollupFileInfo.dynamicImports.length > 0,
128
- usesExport: rollupFileInfo.exports.length > 0,
129
128
  },
130
129
  contentType: "text/javascript",
131
130
  content: rollupFileInfo.code,
@@ -56,8 +56,7 @@ export const jsenvPluginNodeEsmResolution = ({
56
56
  const onFileChange = () => {
57
57
  packageScopesCache.clear()
58
58
  packageJsonsCache.clear()
59
- Object.keys(urlGraph.urlInfos).forEach((url) => {
60
- const urlInfo = urlGraph.getUrlInfo(url)
59
+ urlGraph.urlInfoMap.forEach((urlInfo) => {
61
60
  if (urlInfo.dependsOnPackageJson) {
62
61
  urlGraph.considerModified(urlInfo)
63
62
  }
@@ -13,22 +13,13 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
13
13
  const { rootDirectoryUrl, referenceUtils } = context
14
14
  const actions = []
15
15
  const magicSource = createMagicSource(urlInfo.content)
16
- urlInfo.data.usesImport = false
17
- urlInfo.data.usesExport = false
18
- urlInfo.data.usesImportAssertion = false
19
16
  jsMentions.forEach((jsMention) => {
20
- if (jsMention.assert) {
21
- urlInfo.data.usesImportAssertion = true
22
- }
23
17
  if (
24
18
  jsMention.subtype === "import_static" ||
25
19
  jsMention.subtype === "import_dynamic"
26
20
  ) {
27
21
  urlInfo.data.usesImport = true
28
22
  }
29
- if (jsMention.subtype === "export") {
30
- urlInfo.data.usesExport = true
31
- }
32
23
  const [reference] = referenceUtils.found({
33
24
  type: jsMention.type,
34
25
  subtype: jsMention.subtype,
@@ -50,7 +50,7 @@ export const reportToCoverage = async (
50
50
  coverageMethodForNodeJs !== "NODE_V8_COVERAGE"
51
51
  ) {
52
52
  logger.warn(
53
- `No "coverageFileUrl" from execution named "${executionName}" of ${file}`,
53
+ `"${executionName}" execution of ${file} did not properly write coverage into ${executionResult.coverageFileUrl}`,
54
54
  )
55
55
  }
56
56
  },
@@ -152,18 +152,23 @@ const getCoverageFromReport = async ({ signal, report, onMissing }) => {
152
152
  const executionResultForFileOnRuntime =
153
153
  executionResultForFile[executionName]
154
154
  const { coverageFileUrl } = executionResultForFileOnRuntime
155
- if (!coverageFileUrl) {
156
- onMissing({
157
- executionName,
158
- file,
159
- executionResult: executionResultForFileOnRuntime,
160
- })
161
- return
155
+ let executionCoverage
156
+ try {
157
+ executionCoverage = JSON.parse(
158
+ String(readFileSync(new URL(coverageFileUrl))),
159
+ )
160
+ } catch (e) {
161
+ if (e.code === "ENOENT" || e.name === "SyntaxError") {
162
+ onMissing({
163
+ executionName,
164
+ file,
165
+ executionResult: executionResultForFileOnRuntime,
166
+ })
167
+ return
168
+ }
169
+ throw e
162
170
  }
163
171
 
164
- const executionCoverage = JSON.parse(
165
- String(readFileSync(new URL(coverageFileUrl))),
166
- )
167
172
  if (isV8Coverage(executionCoverage)) {
168
173
  v8Coverage = v8Coverage
169
174
  ? composeTwoV8Coverages(v8Coverage, executionCoverage)
@@ -143,7 +143,7 @@ export const executePlan = async (
143
143
  createDetailedMessage(
144
144
  `process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`,
145
145
  {
146
- "suggestion": `Preprend NODE_V8_COVERAGE=.coverage/node to the command executing this process`,
146
+ "suggestion": `set process.env.NODE_V8_COVERAGE`,
147
147
  "suggestion 2": `use coverageMethodForNodeJs: "Profiler". But it means coverage for child_process and worker_thread cannot be collected`,
148
148
  },
149
149
  ),
@@ -224,7 +224,8 @@ export const executePlan = async (
224
224
  getCustomBabelPlugins: ({ clientRuntimeCompat }) => {
225
225
  if (
226
226
  coverageEnabled &&
227
- Object.keys(clientRuntimeCompat)[0] !== "chrome"
227
+ (coverageMethodForBrowsers !== "playwright_api" ||
228
+ Object.keys(clientRuntimeCompat)[0] !== "chrome")
228
229
  ) {
229
230
  return {
230
231
  "transform-instrument": [
@@ -67,7 +67,9 @@ export const executeTestPlan = async ({
67
67
  },
68
68
  coverageIncludeMissing = true,
69
69
  coverageAndExecutionAllowed = false,
70
- coverageMethodForNodeJs = "NODE_V8_COVERAGE", // "Profiler" also accepted
70
+ coverageMethodForNodeJs = process.env.NODE_V8_COVERAGE
71
+ ? "NODE_V8_COVERAGE"
72
+ : "Profiler",
71
73
  coverageMethodForBrowsers = "playwright_api", // "istanbul" also accepted
72
74
  coverageV8ConflictWarning = true,
73
75
  coverageTempDirectoryRelativeUrl = "./.coverage/tmp/",