@jsenv/core 31.0.1 → 31.1.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.
package/dist/main.js CHANGED
@@ -20,6 +20,7 @@ import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes
20
20
  import { createRequire } from "node:module";
21
21
  import babelParser from "@babel/parser";
22
22
  import { bundleJsModules } from "@jsenv/plugin-bundling";
23
+ import { replacePlaceholders } from "@jsenv/plugin-placeholders";
23
24
  import v8, { takeCoverage } from "node:v8";
24
25
  import wrapAnsi from "wrap-ansi";
25
26
  import stripAnsi from "strip-ansi";
@@ -17977,6 +17978,30 @@ const babelPluginMetadataImportMetaScenarios = () => {
17977
17978
  };
17978
17979
  };
17979
17980
 
17981
+ /*
17982
+ * Source code can contain the following
17983
+ * - __dev__
17984
+ * - __build__
17985
+ * A global will be injected with true/false when needed
17986
+ */
17987
+ const jsenvPluginGlobalScenarios = () => {
17988
+ const transformIfNeeded = (urlInfo, context) => {
17989
+ return replacePlaceholders(urlInfo, {
17990
+ false: context.dev,
17991
+ true: context.build
17992
+ });
17993
+ };
17994
+ return {
17995
+ name: "jsenv:global_scenario",
17996
+ appliesDuring: "*",
17997
+ transformUrlContent: {
17998
+ js_classic: transformIfNeeded,
17999
+ js_module: transformIfNeeded,
18000
+ html: transformIfNeeded
18001
+ }
18002
+ };
18003
+ };
18004
+
17980
18005
  const jsenvPluginCssTranspilation = () => {
17981
18006
  return {
17982
18007
  name: "jsenv:css_transpilation",
@@ -20309,7 +20334,7 @@ const getCorePlugins = ({
20309
20334
  runtimeCompat,
20310
20335
  clientMainFileUrl,
20311
20336
  urlResolution
20312
- }), jsenvPluginUrlVersion(), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), jsenvPluginNodeRuntime({
20337
+ }), jsenvPluginUrlVersion(), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), jsenvPluginGlobalScenarios(), jsenvPluginNodeRuntime({
20313
20338
  runtimeCompat
20314
20339
  }), jsenvPluginImportMetaHot(), ...(clientAutoreload ? [jsenvPluginAutoreload({
20315
20340
  ...clientAutoreload,
@@ -23975,7 +24000,7 @@ const descriptionFormatters = {
23975
24000
  }) => {
23976
24001
  return ANSI.color(`${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total} timeout after ${executionParams.allocatedMs}ms`, EXECUTION_COLORS.timedout);
23977
24002
  },
23978
- efailedrrored: ({
24003
+ failed: ({
23979
24004
  index,
23980
24005
  total
23981
24006
  }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "31.0.1",
3
+ "version": "31.1.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -75,6 +75,7 @@
75
75
  "@jsenv/log": "3.3.4",
76
76
  "@jsenv/node-esm-resolution": "1.0.1",
77
77
  "@jsenv/plugin-bundling": "2.0.0",
78
+ "@jsenv/plugin-globals": "1.1.0",
78
79
  "@jsenv/server": "15.0.0",
79
80
  "@jsenv/sourcemap": "1.0.9",
80
81
  "@jsenv/uneval": "1.6.0",
@@ -113,6 +114,6 @@
113
114
  "eslint-plugin-import": "2.27.5",
114
115
  "eslint-plugin-react": "7.32.2",
115
116
  "playwright": "1.31.2",
116
- "prettier": "2.8.4"
117
+ "prettier": "2.8.6"
117
118
  }
118
119
  }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Source code can contain the following
3
+ * - __dev__
4
+ * - __build__
5
+ * A global will be injected with true/false when needed
6
+ */
7
+
8
+ import { replacePlaceholders } from "@jsenv/plugin-placeholders"
9
+
10
+ export const jsenvPluginGlobalScenarios = () => {
11
+ const transformIfNeeded = (urlInfo, context) => {
12
+ return replacePlaceholders(urlInfo, {
13
+ __DEV__: context.dev,
14
+ __BUILD__: context.build,
15
+ })
16
+ }
17
+
18
+ return {
19
+ name: "jsenv:global_scenario",
20
+ appliesDuring: "*",
21
+ transformUrlContent: {
22
+ js_classic: transformIfNeeded,
23
+ js_module: transformIfNeeded,
24
+ html: transformIfNeeded,
25
+ },
26
+ }
27
+ }
@@ -8,6 +8,7 @@ import { jsenvPluginInline } from "./inline/jsenv_plugin_inline.js"
8
8
  import { jsenvPluginSupervisor } from "./supervisor/jsenv_plugin_supervisor.js"
9
9
  import { jsenvPluginCommonJsGlobals } from "./commonjs_globals/jsenv_plugin_commonjs_globals.js"
10
10
  import { jsenvPluginImportMetaScenarios } from "./import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js"
11
+ import { jsenvPluginGlobalScenarios } from "./global_scenarios/jsenv_plugin_global_scenarios.js"
11
12
  import { jsenvPluginTranspilation } from "./transpilation/jsenv_plugin_transpilation.js"
12
13
  import { jsenvPluginNodeRuntime } from "./node_runtime/jsenv_plugin_node_runtime.js"
13
14
  // autoreload
@@ -89,6 +90,7 @@ export const getCorePlugins = ({
89
90
  jsenvPluginUrlVersion(),
90
91
  jsenvPluginCommonJsGlobals(),
91
92
  jsenvPluginImportMetaScenarios(),
93
+ jsenvPluginGlobalScenarios(),
92
94
 
93
95
  jsenvPluginNodeRuntime({ runtimeCompat }),
94
96
 
@@ -221,7 +221,7 @@ const descriptionFormatters = {
221
221
  EXECUTION_COLORS.timedout,
222
222
  )
223
223
  },
224
- efailedrrored: ({ index, total }) => {
224
+ failed: ({ index, total }) => {
225
225
  return ANSI.color(
226
226
  `${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total} failed`,
227
227
  EXECUTION_COLORS.failed,