@jsenv/core 23.6.0 → 23.7.1

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 (120) hide show
  1. package/{license → LICENSE} +21 -21
  2. package/dist/jsenv_browser_system.js +35 -35
  3. package/dist/jsenv_browser_system.js.map +14 -14
  4. package/dist/jsenv_compile_proxy.js +47 -128
  5. package/dist/jsenv_compile_proxy.js.map +25 -62
  6. package/dist/jsenv_exploring_index.js.map +5 -5
  7. package/dist/jsenv_exploring_redirector.js +47 -54
  8. package/dist/jsenv_exploring_redirector.js.map +17 -19
  9. package/dist/jsenv_toolbar.js +47 -128
  10. package/dist/jsenv_toolbar.js.map +12 -47
  11. package/dist/jsenv_toolbar_injector.js.map +5 -5
  12. package/helpers/babel/.eslintrc.cjs +24 -24
  13. package/helpers/babel/AsyncGenerator/AsyncGenerator.js +81 -81
  14. package/helpers/babel/AwaitValue/AwaitValue.js +3 -3
  15. package/helpers/babel/applyDecoratorDescriptor/applyDecoratorDescriptor.js +33 -33
  16. package/helpers/babel/arrayLikeToArray/arrayLikeToArray.js +7 -7
  17. package/helpers/babel/arrayWithHoles/arrayWithHoles.js +4 -4
  18. package/helpers/babel/arrayWithoutHoles/arrayWithoutHoles.js +6 -6
  19. package/helpers/babel/assertThisInitialized/assertThisInitialized.js +7 -7
  20. package/helpers/babel/asyncGeneratorDelegate/asyncGeneratorDelegate.js +40 -40
  21. package/helpers/babel/asyncIterator/asyncIterator.js +12 -12
  22. package/helpers/babel/asyncToGenerator/asyncToGenerator.js +34 -34
  23. package/helpers/babel/awaitAsyncGenerator/awaitAsyncGenerator.js +5 -5
  24. package/helpers/babel/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +20 -20
  25. package/helpers/babel/classApplyDescriptorGet/classApplyDescriptorGet.js +6 -6
  26. package/helpers/babel/classApplyDescriptorSet/classApplyDescriptorSet.js +13 -13
  27. package/helpers/babel/classCallCheck/classCallCheck.js +5 -5
  28. package/helpers/babel/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -5
  29. package/helpers/babel/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -6
  30. package/helpers/babel/classExtractFieldDescriptor/classExtractFieldDescriptor.js +7 -7
  31. package/helpers/babel/classNameTDZError/classNameTDZError.js +4 -4
  32. package/helpers/babel/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +7 -7
  33. package/helpers/babel/classPrivateFieldGet/classPrivateFieldGet.js +7 -7
  34. package/helpers/babel/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +6 -6
  35. package/helpers/babel/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -5
  36. package/helpers/babel/classPrivateFieldSet/classPrivateFieldSet.js +8 -8
  37. package/helpers/babel/classPrivateMethodGet/classPrivateMethodGet.js +6 -6
  38. package/helpers/babel/classPrivateMethodSet/classPrivateMethodSet.js +3 -3
  39. package/helpers/babel/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +9 -9
  40. package/helpers/babel/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +15 -15
  41. package/helpers/babel/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +6 -6
  42. package/helpers/babel/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -3
  43. package/helpers/babel/construct/construct.js +16 -16
  44. package/helpers/babel/createClass/createClass.js +15 -15
  45. package/helpers/babel/createForOfIteratorHelper/createForOfIteratorHelper.js +60 -60
  46. package/helpers/babel/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +23 -23
  47. package/helpers/babel/createRawReactElement/createRawReactElement.js +50 -50
  48. package/helpers/babel/createSuper/createSuper.js +22 -22
  49. package/helpers/babel/decorate/decorate.js +403 -403
  50. package/helpers/babel/defaults/defaults.js +11 -11
  51. package/helpers/babel/defineEnumerableProperties/defineEnumerableProperties.js +23 -23
  52. package/helpers/babel/defineProperty/defineProperty.js +18 -18
  53. package/helpers/babel/extends/extends.js +14 -14
  54. package/helpers/babel/get/get.js +13 -13
  55. package/helpers/babel/getPrototypeOf/getPrototypeOf.js +4 -4
  56. package/helpers/babel/inherits/inherits.js +15 -15
  57. package/helpers/babel/inheritsLoose/inheritsLoose.js +7 -7
  58. package/helpers/babel/initializerDefineProperty/initializerDefineProperty.js +10 -10
  59. package/helpers/babel/initializerWarningHelper/initializerWarningHelper.js +6 -6
  60. package/helpers/babel/instanceof/instanceof.js +6 -6
  61. package/helpers/babel/interopRequireDefault/interopRequireDefault.js +3 -3
  62. package/helpers/babel/interopRequireWildcard/interopRequireWildcard.js +37 -37
  63. package/helpers/babel/isNativeFunction/isNativeFunction.js +4 -4
  64. package/helpers/babel/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -21
  65. package/helpers/babel/iterableToArray/iterableToArray.js +7 -7
  66. package/helpers/babel/iterableToArrayLimit/iterableToArrayLimit.js +36 -36
  67. package/helpers/babel/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +10 -10
  68. package/helpers/babel/jsx/jsx.js +45 -45
  69. package/helpers/babel/maybeArrayLike/maybeArrayLike.js +10 -10
  70. package/helpers/babel/newArrowCheck/newArrowCheck.js +5 -5
  71. package/helpers/babel/nonIterableRest/nonIterableRest.js +5 -5
  72. package/helpers/babel/nonIterableSpread/nonIterableSpread.js +5 -5
  73. package/helpers/babel/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -3
  74. package/helpers/babel/objectSpread/objectSpread.js +23 -23
  75. package/helpers/babel/objectSpread2/objectSpread2.js +33 -33
  76. package/helpers/babel/objectWithoutProperties/objectWithoutProperties.js +19 -19
  77. package/helpers/babel/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +13 -13
  78. package/helpers/babel/possibleConstructorReturn/possibleConstructorReturn.js +10 -10
  79. package/helpers/babel/readOnlyError/readOnlyError.js +4 -4
  80. package/helpers/babel/readme.md +9 -9
  81. package/helpers/babel/set/set.js +44 -44
  82. package/helpers/babel/setPrototypeOf/setPrototypeOf.js +6 -6
  83. package/helpers/babel/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -8
  84. package/helpers/babel/slicedToArray/slicedToArray.js +10 -10
  85. package/helpers/babel/slicedToArrayLoose/slicedToArrayLoose.js +13 -13
  86. package/helpers/babel/superPropBase/superPropBase.js +10 -10
  87. package/helpers/babel/taggedTemplateLiteral/taggedTemplateLiteral.js +10 -10
  88. package/helpers/babel/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +7 -7
  89. package/helpers/babel/tdz/tdz.js +4 -4
  90. package/helpers/babel/temporalRef/temporalRef.js +6 -6
  91. package/helpers/babel/temporalUndefined/temporalUndefined.js +3 -3
  92. package/helpers/babel/toArray/toArray.js +10 -10
  93. package/helpers/babel/toConsumableArray/toConsumableArray.js +10 -10
  94. package/helpers/babel/toPrimitive/toPrimitive.js +10 -10
  95. package/helpers/babel/toPropertyKey/toPropertyKey.js +6 -6
  96. package/helpers/babel/typeof/typeof.js +14 -14
  97. package/helpers/babel/unsupportedIterableToArray/unsupportedIterableToArray.js +12 -12
  98. package/helpers/babel/wrapAsyncGenerator/wrapAsyncGenerator.js +8 -8
  99. package/helpers/babel/wrapNativeSuper/wrapNativeSuper.js +30 -30
  100. package/helpers/babel/wrapRegExp/wrapRegExp.js +63 -63
  101. package/helpers/babel/writeOnlyError/writeOnlyError.js +4 -4
  102. package/helpers/regenerator-runtime/regenerator-runtime.js +748 -748
  103. package/package.json +4 -2
  104. package/src/buildProject.js +2 -2
  105. package/src/execute.js +1 -1
  106. package/src/internal/browser-launcher/jsenv-browser-system.js +1 -1
  107. package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +0 -3
  108. package/src/internal/compiling/compileFile.js +1 -7
  109. package/src/internal/compiling/createCompiledFileService.js +4 -4
  110. package/src/internal/compiling/startCompileServer.js +73 -152
  111. package/src/internal/executing/coverage/babel_plugin_instrument.js +90 -90
  112. package/src/internal/executing/coverage/reportToCoverage.js +187 -187
  113. package/src/internal/executing/executePlan.js +1 -1
  114. package/src/internal/executing/launchAndExecute.js +17 -9
  115. package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +9 -13
  116. package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +9 -12
  117. package/src/internal/runtime/s.js +727 -727
  118. package/src/internal/toolbar/jsenv-logo.svg +144 -144
  119. package/src/internal/url_conversion.js +2 -2
  120. package/src/startExploring.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "23.6.0",
