@jsenv/core 25.2.0 → 25.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "25.2.0",
3
+ "version": "25.2.1",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/dev_server.js CHANGED
@@ -49,6 +49,7 @@ export const startDevServer = async ({
49
49
  serviceWorkers,
50
50
  importMapInWebWorkers,
51
51
  customCompilers,
52
+ preservedUrls,
52
53
  runtimeSupportDuringDev = {
53
54
  // this allows to compile nothing or almost nothing when opening files
54
55
  // with a recent chrome. Without this we would compile all the things not yet unsupported
@@ -125,6 +126,7 @@ export const startDevServer = async ({
125
126
  compileServerCanReadFromFilesystem,
126
127
  compileServerCanWriteOnFilesystem,
127
128
  customCompilers,
129
+ preservedUrls,
128
130
  sourcemapMethod,
129
131
  babelPluginMap,
130
132
  workers,
@@ -31,7 +31,9 @@ export const updateMeta = async ({
31
31
  if (isNew || isUpdated) {
32
32
  // ensure source that does not leads to concrete files are not capable to invalidate the cache
33
33
  const sourcesToRemove = sources.filter((sourceFileUrl) => {
34
- return !testFilePresence(sourceFileUrl)
34
+ return (
35
+ sourceFileUrl.startsWith("file://") && !testFilePresence(sourceFileUrl)
36
+ )
35
37
  })
36
38
  const sourceNotFoundCount = sourcesToRemove.length
37
39
  if (sourceNotFoundCount > 0) {
@@ -1,7 +1,6 @@
1
1
  // https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-core/src/tools/build-external-helpers.js
2
2
  // the list of possible helpers:
3
3
  // https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-helpers/src/helpers.js#L13
4
- import { fileSystemPathToUrl } from "@jsenv/filesystem"
5
4
  import { require } from "../../require.js"
6
5
 
7
6
  const babelHelperNameInsideJsenvCoreArray = [
@@ -113,13 +112,14 @@ export const babelHelperNameToImportSpecifier = (babelHelperName) => {
113
112
  return `${babelHelperAbstractScope}${babelHelperName}/${babelHelperName}.js`
114
113
  }
115
114
 
116
- export const filePathToBabelHelperName = (filePath) => {
117
- const fileUrl = fileSystemPathToUrl(filePath)
118
-
115
+ export const babelHelperNameFromUrl = (url) => {
116
+ if (!url.startsWith("file://")) {
117
+ return null
118
+ }
119
119
  const babelHelperPrefix = "core/helpers/babel/"
120
- if (fileUrl.includes(babelHelperPrefix)) {
121
- const afterBabelHelper = fileUrl.slice(
122
- fileUrl.indexOf(babelHelperPrefix) + babelHelperPrefix.length,
120
+ if (url.includes(babelHelperPrefix)) {
121
+ const afterBabelHelper = url.slice(
122
+ url.indexOf(babelHelperPrefix) + babelHelperPrefix.length,
123
123
  )
124
124
  const babelHelperName = afterBabelHelper.slice(
125
125
  0,
@@ -127,11 +127,9 @@ export const filePathToBabelHelperName = (filePath) => {
127
127
  )
128
128
  return babelHelperName
129
129
  }
130
-
131
- if (fileUrl.includes(babelHelperAbstractScope)) {
132
- const afterBabelHelper = fileUrl.slice(
133
- fileUrl.indexOf(babelHelperAbstractScope) +
134
- babelHelperAbstractScope.length,
130
+ if (url.includes(babelHelperAbstractScope)) {
131
+ const afterBabelHelper = url.slice(
132
+ url.indexOf(babelHelperAbstractScope) + babelHelperAbstractScope.length,
135
133
  )
136
134
  const babelHelperName = afterBabelHelper.slice(
137
135
  0,
@@ -139,7 +137,6 @@ export const filePathToBabelHelperName = (filePath) => {
139
137
  )
140
138
  return babelHelperName
141
139
  }
142
-
143
140
  return null
144
141
  }
145
142
 
@@ -1,6 +1,8 @@
1
+ import { fileSystemPathToUrl } from "@jsenv/filesystem"
2
+
1
3
  import { require } from "../../require.js"
2
4
  import {
3
- filePathToBabelHelperName,
5
+ babelHelperNameFromUrl,
4
6
  babelHelperNameToImportSpecifier,
5
7
  } from "./babelHelper.js"
6
8
 
@@ -37,7 +39,7 @@ export const babelPluginBabelHelpersAsJsenvImports = (api) => {
37
39
  const babelHelperImportSpecifier =
38
40
  babelHelperNameToImportSpecifier(name)
39
41
 
40
- if (filePathToBabelHelperName(filePath) === name) {
42
+ if (babelHelperNameFromUrl(fileSystemPathToUrl(filePath)) === name) {
41
43
  return undefined
42
44
  }
43
45
 
@@ -13,7 +13,7 @@ import { ansiToHTML } from "./ansiToHTML.js"
13
13
  import { babelPluginRegeneratorRuntimeAsJsenvImport } from "./babel_plugin_regenerator_runtime_as_jsenv_import.js"
14
14
  import { babelPluginBabelHelpersAsJsenvImports } from "./babel_plugin_babel_helpers_as_jsenv_imports.js"
15
15
  import { babelPluginSystemJsPrepend } from "./babel_plugin_systemjs_prepend.js"
16
- import { filePathToBabelHelperName } from "./babelHelper.js"
16
+ import { babelHelperNameFromUrl } from "./babelHelper.js"
17
17
 
18
18
  export const jsenvTransform = async ({
19
19
  jsenvRemoteDirectory,
@@ -36,7 +36,6 @@ export const jsenvTransform = async ({
36
36
  }) => {
37
37
  const transformModulesSystemJs = require("@babel/plugin-transform-modules-systemjs")
38
38
  const proposalDynamicImport = require("@babel/plugin-proposal-dynamic-import")
39
-
40
39
  const inputPath = computeInputPath(url)
41
40
 
42
41
  // https://babeljs.io/docs/en/options
@@ -62,7 +61,7 @@ export const jsenvTransform = async ({
62
61
  },
63
62
  }
64
63
 
65
- const babelHelperName = filePathToBabelHelperName(inputPath)
64
+ const babelHelperName = babelHelperNameFromUrl(url)
66
65
  // to prevent typeof circular dependency
67
66
  if (babelHelperName === "typeof") {
68
67
  const babelPluginMapWithoutTransformTypeOf = { ...babelPluginMap }
@@ -427,7 +427,6 @@ const visitScripts = async ({
427
427
  })
428
428
  return
429
429
  }
430
-
431
430
  const scriptId = getIdForInlineHtmlNode(script, scripts)
432
431
  const inlineScriptName = `${scriptId}.js`
433
432
  const scriptOriginalUrl = resolveUrl(inlineScriptName, url)
@@ -491,7 +490,10 @@ const visitScripts = async ({
491
490
  if (fileIsInsideJsenvDistDirectory) {
492
491
  return
493
492
  }
494
-
493
+ const isRemoteUrl = jsenvRemoteDirectory.isRemoteUrl(src)
494
+ if (isRemoteUrl && jsenvRemoteDirectory.isPreservedUrl(src)) {
495
+ return
496
+ }
495
497
  const scriptCompiledUrl = generateCompilationAssetUrl(
496
498
  compiledUrl,
497
499
  urlToFilename(scriptOriginalUrl),
@@ -501,6 +503,7 @@ const visitScripts = async ({
501
503
  // the transformation here and not in compile server
502
504
  // (because compile server would think it's a module script
503
505
  // and add things like systemjs)
506
+ // we could take into account the integrity her
504
507
  const scriptResponse = await fetchUrl(scriptOriginalUrl)
505
508
  if (scriptResponse.status !== 200) {
506
509
  logger.warn(