@jsenv/core 25.3.0 → 25.4.0

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.
Files changed (105) hide show
  1. package/dist/browser_runtime/asset-manifest.json +2 -2
  2. package/dist/browser_runtime/{browser_runtime_91c5a3b8.js → browser_runtime_0e3396a1.js} +15 -16
  3. package/dist/browser_runtime/{browser_runtime_91c5a3b8.js.map → browser_runtime_0e3396a1.js.map} +13 -13
  4. package/dist/build_manifest.js +5 -5
  5. package/dist/compile_proxy/asset-manifest.json +2 -2
  6. package/dist/compile_proxy/compile_proxy.html__inline__20_2334a374.js.map +342 -0
  7. package/dist/compile_proxy/{compile_proxy_8dfaee51.html → compile_proxy_9f737eaf.html} +357 -398
  8. package/dist/redirector/asset-manifest.json +2 -2
  9. package/dist/redirector/redirector.html__inline__12_009c47c7.js.map +348 -0
  10. package/dist/redirector/{redirector_3e9a97b9.html → redirector_96f74871.html} +378 -421
  11. package/dist/toolbar/asset-manifest.json +2 -2
  12. package/dist/toolbar/{toolbar.main_6c1b3d82.js.map → toolbar.main_86335f90.js.map} +82 -115
  13. package/dist/toolbar/{toolbar_361afb84.html → toolbar_d3a918a4.html} +487 -508
  14. package/dist/toolbar_injector/asset-manifest.json +2 -2
  15. package/dist/toolbar_injector/toolbar_injector_978bbd14.js +267 -0
  16. package/dist/toolbar_injector/toolbar_injector_978bbd14.js.map +119 -0
  17. package/package.json +12 -11
  18. package/src/buildProject.js +31 -26
  19. package/src/dev_server.js +76 -87
  20. package/src/execute.js +3 -8
  21. package/src/internal/browser_launcher/{browser_runtime_report.js → browser_runtime_profile.js} +21 -15
  22. package/src/internal/browser_launcher/executeHtmlFile.js +22 -14
  23. package/src/internal/browser_launcher/from_playwright.js +6 -4
  24. package/src/internal/browser_runtime/browser_runtime.js +12 -14
  25. package/src/internal/browser_runtime/createBrowserRuntime.js +7 -6
  26. package/src/internal/browser_utils/fetchAndEvalUsingFetch.js +1 -1
  27. package/src/internal/browser_utils/fetchJson.js +1 -1
  28. package/src/internal/browser_utils/{fetch-browser.js → fetch_browser.js} +0 -2
  29. package/src/internal/building/buildUsingRollup.js +41 -57
  30. package/src/internal/building/rollup_plugin_jsenv.js +28 -8
  31. package/src/internal/compiling/babel_parse_error.js +9 -0
  32. package/src/internal/{babel_plugin_transform_import_meta.js → compiling/babel_plugin_transform_import_meta.js} +58 -9
  33. package/src/internal/compiling/compileFile.js +2 -2
  34. package/src/internal/compiling/compileHtml.js +1 -1
  35. package/src/internal/compiling/createCompiledFileService.js +25 -74
  36. package/src/internal/compiling/js-compilation-service/transformJs.js +153 -23
  37. package/src/internal/compiling/jsenvCompilerForHtml.js +29 -32
  38. package/src/internal/compiling/jsenvCompilerForImportmap.js +2 -2
  39. package/src/internal/compiling/jsenvCompilerForJavaScript.js +2 -4
  40. package/src/internal/compiling/jsenv_directory/comparison_utils.js +24 -0
  41. package/src/internal/compiling/{compile-directory/compile-asset.js → jsenv_directory/compile_asset.js} +0 -0
  42. package/src/internal/compiling/jsenv_directory/compile_context.js +68 -0
  43. package/src/internal/compiling/jsenv_directory/compile_profile.js +218 -0
  44. package/src/internal/compiling/{compile-directory/createLockRegistry.js → jsenv_directory/file_lock_registry.js} +0 -0
  45. package/src/internal/compiling/{compile-directory/createLockRegistry.test.js → jsenv_directory/file_lock_registry.test.js} +2 -1
  46. package/src/internal/compiling/{compile-directory → jsenv_directory}/fs-optimized-for-cache.js +0 -0
  47. package/src/internal/compiling/{compile-directory → jsenv_directory}/getOrGenerateCompiledFile.js +2 -2
  48. package/src/internal/compiling/jsenv_directory/jsenv_directory.js +174 -0
  49. package/src/internal/compiling/{compile-directory → jsenv_directory}/updateMeta.js +1 -1
  50. package/src/internal/compiling/{compile-directory → jsenv_directory}/validateCache.js +0 -0
  51. package/src/internal/compiling/sse_service/sse_service.js +369 -0
  52. package/src/internal/compiling/startCompileServer.js +156 -804
  53. package/src/internal/compiling/transformResultToCompilationResult.js +2 -2
  54. package/src/internal/dev_server/exploring/exploring.js +10 -8
  55. package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +85 -78
  56. package/src/internal/dev_server/toolbar/settings/toolbar.settings.js +13 -0
  57. package/src/internal/dev_server/toolbar/toolbar.html +40 -16
  58. package/src/internal/dev_server/toolbar/toolbar.injector.js +11 -17
  59. package/src/internal/dev_server/toolbar/toolbar.main.js +6 -6
  60. package/src/internal/executing/executeConcurrently.js +1 -1
  61. package/src/internal/executing/executePlan.js +2 -3
  62. package/src/internal/{generateGroupMap → features}/babel_plugins_compatibility.js +8 -8
  63. package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +20 -0
  64. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +23 -0
  65. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +25 -0
  66. package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +37 -0
  67. package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +9 -0
  68. package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +14 -0
  69. package/src/internal/features/browser_feature_detection/browser_feature_detection.js +85 -0
  70. package/src/internal/{browser_feature_detection → features/browser_feature_detection}/compile_proxy.html +1 -1
  71. package/src/internal/features/browser_feature_detection/execute_with_script_module.js +24 -0
  72. package/src/internal/features/features_compat_from_runtime.js +38 -0
  73. package/src/internal/features/features_compat_from_runtime_support.js +31 -0
  74. package/src/internal/{generateGroupMap → features}/features_compatibility.js +3 -3
  75. package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_dynamic_import.mjs +0 -0
  76. package/src/internal/{node_feature_detection → features/node_feature_detection}/feature_detect_top_level_await.mjs +0 -0
  77. package/src/internal/{node_feature_detection/nodeSupportsDynamicImport.js → features/node_feature_detection/node_feature_detect_dynamic_import.js} +0 -0
  78. package/src/internal/{node_feature_detection/nodeSupportsTopLevelAwait.js → features/node_feature_detection/node_feature_detect_top_level_await.js} +0 -0
  79. package/src/internal/features/node_feature_detection/node_feature_detection.js +66 -0
  80. package/src/internal/node_launcher/createControllableNodeProcess.js +4 -3
  81. package/src/internal/node_launcher/node_runtime_report.js +15 -9
  82. package/src/internal/node_runtime/fetchSource.js +2 -4
  83. package/src/internal/node_runtime/node_execution_systemjs.js +2 -5
  84. package/src/internal/{dev_server/redirector → redirector}/redirector.html +8 -18
  85. package/src/internal/{generateGroupMap/jsenvRuntimeSupport.js → runtime_support/jsenv_runtime_support.js} +0 -0
  86. package/src/internal/{generateGroupMap → runtime_support}/runtime_support.js +0 -0
  87. package/src/internal/url_conversion.js +12 -17
  88. package/src/launchNode.js +29 -41
  89. package/dist/compile_proxy/compile_proxy.html__inline__20_809f35f7.js.map +0 -392
  90. package/dist/redirector/redirector.html__inline__15_e391410e.js.map +0 -397
  91. package/dist/toolbar_injector/toolbar_injector_fac1e995.js +0 -973
  92. package/dist/toolbar_injector/toolbar_injector_fac1e995.js.map +0 -294
  93. package/src/internal/CONSTANTS.js +0 -11
  94. package/src/internal/browser_feature_detection/browser_feature_detection.js +0 -274
  95. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +0 -242
  96. package/src/internal/generateGroupMap/generateGroupMap.js +0 -65
  97. package/src/internal/generateGroupMap/one_runtime_compat.js +0 -38
  98. package/src/internal/generateGroupMap/runtime_compat.js +0 -34
  99. package/src/internal/generateGroupMap/runtime_compat_composition.js +0 -76
  100. package/src/internal/generateGroupMap/shake_babel_plugin_map.js +0 -21
  101. package/src/internal/node_feature_detection/node_feature_detection.js +0 -117
  102. package/src/internal/node_runtime/detectNode.js +0 -3
  103. package/src/internal/runtime/computeCompileIdFromGroupId.js +0 -30
  104. package/src/internal/runtime/resolveGroup.js +0 -13
  105. package/src/internal/runtime/resolveRuntimeGroup.js +0 -11