3
+ "version": "23.7.1",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -50,6 +50,9 @@
50
50
  "prepublishOnly": "node ./script/publish/remove_postinstall.mjs && npm run dist",
51
51
  "postpublish": "node ./script/publish/restore_postinstall.mjs"
52
52
  },
53
+ "peerDependencies": {
54
+ "playwright": "1.x"
55
+ },
53
56
  "dependencies": {
54
57
  "@babel/core": "7.16.0",
55
58
  "@babel/helper-module-imports": "7.15.4",
@@ -94,7 +97,6 @@
94
97
  "node-fetch": "3.0.0",
95
98
  "parse5": "6.0.1",
96
99
  "pidtree": "0.5.0",
97
- "playwright": "1.16.2",
98
100
  "postcss": "8.3.9",
99
101
  "postcss-value-parser": "4.1.0",
100
102
  "regenerator-runtime": "0.13.9",
@@ -88,7 +88,7 @@ export const buildProject = async ({
88
88
  jsenvDirectoryRelativeUrl,
89
89
  jsenvDirectoryClean,
90
90
 
91
- // when true .jsenv/out-build directory is generated
91
+ // when true .jsenv/build directory is generated
92
92
  // with all intermediated files used to produce the final build files.
93
93
  // it might improve buildProject speed for subsequent build generation
94
94
  // but this is to be proven and not absolutely required
@@ -158,7 +158,7 @@ export const buildProject = async ({
158
158
  // than exploring-server. This is because here we compile for rollup
159
159
  // that is expecting esmodule format, not systemjs
160
160
  // + some more differences like import.meta.dev
161
- outDirectoryName: "out-build",
161
+ outDirectoryName: "build",
162
162
  importDefaultExtension,
163
163
  moduleOutFormat: "esmodule", // rollup will transform into systemjs
164
164
  importMetaFormat: format, // but ensure import.meta are correctly transformed into the right format
package/src/execute.js CHANGED
@@ -99,7 +99,7 @@ export const execute = async ({
99
99
  projectDirectoryUrl,
100
100
  jsenvDirectoryRelativeUrl,
101
101
  jsenvDirectoryClean,
102
- outDirectoryName: "out-dev",
102
+ outDirectoryName: "dev",
103
103
 
104
104
  importDefaultExtension,
105
105
 
@@ -141,7 +141,7 @@ const onExecutionError = (executionResult, { currentScript }) => {
141
141
  const getBrowserRuntime = memoize(async () => {
142
142
  const compileServerOrigin = document.location.origin
143
143
  const compileMetaResponse = await fetchUrl(
144
- `${compileServerOrigin}/.jsenv/compile-meta.json`,
144
+ `${compileServerOrigin}/.jsenv/__compile_server_meta__.json`,
145
145
  )
146
146
  const compileMeta = await compileMetaResponse.json()
147
147
  const { outDirectoryRelativeUrl, errorStackRemapping } = compileMeta
@@ -137,7 +137,6 @@ const computeCompileReport = async ({
137
137
  logger,
138
138
  originalFileUrl,
139
139
  fileContentFallback,
140
- request,
141
140
  compile,
142
141
  }),
143
142
  )
@@ -178,7 +177,6 @@ const callCompile = async ({
178
177
  logger,
179
178
  originalFileUrl,
180
179
  fileContentFallback,
181
- request,
182
180
  compile,
183
181
  }) => {
184
182
  logger.debug(`compile ${originalFileUrl}`)
@@ -191,7 +189,6 @@ const callCompile = async ({
191
189
  const compileReturnValue = await compile({
192
190
  code: codeBeforeCompile,
193
191
  map: undefined,
194
- request,
195
192
  })
196
193
  if (typeof compileReturnValue !== "object" || compileReturnValue === null) {
197
194
  throw new TypeError(
@@ -85,13 +85,7 @@ export const compileFile = async ({
85
85
  responseHeaders = {},
86
86
  } = compileResult
87
87
 
88
- if (
89
- compileResultStatus !== "cached" &&
90
- compileCacheStrategy !== "none" &&
91
- // a cutom compiler explicitely disables cache by returning "cache-control": "no-store"
92
- // this file must not be cached on the filesystem and always re-generated
93
- responseHeaders["cache-control"] !== "no-store"
94
- ) {
88
+ if (compileResultStatus !== "cached" && compileCacheStrategy !== "none") {
95
89
  updateMeta({
96
90
  logger,
97
91
  meta,
@@ -86,9 +86,9 @@ export const createCompiledFileService = ({
86
86
  }
87
87
 
88
88
  const { compileId, afterCompileId } = requestCompileInfo
89
- // serve files inside /.jsenv/out/* directly without compilation
89
+ // serve files inside /.jsenv/* directly without compilation
90
90
  // this is just to allow some files to be written inside outDirectory and read directly
91
- // if asked by the client (such as env.json, groupMap.json, meta.json)
91
+ // if asked by the client (such __compile_server_meta__.json)
92
92
  if (!compileId) {
93
93
  return fetchFileSystem(
94
94
  new URL(request.ressource.slice(1), projectDirectoryUrl),
@@ -155,9 +155,8 @@ export const createCompiledFileService = ({
155
155
  compileCacheStrategy,
156
156
  projectFileRequestedCallback,
157
157
  request,
158
- compile: ({ signal, code, map }) => {
158
+ compile: ({ code, map }) => {
159
159
  return compiler({
160
- signal,
161
160
  logger,
162
161
 
163
162
  code,
@@ -168,6 +167,7 @@ export const createCompiledFileService = ({
168
167
  compileServerOrigin: request.origin,
169
168
  outDirectoryRelativeUrl,
170
169
  compileId,
170
+ request,
171
171
 
172
172
  runtimeSupport,
173
173
  moduleOutFormat,
@@ -256,7 +256,7 @@ export const startCompileServer = async ({
256
256
  }
257
257
  }
258
258
 
259
- const outJSONFiles = createOutJSONFiles({
259
+ const compileServerMetaFileInfo = createCompileServerMetaFileInfo({
260
260
  projectDirectoryUrl,
261
261
  jsenvDirectoryRelativeUrl,
262
262
  outDirectoryRelativeUrl,
@@ -271,29 +271,28 @@ export const startCompileServer = async ({
271
271
  sourcemapExcludeSources,
272
272
  })
273
273
  if (compileServerCanWriteOnFilesystem) {
274
- await setupOutDirectory({
274
+ await cleanOutDirectoryIfNeeded({
275
275
  logger,
276
- outDirectoryMeta: outJSONFiles.meta.data,
277
276
  outDirectoryUrl,
278
277
  jsenvDirectoryUrl,
279
278
  jsenvDirectoryClean,
279
+ compileServerMetaFileInfo,
280
280
  })
281
+ writeFile(
282
+ compileServerMetaFileInfo.url,
283
+ JSON.stringify(compileServerMetaFileInfo.data, null, " "),
284
+ )
285
+ logger.debug(`-> ${compileServerMetaFileInfo.url}`)
281
286
  }
282
287
 
283
288
  const jsenvServices = {
284
289
  "service:compilation asset": createCompilationAssetFileService({
285
290
  projectDirectoryUrl,
286
291
  }),
287
- "service:browser script": createBrowserScriptService({
292
+ "service:compile server meta": createCompileServerMetaService({
288
293
  projectDirectoryUrl,
289
- outDirectoryRelativeUrl,
290
- }),
291
- "service:out files": await createOutFilesService({
292
- logger,
293
- projectDirectoryUrl,
294
- compileServerCanWriteOnFilesystem,
295
294
  outDirectoryUrl,
296
- outJSONFiles,
295
+ compileServerMetaFileInfo,
297
296
  }),
298
297
  "service: compile proxy": createCompileProxyService({
299
298
  projectDirectoryUrl,
@@ -458,12 +457,12 @@ const assertArguments = ({
458
457
  }
459
458
  }
460
459
 
461
- const setupOutDirectory = async ({
460
+ const cleanOutDirectoryIfNeeded = async ({
462
461
  logger,
463
- outDirectoryMeta,
464
462
  outDirectoryUrl,
465
463
  jsenvDirectoryClean,
466
464
  jsenvDirectoryUrl,
465
+ compileServerMetaFileInfo,
467
466
  }) => {
468
467
  if (jsenvDirectoryClean) {
469
468
  logger.debug(
@@ -471,24 +470,23 @@ const setupOutDirectory = async ({
471
470
  )
472
471
  await ensureEmptyDirectory(jsenvDirectoryUrl)
473
472
  }
474
- const metaFileUrl = resolveUrl("./meta.json", outDirectoryUrl)
475
473
 
476
- let previousOutDirectoryMeta
474
+ let previousCompileServerMeta
477
475
  try {
478
- const source = await readFile(metaFileUrl)
479
- previousOutDirectoryMeta = JSON.parse(source)
476
+ const source = await readFile(compileServerMetaFileInfo.url)
477
+ previousCompileServerMeta = JSON.parse(source)
480
478
  } catch (e) {
481
479
  if (e && e.code === "ENOENT") {
482
- previousOutDirectoryMeta = null
480
+ previousCompileServerMeta = null
483
481
  } else {
484
482
  throw e
485
483
  }
486
484
  }
487
485
 
488
- if (previousOutDirectoryMeta !== null) {
486
+ if (previousCompileServerMeta !== null) {
489
487
  const outDirectoryChanges = getOutDirectoryChanges(
490
- previousOutDirectoryMeta,
491
- outDirectoryMeta,
488
+ previousCompileServerMeta,
489
+ compileServerMetaFileInfo.data,
492
490
  )
493
491
 
494
492
  if (outDirectoryChanges) {
@@ -512,12 +510,15 @@ const setupOutDirectory = async ({
512
510
  }
513
511
  }
514
512
 
515
- const getOutDirectoryChanges = (previousOutDirectoryMeta, outDirectoryMeta) => {
513
+ const getOutDirectoryChanges = (
514
+ previousCompileServerMeta,
515
+ compileServerMeta,
516
+ ) => {
516
517
  const changes = []
517
518
 
518
- Object.keys(outDirectoryMeta).forEach((key) => {
519
- const now = outDirectoryMeta[key]
520
- const previous = previousOutDirectoryMeta[key]
519
+ Object.keys(compileServerMeta).forEach((key) => {
520
+ const now = compileServerMeta[key]
521
+ const previous = previousCompileServerMeta[key]
521
522
  if (!compareValueJson(now, previous)) {
522
523
  changes.push(key)
523
524
  }
@@ -528,7 +529,7 @@ const getOutDirectoryChanges = (previousOutDirectoryMeta, outDirectoryMeta) => {
528
529
  }
529
530
 
530
531
  // in case basic comparison from above is not enough
531
- if (!compareValueJson(previousOutDirectoryMeta, outDirectoryMeta)) {
532
+ if (!compareValueJson(previousCompileServerMeta, compileServerMeta)) {
532
533
  return { somethingChanged: true }
533
534
  }
534
535
 
@@ -539,7 +540,6 @@ const compareValueJson = (left, right) => {
539
540
  return JSON.stringify(left) === JSON.stringify(right)
540
541
  }
541
542
 
542
- // eslint-disable-next-line valid-jsdoc
543
543
  /**
544
544
  * We need to get two things:
545
545
  * { projectFileRequestedCallback, trackMainAndDependencies }
@@ -869,46 +869,6 @@ const createCompilationAssetFileService = ({ projectDirectoryUrl }) => {
869
869
  }
870
870
  }
871
871
 
872
- const createBrowserScriptService = ({
873
- projectDirectoryUrl,
874
- outDirectoryRelativeUrl,
875
- }) => {
876
- const sourcemapMainFileRelativeUrl = urlToRelativeUrl(
877
- sourcemapMainFileInfo.url,
878
- projectDirectoryUrl,
879
- )
880
- const sourcemapMappingFileRelativeUrl = urlToRelativeUrl(
881
- sourcemapMappingFileInfo.url,
882
- projectDirectoryUrl,
883
- )
884
-
885
- return (request) => {
886
- if (
887
- request.method === "GET" &&
888
- request.ressource === "/.jsenv/compile-meta.json"
889
- ) {
890
- const body = JSON.stringify({
891
- outDirectoryRelativeUrl,
892
- errorStackRemapping: true,
893
- sourcemapMainFileRelativeUrl,
894
- sourcemapMappingFileRelativeUrl,
895
- })
896
-
897
- return {
898
- status: 200,
899
- headers: {
900
- "cache-control": "no-store",
901
- "content-type": "application/json",
902
- "content-length": Buffer.byteLength(body),
903
- },
904
- body,
905
- }
906
- }
907
-
908
- return null
909
- }
910
- }
911
-
912
872
  const createSourceFileService = ({
913
873
  projectDirectoryUrl,
914
874
  projectFileRequestedCallback,
@@ -931,7 +891,7 @@ const createSourceFileService = ({
931
891
  }
932
892
  }
933
893
 
934
- const createOutJSONFiles = ({
894
+ const createCompileServerMetaFileInfo = ({
935
895
  projectDirectoryUrl,
936
896
  jsenvDirectoryRelativeUrl,
937
897
  outDirectoryRelativeUrl,
@@ -947,13 +907,14 @@ const createOutJSONFiles = ({
947
907
  sourcemapMethod,
948
908
  sourcemapExcludeSources,
949
909
  }) => {
950
- const outJSONFiles = {}
951
910
  const outDirectoryUrl = resolveUrl(
952
911
  outDirectoryRelativeUrl,
953
912
  projectDirectoryUrl,
954
913
  )
955
-
956
- const metaOutFileUrl = resolveUrl("./meta.json", outDirectoryUrl)
914
+ const compileServerMetaFileUrl = resolveUrl(
915
+ "./__compile_server_meta__.json",
916
+ outDirectoryUrl,
917
+ )
957
918
  const jsenvCorePackageFileUrl = resolveUrl(
958
919
  "./package.json",
959
920
  jsenvCoreDirectoryUrl,
@@ -961,43 +922,40 @@ const createOutJSONFiles = ({
961
922
  const jsenvCorePackageFilePath = urlToFileSystemPath(jsenvCorePackageFileUrl)
962
923
  const jsenvCorePackageVersion = readPackage(jsenvCorePackageFilePath).version
963
924
  const customCompilerPatterns = Object.keys(customCompilers)
964
- const outDirectoryMeta = {
965
- jsenvCorePackageVersion,
925
+ const sourcemapMainFileRelativeUrl = urlToRelativeUrl(
926
+ sourcemapMainFileInfo.url,
927
+ projectDirectoryUrl,
928
+ )
929
+ const sourcemapMappingFileRelativeUrl = urlToRelativeUrl(
930
+ sourcemapMappingFileInfo.url,
931
+ projectDirectoryUrl,
932
+ )
933
+ const compileServerMeta = {
934
+ jsenvDirectoryRelativeUrl,
935
+ outDirectoryRelativeUrl,
936
+ importDefaultExtension,
937
+
966
938
  babelPluginMap: babelPluginMapAsData(babelPluginMap),
967
939
  compileServerGroupMap,
940
+ customCompilerPatterns,
968
941
  replaceProcessEnvNodeEnv,
969
942
  processEnvNodeEnv,
970
- customCompilerPatterns,
971
- jsenvToolbarInjection,
943
+ inlineImportMapIntoHTML,
944
+
972
945
  sourcemapMethod,
973
946
  sourcemapExcludeSources,
974
- }
975
- outJSONFiles.meta = {
976
- url: metaOutFileUrl,
977
- data: outDirectoryMeta,
978
- }
947
+ sourcemapMainFileRelativeUrl,
948
+ sourcemapMappingFileRelativeUrl,
949
+ errorStackRemapping: true,
979
950
 
980
- const envOutFileUrl = resolveUrl("./env.json", outDirectoryUrl)
981
- env = {
982
- ...env,
983
- jsenvDirectoryRelativeUrl,
984
- outDirectoryRelativeUrl,
985
- importDefaultExtension,
986
- inlineImportMapIntoHTML,
987
- customCompilerPatterns,
988
- }
989
- outJSONFiles.env = {
990
- url: envOutFileUrl,
991
- data: env,
951
+ jsenvCorePackageVersion,
952
+ jsenvToolbarInjection,
953
+ env,
992
954
  }
993
-
994
- const groupMapOutFileUrl = resolveUrl("./groupMap.json", outDirectoryUrl)
995
- outJSONFiles.groupMap = {
996
- url: groupMapOutFileUrl,
997
- data: compileServerGroupMap,
955
+ return {
956
+ url: compileServerMetaFileUrl,
957
+ data: compileServerMeta,
998
958
  }
999
-
1000
- return outJSONFiles
1001
959
  }
1002
960
 
1003
961
  const babelPluginMapAsData = (babelPluginMap) => {
@@ -1019,14 +977,12 @@ const babelPluginMapAsData = (babelPluginMap) => {
1019
977
  return data
1020
978
  }
1021
979
 
1022
- const createOutFilesService = async ({
1023
- logger,
980
+ const createCompileServerMetaService = ({
1024
981
  projectDirectoryUrl,
1025
- compileServerCanWriteOnFilesystem,
1026
982
  outDirectoryUrl,
1027
- outJSONFiles,
983
+ compileServerMetaFileInfo,
1028
984
  }) => {
1029
- const isOutRootFile = (url) => {
985
+ const isCompileServerMetaFile = (url) => {
1030
986
  if (!urlIsInsideOf(url, outDirectoryUrl)) {
1031
987
  return false
1032
988
  }
@@ -1037,64 +993,29 @@ const createOutFilesService = async ({
1037
993
  return true
1038
994
  }
1039
995
 
1040
- if (compileServerCanWriteOnFilesystem) {
1041
- await Promise.all(
1042
- Object.keys(outJSONFiles).map(async (name) => {
1043
- const outJSONFile = outJSONFiles[name]
1044
- await writeFile(
1045
- outJSONFile.url,
1046
- JSON.stringify(outJSONFile.data, null, " "),
1047
- )
1048
- logger.debug(`-> ${outJSONFile.url}`)
1049
- }),
1050
- )
1051
-
1052
- return async (request) => {
1053
- const requestUrl = resolveUrl(
1054
- request.ressource.slice(1),
1055
- projectDirectoryUrl,
1056
- )
1057
- if (!isOutRootFile(requestUrl)) {
1058
- return null
1059
- }
1060
- return fetchFileSystem(
1061
- new URL(request.ressource.slice(1), projectDirectoryUrl),
1062
- {
1063
- headers: request.headers,
1064
- etagEnabled: true,
1065
- },
1066
- )
1067
- }
1068
- }
1069
996
  // serve from memory
1070
997
  return (request) => {
1071
998
  const requestUrl = resolveUrl(
1072
999
  request.ressource.slice(1),
1073
1000
  projectDirectoryUrl,
1074
1001
  )
1075
- if (!isOutRootFile(requestUrl)) {
1076
- return null
1077
- }
1078
-
1079
- const outJSONFileKey = Object.keys(outJSONFiles).find((name) => {
1080
- return outJSONFiles[name].url === requestUrl
1081
- })
1082
- if (!outJSONFileKey) {
1002
+ if (
1003
+ isCompileServerMetaFile(requestUrl) ||
1004
+ // allow to request it directly from .jsenv
1005
+ request.ressource === "/.jsenv/__compile_server_meta__.json"
1006
+ ) {
1007
+ const body = JSON.stringify(compileServerMetaFileInfo.data, null, " ")
1083
1008
  return {
1084
- status: 404,
1009
+ status: 200,
1010
+ headers: {
1011
+ "content-type": urlToContentType(requestUrl),
1012
+ "content-length": Buffer.byteLength(body),
1013
+ },
1014
+ body,
1085
1015
  }
1086
1016
  }
1087
1017
 
1088
- const outJSONFile = outJSONFiles[outJSONFileKey]
1089
- const body = JSON.stringify(outJSONFile.data, null, " ")
1090
- return {
1091
- status: 200,
1092
- headers: {
1093
- "content-type": urlToContentType(requestUrl),
1094
- "content-length": Buffer.byteLength(body),
1095
- },
1096
- body,
1097
- }
1018
+ return null
1098
1019
  }
1099
1020
  }
1100
1021
 
@@ -1,90 +1,90 @@
1
- import {
2
- resolveUrl,
3
- normalizeStructuredMetaMap,
4
- urlToMeta,
5
- } from "@jsenv/filesystem"
6
-
7
- import { require } from "../../require.js"
8
-
9
- // https://github.com/istanbuljs/babel-plugin-istanbul/blob/321740f7b25d803f881466ea819d870f7ed6a254/src/index.js
10
-
11
- export const babelPluginInstrument = (api, options) => {
12
- const { programVisitor } = require("istanbul-lib-instrument")
13
-
14
- const { types } = api
15
- const {
16
- useInlineSourceMaps = false,
17
- projectDirectoryUrl,
18
- coverageConfig = { "./**/*": true },
19
- } = options
20
-
21
- const structuredMetaMapForCover = normalizeStructuredMetaMap(
22
- {
23
- cover: coverageConfig,
24
- },
25
- projectDirectoryUrl,
26
- )
27
- const shouldInstrument = (relativeUrl) => {
28
- return urlToMeta({
29
- url: resolveUrl(relativeUrl, projectDirectoryUrl),
30
- structuredMetaMap: structuredMetaMapForCover,
31
- }).cover
32
- }
33
-
34
- return {
35
- name: "transform-instrument",
36
- visitor: {
37
- Program: {
38
- enter(path) {
39
- const { file } = this
40
- const { opts } = file
41
-
42
- const relativeUrl = optionsToRelativeUrl(opts)
43
- if (!relativeUrl) {
44
- console.warn("file without relativeUrl", relativeUrl)
45
- return
46
- }
47
- if (!shouldInstrument(relativeUrl)) return
48
-
49
- this.__dv__ = null
50
-
51
- let inputSourceMap
52
-
53
- if (useInlineSourceMaps) {
54
- // https://github.com/istanbuljs/babel-plugin-istanbul/commit/a9e15643d249a2985e4387e4308022053b2cd0ad#diff-1fdf421c05c1140f6d71444ea2b27638R65
55
- inputSourceMap =
56
- opts.inputSourceMap || file.inputMap
57
- ? file.inputMap.sourcemap
58
- : null
59
- } else {
60
- inputSourceMap = opts.inputSourceMap
61
- }
62
-
63
- this.__dv__ = programVisitor(
64
- types,
65
- opts.filenameRelative || opts.filename,
66
- {
67
- coverageVariable: "__coverage__",
68
- inputSourceMap,
69
- },
70
- )
71
- this.__dv__.enter(path)
72
- },
73
-
74
- exit(path) {
75
- if (!this.__dv__) {
76
- return
77
- }
78
- const object = this.__dv__.exit(path)
79
- // object got two properties: fileCoverage and sourceMappingURL
80
- this.file.metadata.coverage = object.fileCoverage
81
- },
82
- },
83
- },
84
- }
85
- }
86
-
87
- const optionsToRelativeUrl = ({ filenameRelative }) => {
88
- if (filenameRelative) return filenameRelative
89
- return ""
90
- }
1
+ import {
2
+ resolveUrl,
3
+ normalizeStructuredMetaMap,
4
+ urlToMeta,
5
+ } from "@jsenv/filesystem"
6
+
7
+ import { require } from "../../require.js"
8
+
9
+ // https://github.com/istanbuljs/babel-plugin-istanbul/blob/321740f7b25d803f881466ea819d870f7ed6a254/src/index.js
10
+
11
+ export const babelPluginInstrument = (api, options) => {
12
+ const { programVisitor } = require("istanbul-lib-instrument")
13
+
14
+ const { types } = api
15
+ const {
16
+ useInlineSourceMaps = false,
17
+ projectDirectoryUrl,
18
+ coverageConfig = { "./**/*": true },
19
+ } = options
20
+
21
+ const structuredMetaMapForCover = normalizeStructuredMetaMap(
22
+ {
23
+ cover: coverageConfig,
24
+ },
25
+ projectDirectoryUrl,
26
+ )
27
+ const shouldInstrument = (relativeUrl) => {
28
+ return urlToMeta({
29
+ url: resolveUrl(relativeUrl, projectDirectoryUrl),
30
+ structuredMetaMap: structuredMetaMapForCover,
31
+ }).cover
32
+ }
33
+
34
+ return {
35
+ name: "transform-instrument",
36
+ visitor: {
37
+ Program: {
38
+ enter(path) {
39
+ const { file } = this
40
+ const { opts } = file
41
+
42
+ const relativeUrl = optionsToRelativeUrl(opts)
43
+ if (!relativeUrl) {
44
+ console.warn("file without relativeUrl", relativeUrl)
45
+ return
46
+ }
47
+ if (!shouldInstrument(relativeUrl)) return
48
+
49
+ this.__dv__ = null
50
+
51
+ let inputSourceMap
52
+
53
+ if (useInlineSourceMaps) {
54
+ // https://github.com/istanbuljs/babel-plugin-istanbul/commit/a9e15643d249a2985e4387e4308022053b2cd0ad#diff-1fdf421c05c1140f6d71444ea2b27638R65
55
+ inputSourceMap =
56
+ opts.inputSourceMap || file.inputMap
57
+ ? file.inputMap.sourcemap
58
+ : null
59
+ } else {
60
+ inputSourceMap = opts.inputSourceMap
61
+ }
62
+
63
+ this.__dv__ = programVisitor(
64
+ types,
65
+ opts.filenameRelative || opts.filename,
66
+ {
67
+ coverageVariable: "__coverage__",
68
+ inputSourceMap,
69
+ },
70
+ )
71
+ this.__dv__.enter(path)
72
+ },
73
+
74
+ exit(path) {
75
+ if (!this.__dv__) {
76
+ return
77
+ }
78
+ const object = this.__dv__.exit(path)
79
+ // object got two properties: fileCoverage and sourceMappingURL
80
+ this.file.metadata.coverage = object.fileCoverage
81
+ },
82
+ },
83
+ },
84
+ }
85
+ }
86
+
87
+ const optionsToRelativeUrl = ({ filenameRelative }) => {
88
+ if (filenameRelative) return filenameRelative
89
+ return ""
90
+ }