@jsenv/core 30.3.9 → 30.4.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.
@@ -2,7 +2,9 @@ import { createRuntimeFromPlaywright } from "./from_playwright.js"
2
2
 
3
3
  export const webkit = createRuntimeFromPlaywright({
4
4
  browserName: "webkit",
5
- browserVersion: "16.4", // to update, check https://github.com/microsoft/playwright/releases
5
+ // browserVersion will be set by "browser._initializer.version"
6
+ // see also https://github.com/microsoft/playwright/releases
7
+ browserVersion: "unset",
6
8
  ignoreErrorHook: (error) => {
7
9
  // we catch error during execution but safari throw unhandled rejection
8
10
  // in a non-deterministic way.
@@ -0,0 +1,13 @@
1
+ # runtimes/
2
+
3
+ Code implementing runtimes can be found here.
4
+
5
+ # Description
6
+
7
+ A runtime is an object with a "run" method.
8
+ The run method is roughly doing the following:
9
+
10
+ 1. spawn a runtime (browser,Node.js)
11
+ 2. set various listeners to monitor file execution
12
+ 3. execute the file
13
+ 4. return info about file execution (logs and errors for instance)
@@ -356,7 +356,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
356
356
  type,
357
357
  subtype,
358
358
  originalUrl,
359
- originalContent,
359
+ originalContent = content,
360
360
  sourcemap,
361
361
  filename,
362
362
 
@@ -381,8 +381,13 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
381
381
  urlInfo.subtype = subtype || reference.expectedSubtype || ""
382
382
  // during build urls info are reused and load returns originalUrl/originalContent
383
383
  urlInfo.originalUrl = originalUrl || urlInfo.originalUrl
384
- urlInfo.originalContent =
385
- originalContent === undefined ? content : originalContent
384
+ if (originalContent !== urlInfo.originalContent) {
385
+ urlInfo.originalContentEtag = undefined // set by "initTransformations"
386
+ }
387
+ if (content !== urlInfo.content) {
388
+ urlInfo.contentEtag = undefined // set by "applyFinalTransformations"
389
+ }
390
+ urlInfo.originalContent = originalContent
386
391
  urlInfo.content = content
387
392
  urlInfo.sourcemap = sourcemap
388
393
  if (data) {
@@ -0,0 +1,8 @@
1
+ # kitchen/
2
+
3
+ Code implementing jsenv kitchen can be found here.
4
+
5
+ # Description
6
+
7
+ Jsenv kitchen is an abstraction representing the place where files content is transformed to obtain something.
8
+ Jsenv dev server and build go through the kitchen to transform file content.
@@ -37,12 +37,30 @@ export const createUrlGraph = () => {
37
37
  if (!parentUrlInfo) {
38
38
  return null
39
39
  }
40
- const firstReferenceOnThatUrl = parentUrlInfo.references.find(
41
- (reference) => {
40
+ const seen = []
41
+ const search = (urlInfo) => {
42
+ const firstReferenceFound = urlInfo.references.find((reference) => {
42
43
  return urlSpecifierEncoding.decode(reference) === specifier
43
- },
44
- )
45
- return firstReferenceOnThatUrl
44
+ })
45
+ if (firstReferenceFound) {
46
+ return firstReferenceFound
47
+ }
48
+ for (const dependencyUrl of parentUrlInfo.dependencies) {
49
+ if (seen.includes(dependencyUrl)) {
50
+ continue
51
+ }
52
+ seen.push(dependencyUrl)
53
+ const dependencyUrlInfo = getUrlInfo(dependencyUrl)
54
+ if (dependencyUrlInfo.isInline) {
55
+ const firstRef = search(dependencyUrlInfo)
56
+ if (firstRef) {
57
+ return firstRef
58
+ }
59
+ }
60
+ }
61
+ return null
62
+ }
63
+ return search(parentUrlInfo)
46
64
  }
47
65
  const findDependent = (urlInfo, visitor) => {
48
66
  const seen = [urlInfo.url]
@@ -1,15 +1,19 @@
1
- export const jsenvPluginCacheControl = () => {
1
+ export const jsenvPluginCacheControl = ({
2
+ versionedUrls = true,
3
+ maxAge = SECONDS_IN_30_DAYS,
4
+ }) => {
2
5
  return {
3
6
  name: "jsenv:cache_control",
4
7
  appliesDuring: "dev",
5
8
  augmentResponse: ({ reference }) => {
6
9
  if (
10
+ versionedUrls &&
7
11
  reference.searchParams.has("v") &&
8
12
  !reference.searchParams.has("hmr")
9
13
  ) {
10
14
  return {
11
15
  headers: {
12
- "cache-control": `private,max-age=${SECONDS_IN_30_DAYS},immutable`,
16
+ "cache-control": `private,max-age=${maxAge},immutable`,
13
17
  },
14
18
  }
15
19
  }
@@ -38,11 +38,15 @@ export const getCorePlugins = ({
38
38
  clientFileChangeCallbackList,
39
39
  clientFilesPruneCallbackList,
40
40
  explorer,
41
+ cacheControl,
41
42
  ribbon = true,
42
43
  } = {}) => {
43
44
  if (explorer === true) {
44
45
  explorer = {}
45
46
  }
47
+ if (cacheControl === true) {
48
+ cacheControl = {}
49
+ }
46
50
  if (supervisor === true) {
47
51
  supervisor = {}
48
52
  }
@@ -59,6 +63,7 @@ export const getCorePlugins = ({
59
63
  } else {
60
64
  clientMainFileUrl = String(clientMainFileUrl)
61
65
  }
66
+
62
67
  if (ribbon === true) {
63
68
  ribbon = {}
64
69
  }
@@ -97,7 +102,7 @@ export const getCorePlugins = ({
97
102
  }),
98
103
  ]
99
104
  : []),
100
- jsenvPluginCacheControl(),
105
+ ...(cacheControl ? [jsenvPluginCacheControl(cacheControl)] : []),
101
106
  ...(explorer
102
107
  ? [jsenvPluginExplorer({ ...explorer, clientMainFileUrl })]
103
108
  : []),
@@ -0,0 +1,18 @@
1
+ # plugins/
2
+
3
+ Code implementing jsenv internal plugins can be found here.
4
+
5
+ # Description
6
+
7
+ These plugins can be configured using parameters of "startDevServer" and "build" functions.
8
+
9
+ A few examples of plugins that can be found here:
10
+
11
+ - inject code to autoreload during dev
12
+ - apply node module resolution on js imports
13
+
14
+ They are here and not inside a separate NPM package because:
15
+
16
+ 1. they are considered useful enough to be available by default
17
+ 2. putting them into a separate package would force people to enable a bunch of plugins
18
+ to obtain what they want instead of having sensible defaults
@@ -1,5 +1,3 @@
1
- /* globals self */
2
-
3
1
  import { createWebSocketConnection } from "./web_socket_connection.js"
4
2
 
5
3
  const websocketScheme = self.location.protocol === "https:" ? "wss" : "ws"
@@ -12,7 +12,6 @@
12
12
 
13
13
  ;(function () {
14
14
  /* eslint-env browser */
15
- /* globals self */
16
15
 
17
16
  const loadRegistry = Object.create(null)
18
17
  const registerRegistry = Object.create(null)
@@ -5,18 +5,9 @@ import { babelPluginInstrument } from "@jsenv/core/src/test/coverage/babel_plugi
5
5
  import { RUNTIME_COMPAT } from "@jsenv/core/src/kitchen/compat/runtime_compat.js"
6
6
  import { getBaseBabelPluginStructure } from "./helpers/babel_plugin_structure.js"
7
7
  import { babelPluginBabelHelpersAsJsenvImports } from "./helpers/babel_plugin_babel_helpers_as_jsenv_imports.js"
8
- import {
9
- babelPluginNewStylesheetAsJsenvImport,
10
- newStylesheetClientFileUrl,
11
- } from "./new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js"
12
- import {
13
- babelPluginGlobalThisAsJsenvImport,
14
- globalThisClientFileUrl,
15
- } from "./global_this/babel_plugin_global_this_as_jsenv_import.js"
16
- import {
17
- babelPluginRegeneratorRuntimeAsJsenvImport,
18
- regeneratorRuntimeClientFileUrl,
19
- } from "./regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js"
8
+ import { babelPluginNewStylesheetAsJsenvImport } from "./new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js"
9
+ import { babelPluginGlobalThisAsJsenvImport } from "./global_this/babel_plugin_global_this_as_jsenv_import.js"
10
+ import { babelPluginRegeneratorRuntimeAsJsenvImport } from "./regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js"
20
11
 
21
12
  export const jsenvPluginBabel = ({
22
13
  getCustomBabelPlugins,
@@ -115,17 +106,6 @@ export const jsenvPluginBabel = ({
115
106
  return {
116
107
  name: "jsenv:babel",
117
108
  appliesDuring: "*",
118
- transformUrlContent: (urlInfo) => {
119
- if (urlInfo.url === regeneratorRuntimeClientFileUrl) {
120
- urlInfo.data.isBabelClientFile = true
121
- }
122
- if (urlInfo.url === globalThisClientFileUrl) {
123
- urlInfo.data.isBabelClientFile = true
124
- }
125
- if (urlInfo.url === newStylesheetClientFileUrl) {
126
- urlInfo.data.isBabelClientFile = true
127
- }
128
- },
129
109
  finalizeUrlContent: {
130
110
  js_classic: transformWithBabel,
131
111
  js_module: transformWithBabel,
@@ -326,6 +326,7 @@ export const executePlan = async (
326
326
 
327
327
  const afterExecutionInfo = {
328
328
  ...beforeExecutionInfo,
329
+ runtimeVersion: runtime.version,
329
330
  endMs: Date.now(),
330
331
  executionResult,
331
332
  }
@@ -0,0 +1,3 @@
1
+ # test/
2
+
3
+ Code implementing "executeTestPlan" can be found here