@@ -0,0 +1,218 @@
1
+ import { featuresCompatFromRuntime } from "@jsenv/core/src/internal/features/features_compat_from_runtime.js"
2
+ import { featuresCompatFromRuntimeSupport } from "@jsenv/core/src/internal/features/features_compat_from_runtime_support.js"
3
+
4
+ import { sameValueInTwoObjects } from "./comparison_utils.js"
5
+
6
+ const COMPARERS = {
7
+ missingFeatures: sameValueInTwoObjects,
8
+ preservedUrls: sameValueInTwoObjects,
9
+ moduleOutFormat: (a, b) => a === b,
10
+ sourcemapMethod: (a, b) => a === b,
11
+ sourcemapExcludeSources: (a, b) => a === b,
12
+ jsenvEventSourceClientInjection: (a, b) => a === b,
13
+ jsenvToolbarInjection: (a, b) => a === b,
14
+ }
15
+
16
+ export const createCompileProfile = ({
17
+ importDefaultExtension,
18
+ preservedUrls,
19
+ customCompilers,
20
+ babelPluginMapWithoutSyntax,
21
+ workerUrls,
22
+ importMapInWebWorkers,
23
+ moduleOutFormat,
24
+ sourcemapMethod,
25
+ sourcemapExcludeSources,
26
+ jsenvEventSourceClientInjection,
27
+ jsenvToolbarInjection,
28
+
29
+ runtimeReport,
30
+ }) => {
31
+ const { env = {} } = runtimeReport
32
+
33
+ const features = {}
34
+ if (importDefaultExtension) {
35
+ features["import_default_extension"] = true
36
+ }
37
+ const customCompilerPatterns = Object.keys(customCompilers)
38
+ if (customCompilerPatterns.length > 0) {
39
+ features["custom_compiler_patterns"] = customCompilerPatterns
40
+ }
41
+ Object.keys(babelPluginMapWithoutSyntax).forEach((babelPluginName) => {
42
+ // if we need to be compatible only with node
43
+ // ignore "new-stylesheet-as-jsenv-import" and "transform-import-assertions"
44
+ // (we consider they won't be used in the code we are about to execute)
45
+ if (env.node && !env.browser) {
46
+ if (
47
+ babelPluginName === "new-stylesheet-as-jsenv-import" ||
48
+ babelPluginName === "transform-import-assertions"
49
+ ) {
50
+ return
51
+ }
52
+ }
53
+ features[babelPluginName] = babelPluginValueAsJSON(
54
+ babelPluginMapWithoutSyntax[babelPluginName],
55
+ )
56
+ })
57
+
58
+ if (env.browser) {
59
+ Object.assign(features, {
60
+ script_type_module: true,
61
+ import_dynamic: true,
62
+ top_level_await: true,
63
+ importmap: true,
64
+ import_assertion_type_json: true,
65
+ import_assertion_type_css: true,
66
+ })
67
+ }
68
+ if (env.browser && workerUrls.length > 0) {
69
+ features["worker_type_module"] = true
70
+ }
71
+ if (env.browser && importMapInWebWorkers) {
72
+ features["worker_importmap"] = true
73
+ }
74
+ const featureNames = Object.keys(features)
75
+
76
+ const supportedFeatureNames = []
77
+ const { featuresReport = {} } = runtimeReport
78
+ Object.keys(featuresReport).forEach((featureName) => {
79
+ if (featuresReport[featureName]) {
80
+ supportedFeatureNames.push(featureName)
81
+ }
82
+ })
83
+ const { name, version } = runtimeReport
84
+ if (name && version) {
85
+ const { availableFeatureNames } = featuresCompatFromRuntime({
86
+ runtimeName: name,
87
+ runtimeVersion: version,
88
+ featureNames,
89
+ })
90
+ availableFeatureNames.forEach((featureName) => {
91
+ const runtimeReportResult = featuresReport[featureName]
92
+ if (runtimeReportResult === undefined) {
93
+ supportedFeatureNames.push(featureName)
94
+ }
95
+ })
96
+ }
97
+ const { runtimeSupport } = runtimeReport
98
+ if (runtimeSupport) {
99
+ const { availableFeatureNames } = featuresCompatFromRuntimeSupport({
100
+ runtimeSupport,
101
+ featureNames,
102
+ })
103
+ availableFeatureNames.forEach((featureName) => {
104
+ const runtimeReportResult = featuresReport[featureName]
105
+ if (runtimeReportResult === undefined) {
106
+ supportedFeatureNames.push(featureName)
107
+ }
108
+ })
109
+ }
110
+ Object.keys(featureEffects).forEach((featureName) => {
111
+ if (featuresReport[featureName]) {
112
+ featureEffects[featureName]({
113
+ supportedFeatureNames,
114
+ })
115
+ }
116
+ })
117
+
118
+ const missingFeatures = {}
119
+ if (!runtimeReport.forceSource) {
120
+ featureNames.forEach((featureName) => {
121
+ const supported = supportedFeatureNames.includes(featureName)
122
+ if (supported) {
123
+ return
124
+ }
125
+ missingFeatures[featureName] = features[featureName]
126
+ })
127
+ if (moduleOutFormat === undefined) {
128
+ if (runtimeReport.moduleOutFormat) {
129
+ moduleOutFormat = runtimeReport.moduleOutFormat
130
+ if (moduleOutFormat !== "esmodule") {
131
+ missingFeatures["module_format"] = moduleOutFormat
132
+ }
133
+ } else {
134
+ const systemJsIsRequired =
135
+ featuresRelatedToSystemJs.some((featureName) => {
136
+ return Boolean(missingFeatures[featureName])
137
+ }) || !featuresReport["import_http"]
138
+ moduleOutFormat = systemJsIsRequired ? "systemjs" : "esmodule"
139
+ }
140
+ }
141
+ if (runtimeReport.forceCompilation) {
142
+ missingFeatures["compilation_forced"] = true
143
+ }
144
+ }
145
+ return {
146
+ missingFeatures,
147
+ preservedUrls,
148
+ moduleOutFormat,
149
+ sourcemapMethod,
150
+ sourcemapExcludeSources,
151
+ jsenvEventSourceClientInjection,
152
+ jsenvToolbarInjection,
153
+ }
154
+ }
155
+
156
+ const featuresRelatedToSystemJs = [
157
+ "script_type_module",
158
+ "import_dynamic",
159
+ "top_level_await",
160
+ "importmap",
161
+ "import_assertion_type_json",
162
+ "import_assertion_type_css",
163
+ "worker_type_module",
164
+ "worker_importmap",
165
+ ]
166
+
167
+ const featureEffects = {
168
+ coverage_js: ({ supportedFeatureNames }) => {
169
+ supportedFeatureNames.push("transform-instrument")
170
+ },
171
+ new_stylesheet: ({ supportedFeatureNames }) => {
172
+ supportedFeatureNames.push("new-stylesheet-as-jsenv-import")
173
+ },
174
+ }
175
+
176
+ export const compareCompileProfiles = (
177
+ compileProfile,
178
+ secondCompileProfile,
179
+ ) => {
180
+ return Object.keys(COMPARERS).every((key) => {
181
+ return COMPARERS[key](compileProfile[key], secondCompileProfile[key])
182
+ })
183
+ }
184
+
185
+ export const shakeBabelPluginMap = ({ babelPluginMap, compileProfile }) => {
186
+ const babelPluginMapShaked = {}
187
+ const { missingFeatures } = compileProfile
188
+ Object.keys(babelPluginMap).forEach((babelPluginName) => {
189
+ if (missingFeatures[babelPluginName]) {
190
+ babelPluginMapShaked[babelPluginName] = babelPluginMap[babelPluginName]
191
+ }
192
+ })
193
+ Object.keys(babelPluginMap).forEach((key) => {
194
+ if (key.startsWith("syntax-")) {
195
+ babelPluginMapShaked[key] = babelPluginMap[key]
196
+ }
197
+ if (key === "transform-replace-expressions") {
198
+ babelPluginMapShaked[key] = babelPluginMap[key]
199
+ }
200
+ })
201
+ return babelPluginMapShaked
202
+ }
203
+
204
+ const babelPluginValueAsJSON = (babelPluginValue) => {
205
+ if (Array.isArray(babelPluginValue)) {
206
+ if (babelPluginValue.length === 1) {
207
+ return true
208
+ }
209
+ if (babelPluginValue.length === 2) {
210
+ return babelPluginValue[1]
211
+ }
212
+ return true
213
+ }
214
+ if (typeof babelPluginValue === "object") {
215
+ return babelPluginValue.options
216
+ }
217
+ return true
218
+ }
@@ -1,5 +1,6 @@
1
1
  import { assert } from "@jsenv/assert"
2
- import { createLockRegistry } from "./createLockRegistry.js"
2
+
3
+ import { createLockRegistry } from "./file_lock_registry.js"
3
4
 
4
5
  // a second lock on same ressource await first one to be unlocked
5
6
  {
@@ -3,8 +3,8 @@ import { urlToFileSystemPath, readFile } from "@jsenv/filesystem"
3
3
  import { createDetailedMessage } from "@jsenv/logger"
4
4
 
5
5
  import { validateCache } from "./validateCache.js"
6
- import { getMetaJsonFileUrl } from "./compile-asset.js"
7
- import { createLockRegistry } from "./createLockRegistry.js"
6
+ import { getMetaJsonFileUrl } from "./compile_asset.js"
7
+ import { createLockRegistry } from "./file_lock_registry.js"
8
8
 
9
9
  const { lockForRessource } = createLockRegistry()
10
10
 
@@ -0,0 +1,174 @@
1
+ import {
2
+ resolveUrl,
3
+ readFile,
4
+ writeFile,
5
+ ensureEmptyDirectory,
6
+ } from "@jsenv/filesystem"
7
+
8
+ import { compareCompileContexts } from "./compile_context.js"
9
+ import { compareCompileProfiles } from "./compile_profile.js"
10
+
11
+ export const setupJsenvDirectory = async ({
12
+ logger,
13
+ projectDirectoryUrl,
14
+ jsenvDirectoryRelativeUrl,
15
+ jsenvDirectoryClean,
16
+ compileServerCanWriteOnFilesystem,
17
+ compileContext,
18
+ }) => {
19
+ const jsenvDirectoryUrl = resolveUrl(
20
+ jsenvDirectoryRelativeUrl,
21
+ projectDirectoryUrl,
22
+ )
23
+ const jsenvDirectoryMetaFileUrl = resolveUrl(
24
+ "__jsenv_meta__.json",
25
+ jsenvDirectoryUrl,
26
+ )
27
+ const compileDirectories = {}
28
+ const jsenvDirectoryMeta = {
29
+ jsenvDirectoryRelativeUrl,
30
+ compileContext,
31
+ compileDirectories,
32
+ }
33
+
34
+ const writeMetaFile = async () => {
35
+ await writeFile(
36
+ jsenvDirectoryMetaFileUrl,
37
+ JSON.stringify(jsenvDirectoryMeta, null, " "),
38
+ )
39
+ }
40
+
41
+ if (compileServerCanWriteOnFilesystem) {
42
+ if (jsenvDirectoryClean) {
43
+ await ensureEmptyDirectory(jsenvDirectoryUrl)
44
+ }
45
+ await applyFileSystemEffects({
46
+ logger,
47
+ jsenvDirectoryUrl,
48
+ jsenvDirectoryMetaFileUrl,
49
+ writeMetaFile,
50
+ jsenvDirectoryMeta,
51
+ })
52
+ }
53
+
54
+ /*
55
+ * This function try to reuse existing compiled id
56
+ * (the goal being to reuse file that would be in a corresponding compile directory)
57
+ * To decide if we reuse a compile directory we need to know
58
+ * how the files inside that directory where generated
59
+ * and if what we want matches what we have, the compile id is reused
60
+ *
61
+ * Note: some parameters means only a subset of files would be invalid
62
+ * but to keep things simple the whole directory is ignored
63
+ */
64
+ const getOrCreateCompileId = async ({
65
+ runtimeName,
66
+ runtimeVersion,
67
+ compileProfile,
68
+ }) => {
69
+ const missingFeatureNames = Object.keys(compileProfile.missingFeatures)
70
+ if (missingFeatureNames.length === 0) {
71
+ return null
72
+ }
73
+ const existingCompileIds = Object.keys(compileDirectories)
74
+ const existingCompileId = existingCompileIds.find((compileIdCandidate) => {
75
+ const compileDirectoryCandidate = compileDirectories[compileIdCandidate]
76
+ return compareCompileProfiles(
77
+ compileDirectoryCandidate.compileProfile,
78
+ compileProfile,
79
+ )
80
+ })
81
+ const runtime = `${runtimeName}@${runtimeVersion}`
82
+ if (existingCompileId) {
83
+ const compileDirectory = compileDirectories[existingCompileId]
84
+ const { runtimes } = compileDirectory
85
+ if (!runtimes.includes(runtime)) {
86
+ runtimes.push(runtime)
87
+ await writeMetaFile()
88
+ }
89
+ return existingCompileId
90
+ }
91
+ const compileIdBase = generateCompileId({ compileProfile })
92
+ let compileId = compileIdBase
93
+ let integer = 1
94
+ while (existingCompileIds.includes(compileId)) {
95
+ compileId = `${compileIdBase}_${integer}`
96
+ integer++
97
+ }
98
+ compileDirectories[compileId] = {
99
+ compileProfile,
100
+ runtimes: [runtime],
101
+ }
102
+ await writeMetaFile()
103
+ return compileId
104
+ }
105
+
106
+ return {
107
+ compileDirectories,
108
+ getOrCreateCompileId,
109
+ }
110
+ }
111
+
112
+ const generateCompileId = ({ compileProfile }) => {
113
+ if (compileProfile.missingFeatures["transform-instrument"]) {
114
+ return `out_instrumented`
115
+ }
116
+ return `out`
117
+ }
118
+
119
+ const applyFileSystemEffects = async ({
120
+ logger,
121
+ jsenvDirectoryUrl,
122
+ jsenvDirectoryMetaFileUrl,
123
+ jsenvDirectoryMeta,
124
+ writeMetaFile,
125
+ }) => {
126
+ try {
127
+ const source = await readFile(jsenvDirectoryMetaFileUrl)
128
+ if (source === "") {
129
+ logger.warn(
130
+ `${jsenvDirectoryMetaFileUrl} is empty -> clean ${jsenvDirectoryUrl} directory`,
131
+ )
132
+ await ensureEmptyDirectory(jsenvDirectoryUrl)
133
+ await writeMetaFile()
134
+ return
135
+ }
136
+ const jsenvDirectoryMetaPrevious = JSON.parse(source)
137
+ if (
138
+ !compareCompileContexts(
139
+ jsenvDirectoryMetaPrevious.compileContext,
140
+ jsenvDirectoryMeta.compileContext,
141
+ )
142
+ ) {
143
+ logger.debug(
144
+ `compile context has changed -> clean ${jsenvDirectoryUrl} directory`,
145
+ )
146
+ await ensureEmptyDirectory(jsenvDirectoryUrl)
147
+ await writeMetaFile()
148
+ return
149
+ }
150
+ // reuse existing compile directories
151
+ Object.assign(
152
+ jsenvDirectoryMeta.compileDirectories,
153
+ jsenvDirectoryMetaPrevious.compileDirectories,
154
+ )
155
+ } catch (e) {
156
+ if (e.code === "ENOENT") {
157
+ logger.debug(
158
+ `${jsenvDirectoryMetaFileUrl} not found -> clean ${jsenvDirectoryUrl} directory`,
159
+ )
160
+ await ensureEmptyDirectory(jsenvDirectoryUrl)
161
+ await writeMetaFile()
162
+ return
163
+ }
164
+ if (e.name === "SyntaxError") {
165
+ logger.warn(
166
+ `${jsenvDirectoryMetaFileUrl} syntax error -> clean ${jsenvDirectoryUrl} directory`,
167
+ )
168
+ await ensureEmptyDirectory(jsenvDirectoryUrl)
169
+ await writeMetaFile()
170
+ return
171
+ }
172
+ throw e
173
+ }
174
+ }
@@ -6,7 +6,7 @@ import {
6
6
  import { utimesSync } from "node:fs"
7
7
 
8
8
  import { writeFileContent, testFilePresence } from "./fs-optimized-for-cache.js"
9
- import { getMetaJsonFileUrl } from "./compile-asset.js"
9
+ import { getMetaJsonFileUrl } from "./compile_asset.js"
10
10
 
11
11
  export const updateMeta = async ({
12
12
  logger,