@jsenv/core 23.8.20 → 23.11.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.
@@ -1,3 +1,3 @@
1
- export default function (value) {
1
+ export default function _AwaitValue (value) {
2
2
  this.wrapped = value
3
3
  }
@@ -1,13 +1,19 @@
1
1
  import superPropBase from "../superPropBase/superPropBase.js"
2
2
 
3
- function reflectGet(target, property, receiver) {
4
- var base = superPropBase(target, property)
5
- if (!base) return undefined
6
- var desc = Object.getOwnPropertyDescriptor(base, property)
7
- if (desc.get) {
8
- return desc.get.call(receiver)
3
+ export default function _get() {
4
+ if (typeof Reflect !== "undefined" && Reflect.get) {
5
+ _get = Reflect.get;
6
+ } else {
7
+ _get = function _get(target, property, receiver) {
8
+ var base = superPropBase(target, property);
9
+ if (!base) return;
10
+ var desc = Object.getOwnPropertyDescriptor(base, property);
11
+ if (desc.get) {
12
+ // STEP 3. If receiver is not present, then set receiver to target.
13
+ return desc.get.call(arguments.length < 3 ? target : receiver);
14
+ }
15
+ return desc.value;
16
+ };
9
17
  }
10
- return desc.value
11
- }
12
-
13
- export default typeof Reflect !== "undefined" && Reflect.get ? Reflect.get : reflectGet
18
+ return _get.apply(this, arguments);
19
+ }
@@ -2,8 +2,12 @@
2
2
 
3
3
  Babel helpers are copied in there to properly appear in sourcemap.
4
4
 
5
- - All thoose file are inlines versions of babel helpers declared in: https://github.com/babel/babel/blob/main/packages/babel-helpers/src/helpers.js
5
+ - Last sync date: 21 November 2021
6
6
 
7
7
  - History of the file: https://github.com/babel/babel/commits/main/packages/babel-helpers/src/helpers.js
8
8
 
9
+
9
10
  - History of individual helpers: https://github.com/babel/babel/commits/main/packages/babel-helpers/src/helpers
11
+
12
+
13
+ - All thoose file are inlines versions of babel helpers declared in: https://github.com/babel/babel/blob/main/packages/babel-helpers/src/helpers.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "23.8.20",
3
+ "version": "23.11.1",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,11 +29,11 @@
29
29
  ],
30
30
  "scripts": {
31
31
  "eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs,.cjs,.html",
32
- "generate-importmap": "node ./script/importmap/generate_importmap.js",
32
+ "importmap-generate": "node ./script/importmap/generate_importmap.js",
33
33
  "build": "node ./script/build/build.js",
34
34
  "dist": "npm run build",
35
35
  "test": "node --experimental-import-meta-resolve ./script/test/test.js",
36
- "start-exploring": "node ./script/start-exploring/start-exploring.js",
36
+ "dev": "node ./script/dev/start_dev_server.js",
37
37
  "test-with-coverage": "npm run test -- --coverage",
38
38
  "test-js-transform": "node ./script/test/test-js-transform.js",
39
39
  "test-compile-server": "node ./script/test/test-compile-server.js",
@@ -42,81 +42,80 @@
42
42
  "test-launch-browser": "node ./script/test/test-launch-browser.js",
43
43
  "test-launch-node": "node ./script/test/test-launch-node.js",
44
44
  "measure-performances": "node --expose-gc ./script/performance/generate_performance_report.js --log --once",
45
- "prettier-format": "node ./script/prettier/prettier_format.mjs",
46
- "prettier-format-stage": "npm run prettier-format -- --staged",
47
- "prettier-check": "npm run prettier-format -- --dry-run",
45
+ "prettier-check": "prettier --check .",
46
+ "prettier-write": "prettier --write .",
48
47
  "playwright-install": "npx playwright install-deps && npx playwright install",
49
48
  "packages-install": "node ./script/packages/packages_install.js",
50
49
  "prepublishOnly": "node ./script/publish/remove_postinstall.mjs && npm run dist",
51
50
  "postpublish": "node ./script/publish/restore_postinstall.mjs"
52
51
  },
53
- "peerDependencies": {
52
+ "optionalDependencies": {
54
53
  "playwright": "1.x"
55
54
  },
56
55
  "dependencies": {
57
56
  "@babel/core": "7.16.0",
58
- "@babel/helper-module-imports": "7.15.4",
59
- "@babel/helpers": "7.15.4",
60
- "@babel/parser": "7.15.8",
61
- "@babel/plugin-proposal-dynamic-import": "7.14.5",
57
+ "@babel/helper-module-imports": "7.16.0",
58
+ "@babel/helpers": "7.16.3",
59
+ "@babel/parser": "7.16.4",
60
+ "@babel/plugin-proposal-dynamic-import": "7.16.0",
62
61
  "@babel/plugin-syntax-dynamic-import": "7.8.3",
63
- "@babel/plugin-syntax-import-assertions": "7.14.5",
62
+ "@babel/plugin-syntax-import-assertions": "7.16.0",
64
63
  "@babel/plugin-syntax-import-meta": "7.10.4",
65
64
  "@babel/plugin-syntax-numeric-separator": "7.10.4",
66
- "@babel/plugin-transform-modules-systemjs": "7.15.4",
65
+ "@babel/plugin-transform-modules-systemjs": "7.16.0",
67
66
  "@c88/v8-coverage": "0.1.1",
68
67
  "@jsenv/abort": "4.1.1",
69
68
  "@jsenv/filesystem": "2.5.1",
70
69
  "@jsenv/importmap": "1.2.0",
71
70
  "@jsenv/log": "1.4.0",
72
71
  "@jsenv/logger": "4.0.1",
73
- "@jsenv/server": "10.1.6",
72
+ "@jsenv/server": "12.0.0",
74
73
  "@jsenv/uneval": "1.6.0",
75
- "@rollup/plugin-commonjs": "21.0.0",
74
+ "@rollup/plugin-commonjs": "21.0.1",
76
75
  "@rollup/plugin-json": "4.1.0",
77
- "@rollup/plugin-node-resolve": "13.0.5",
76
+ "@rollup/plugin-node-resolve": "13.0.6",
78
77
  "@rollup/plugin-replace": "3.0.0",
79
78
  "acorn-import-assertions": "1.8.0",
80
79
  "ansi-to-html": "0.7.2",
81
- "bytes": "3.1.0",
80
+ "bytes": "3.1.1",
82
81
  "cjs-module-lexer": "1.2.2",
83
82
  "construct-style-sheets-polyfill": "3.0.4",
84
- "cssnano": "5.0.9",
85
- "cssnano-preset-default": "5.1.5",
83
+ "cssnano": "5.0.11",
84
+ "cssnano-preset-default": "5.1.7",
86
85
  "cuid": "2.1.8",
87
86
  "estree-walker": "3.0.0",
88
87
  "html-minifier": "4.0.0",
89
88
  "humanize-duration": "3.27.0",
90
89
  "is-valid-identifier": "2.0.2",
91
- "istanbul-lib-coverage": "3.0.2",
92
- "istanbul-lib-instrument": "5.0.3",
90
+ "istanbul-lib-coverage": "3.2.0",
91
+ "istanbul-lib-instrument": "5.1.0",
93
92
  "istanbul-lib-report": "3.0.0",
94
93
  "istanbul-reports": "3.0.5",
95
94
  "magic-string": "0.25.7",
96
95
  "parse5": "6.0.1",
97
96
  "pidtree": "0.5.0",
98
- "postcss": "8.3.9",
97
+ "postcss": "8.3.11",
99
98
  "postcss-value-parser": "4.1.0",
100
99
  "regenerator-runtime": "0.13.9",
101
100
  "resolve": "1.20.0",
102
- "rollup": "2.58.0",
101
+ "rollup": "2.60.0",
103
102
  "rollup-plugin-node-builtins-brofs": "2.1.3",
104
103
  "rollup-plugin-node-globals": "1.4.0",
105
104
  "rollup-plugin-polyfill-node": "0.7.0",
106
105
  "source-map": "0.7.3",
107
106
  "systemjs": "6.11.0",
108
- "terser": "5.9.0",
107
+ "terser": "5.10.0",
109
108
  "v8-to-istanbul": "8.1.0",
110
- "vm2": "3.9.4",
109
+ "vm2": "3.9.5",
111
110
  "wrap-ansi": "8.0.1"
112
111
  },
113
112
  "devDependencies": {
114
- "@babel/eslint-parser": "7.16.0",
115
- "@babel/plugin-syntax-jsx": "7.14.5",
116
- "@babel/plugin-transform-block-scoping": "7.15.3",
117
- "@babel/plugin-transform-react-jsx": "7.14.9",
118
- "@babel/plugin-transform-typescript": "7.15.8",
119
- "@babel/preset-env": "7.15.8",
113
+ "@babel/eslint-parser": "7.16.3",
114
+ "@babel/plugin-syntax-jsx": "7.16.0",
115
+ "@babel/plugin-transform-block-scoping": "7.16.0",
116
+ "@babel/plugin-transform-react-jsx": "7.16.0",
117
+ "@babel/plugin-transform-typescript": "7.16.1",
118
+ "@babel/preset-env": "7.16.4",
120
119
  "@jsenv/assert": "2.3.2",
121
120
  "@jsenv/babel-preset": "./packages/jsenv-babel-preset",
122
121
  "@jsenv/eslint-config": "16.0.9",
@@ -126,14 +125,14 @@
126
125
  "@jsenv/importmap-node-module": "2.7.1",
127
126
  "@jsenv/package-publish": "1.6.2",
128
127
  "@jsenv/performance-impact": "2.2.1",
129
- "@jsenv/prettier-check-project": "5.6.1",
130
128
  "@jsenv/pwa": "4.0.0",
131
129
  "babel-plugin-transform-async-to-promises": "0.8.15",
132
130
  "eslint": "7.32.0",
133
131
  "eslint-plugin-html": "6.2.0",
134
- "eslint-plugin-import": "2.25.2",
135
- "eslint-plugin-react": "7.26.1",
132
+ "eslint-plugin-import": "2.25.3",
133
+ "eslint-plugin-react": "7.27.1",
136
134
  "node-notifier": "10.0.0",
135
+ "playwright": "1.16.3",
137
136
  "preact": "10.5.15",
138
137
  "prettier": "2.4.1",
139
138
  "react": "17.0.2",
@@ -67,6 +67,7 @@ export const buildProject = async ({
67
67
  // in that case the returned buildImportMap must be injected into an html file
68
68
  useImportMapToMaximizeCacheReuse,
69
69
  preserveEntrySignatures,
70
+ treeshake,
70
71
 
71
72
  minify = process.env.NODE_ENV === "production",
72
73
  // https://github.com/kangax/html-minifier#options-quick-reference
@@ -222,6 +223,7 @@ export const buildProject = async ({
222
223
  lineBreakNormalization,
223
224
  useImportMapToMaximizeCacheReuse,
224
225
  preserveEntrySignatures,
226
+ treeshake,
225
227
  jsConcatenation,
226
228
 
227
229
  minify,
@@ -54,6 +54,7 @@ export const buildUsingRollup = async ({
54
54
  jsConcatenation,
55
55
  useImportMapToMaximizeCacheReuse,
56
56
  preserveEntrySignatures,
57
+ treeshake,
57
58
 
58
59
  minify,
59
60
  minifyJsOptions,
@@ -141,6 +142,7 @@ export const buildUsingRollup = async ({
141
142
  globalName,
142
143
  sourcemapExcludeSources,
143
144
  preserveEntrySignatures,
145
+ treeshake,
144
146
  // jsConcatenation,
145
147
  buildDirectoryUrl,
146
148
  buildDirectoryClean,
@@ -259,6 +261,7 @@ const useRollup = async ({
259
261
  globalName,
260
262
  sourcemapExcludeSources,
261
263
  preserveEntrySignatures,
264
+ treeshake,
262
265
  // jsConcatenation,
263
266
  buildDirectoryUrl,
264
267
  asOriginalUrl,
@@ -316,6 +319,7 @@ const useRollup = async ({
316
319
  // on fait cela car sinon rollup est pénible si on passe un entry point map de type html
317
320
  input: [],
318
321
  preserveEntrySignatures,
322
+ treeshake,
319
323
  plugins: [jsenvRollupPlugin],
320
324
  acornInjectPlugins: [importAssertions],
321
325
  }
@@ -1,7 +1,7 @@
1
- import { urlToFileSystemPath } from "@jsenv/filesystem"
1
+ import { urlToFileSystemPath, readFile } from "@jsenv/filesystem"
2
2
  import { createDetailedMessage } from "@jsenv/logger"
3
3
  import { timeStart, timeFunction } from "@jsenv/server"
4
- import { readFileContent } from "./fs-optimized-for-cache.js"
4
+
5
5
  import { validateCache } from "./validateCache.js"
6
6
  import { getMetaJsonFileUrl } from "./compile-asset.js"
7
7
  import { createLockRegistry } from "./createLockRegistry.js"
@@ -17,7 +17,6 @@ export const getOrGenerateCompiledFile = async ({
17
17
  compileCacheStrategy,
18
18
  compileCacheSourcesValidation,
19
19
  compileCacheAssetsValidation,
20
- fileContentFallback,
21
20
  request,
22
21
  compile,
23
22
  }) => {
@@ -65,7 +64,6 @@ export const getOrGenerateCompiledFile = async ({
65
64
  originalFileUrl,
66
65
  compiledFileUrl,
67
66
  compile,
68
- fileContentFallback,
69
67
  compileCacheStrategy,
70
68
  compileCacheSourcesValidation,
71
69
  compileCacheAssetsValidation,
@@ -94,7 +92,6 @@ const computeCompileReport = async ({
94
92
  originalFileUrl,
95
93
  compiledFileUrl,
96
94
  compile,
97
- fileContentFallback,
98
95
  compileCacheStrategy,
99
96
  compileCacheSourcesValidation,
100
97
  compileCacheAssetsValidation,
@@ -136,7 +133,6 @@ const computeCompileReport = async ({
136
133
  callCompile({
137
134
  logger,
138
135
  originalFileUrl,
139
- fileContentFallback,
140
136
  compile,
141
137
  }),
142
138
  )
@@ -174,22 +170,11 @@ const computeCompileReport = async ({
174
170
  }
175
171
  }
176
172
 
177
- const callCompile = async ({
178
- logger,
179
- originalFileUrl,
180
- fileContentFallback,
181
- compile,
182
- }) => {
173
+ const callCompile = async ({ logger, originalFileUrl, compile }) => {
183
174
  logger.debug(`compile ${originalFileUrl}`)
184
175
 
185
- const codeBeforeCompile =
186
- compile.length === 0
187
- ? ""
188
- : await getCodeToCompile({ originalFileUrl, fileContentFallback })
189
-
190
176
  const compileReturnValue = await compile({
191
- code: codeBeforeCompile,
192
- map: undefined,
177
+ code: await readFile(originalFileUrl),
193
178
  })
194
179
  if (typeof compileReturnValue !== "object" || compileReturnValue === null) {
195
180
  throw new TypeError(
@@ -229,24 +214,6 @@ const callCompile = async ({
229
214
  }
230
215
  }
231
216
 
232
- const getCodeToCompile = async ({ originalFileUrl, fileContentFallback }) => {
233
- let fileContent
234
- if (fileContentFallback) {
235
- try {
236
- fileContent = await readFileContent(originalFileUrl)
237
- } catch (e) {
238
- if (e.code === "ENOENT") {
239
- fileContent = await fileContentFallback()
240
- } else {
241
- throw e
242
- }
243
- }
244
- } else {
245
- fileContent = await readFileContent(originalFileUrl)
246
- }
247
- return fileContent
248
- }
249
-
250
217
  const startAsap = async (fn, { logger, compiledFileUrl }) => {
251
218
  const metaJsonFileUrl = getMetaJsonFileUrl(compiledFileUrl)
252
219
  const metaJsonFilePath = urlToFileSystemPath(metaJsonFileUrl)
@@ -16,7 +16,6 @@ export const compileFile = async ({
16
16
  projectDirectoryUrl,
17
17
  originalFileUrl,
18
18
  compiledFileUrl,
19
- fileContentFallback,
20
19
  projectFileRequestedCallback = () => {},
21
20
  request,
22
21
  pushResponse,
@@ -44,7 +43,6 @@ export const compileFile = async ({
44
43
  projectDirectoryUrl,
45
44
  originalFileUrl,
46
45
  compiledFileUrl,
47
- fileContentFallback,
48
46
  request,
49
47
  compileCacheStrategy,
50
48
  compileCacheSourcesValidation,
@@ -1,4 +1,4 @@
1
- import { redirectRequest, fetchFileSystem } from "@jsenv/server"
1
+ import { fetchFileSystem } from "@jsenv/server"
2
2
  import {
3
3
  resolveUrl,
4
4
  resolveDirectoryUrl,
@@ -80,7 +80,7 @@ export const createCompiledFileService = ({
80
80
  projectDirectoryUrl,
81
81
  )
82
82
 
83
- return (request, { pushResponse }) => {
83
+ return (request, { pushResponse, redirectRequest }) => {
84
84
  const { origin, ressource } = request
85
85
  // we use "ressourceToPathname" to remove eventual query param from the url
86
86
  // Without this a pattern like "**/*.js" would not match "file.js?t=1"
@@ -167,12 +167,11 @@ export const createCompiledFileService = ({
167
167
  projectFileRequestedCallback,
168
168
  request,
169
169
  pushResponse,
170
- compile: ({ code, map }) => {
170
+ compile: ({ code }) => {
171
171
  return compiler({
172
172
  logger,
173
173
 
174
174
  code,
175
- map,
176
175
  url: originalFileUrl,
177
176
  compiledUrl: compiledFileUrl,
178
177
  projectDirectoryUrl,
@@ -4,7 +4,7 @@ import {
4
4
  startServer,
5
5
  fetchFileSystem,
6
6
  createSSERoom,
7
- composeServicesWithTiming,
7
+ composeServices,
8
8
  urlToContentType,
9
9
  pluginServerTiming,
10
10
  pluginRequestWaitingCheck,
@@ -103,6 +103,7 @@ export const startCompileServer = async ({
103
103
  },
104
104
  livereloadLogLevel = "info",
105
105
  customServices = {},
106
+ serverPlugins,
106
107
  livereloadSSE = false,
107
108
  transformHtmlSourceFiles = true,
108
109
  jsenvToolbarInjection = false,
@@ -239,13 +240,14 @@ export const startCompileServer = async ({
239
240
  trackMainAndDependencies: sseSetup.trackMainAndDependencies,
240
241
  })
241
242
  customServices = {
242
- "service:sse": serveSSEForLivereload,
243
243
  ...customServices,
244
+ "service:sse": serveSSEForLivereload,
244
245
  }
245
246
  } else {
246
247
  const roomWhenLivereloadIsDisabled = createSSERoom()
247
248
  roomWhenLivereloadIsDisabled.open()
248
249
  customServices = {
250
+ ...customServices,
249
251
  "service:sse": (request) => {
250
252
  const { accept } = request.headers
251
253
  if (!accept || !accept.includes("text/event-stream")) {
@@ -253,7 +255,6 @@ export const startCompileServer = async ({
253
255
  }
254
256
  return roomWhenLivereloadIsDisabled.join(request)
255
257
  },
256
- ...customServices,
257
258
  }
258
259
  }
259
260
 
@@ -358,6 +359,7 @@ export const startCompileServer = async ({
358
359
  ip: compileServerIp,
359
360
  port: compileServerPort,
360
361
  plugins: {
362
+ ...serverPlugins,
361
363
  ...pluginCORS({
362
364
  accessControlAllowRequestOrigin: true,
363
365
  accessControlAllowRequestMethod: true,
@@ -368,12 +370,12 @@ export const startCompileServer = async ({
368
370
  ],
369
371
  accessControlAllowCredentials: true,
370
372
  }),
371
- ...pluginServerTiming,
373
+ ...pluginServerTiming(),
372
374
  ...pluginRequestWaitingCheck({
373
375
  requestWaitingMs: 60 * 1000,
374
376
  }),
375
377
  },
376
- requestToResponse: composeServicesWithTiming({
378
+ requestToResponse: composeServices({
377
379
  ...customServices,
378
380
  ...jsenvServices,
379
381
  }),
@@ -59,7 +59,7 @@ chromiumRuntime.launch = async ({
59
59
  })
60
60
  : chromiumSharing.getUniqueSharingToken()
61
61
  if (!sharingToken.isUsed()) {
62
- const { chromium } = await import("playwright")
62
+ const { chromium } = await importPlaywright({ browserName: "chromium" })
63
63
  const launchOperation = launchBrowser("chromium", {
64
64
  browserClass: chromium,
65
65
  launchBrowserOperation,
@@ -165,7 +165,7 @@ firefoxRuntime.launch = async ({
165
165
  ? firefoxSharing.getSharingToken({ firefoxExecutablePath, headless })
166
166
  : firefoxSharing.getUniqueSharingToken()
167
167
  if (!sharingToken.isUsed()) {
168
- const { firefox } = await import("playwright")
168
+ const { firefox } = await importPlaywright({ browserName: "firefox" })
169
169
  const launchOperation = launchBrowser("firefox", {
170
170
  browserClass: firefox,
171
171
 
@@ -244,7 +244,7 @@ webkitRuntime.launch = async ({
244
244
  : webkitSharing.getUniqueSharingToken()
245
245
 
246
246
  if (!sharingToken.isUsed()) {
247
- const { webkit } = await import("playwright")
247
+ const { webkit } = await await importPlaywright({ browserName: "webkit" })
248
248
  const launchOperation = launchBrowser("webkit", {
249
249
  browserClass: webkit,
250
250
  launchBrowserOperation,
@@ -349,6 +349,26 @@ const launchBrowser = async (
349
349
  }
350
350
  }
351
351
 
352
+ const importPlaywright = async ({ browserName }) => {
353
+ try {
354
+ const namespace = await import("playwright")
355
+ return namespace
356
+ } catch (e) {
357
+ if (e.code === "ERR_MODULE_NOT_FOUND") {
358
+ throw new Error(
359
+ createDetailedMessage(
360
+ `"playwright" not found. You need playwright in your dependencies when using "${browserName}Runtime"`,
361
+ {
362
+ suggestion: `npm install --save-dev playwright`,
363
+ },
364
+ ),
365
+ { cause: e },
366
+ )
367
+ }
368
+ throw e
369
+ }
370
+ }
371
+
352
372
  const stopBrowser = async (browser) => {
353
373
  const disconnected = browser.isConnected()
354
374
  ? new Promise((resolve) => {
@@ -49,7 +49,9 @@ export const startExploring = async ({
49
49
  compileServerCertificate,
50
50
  compileServerPrivateKey,
51
51
  sourcemapMethod,
52
+ customServices,
52
53
  customCompilers,
54
+ serverPlugins,
53
55
  livereloadWatchConfig,
54
56
  jsenvDirectoryClean,
55
57
  }) => {
@@ -87,11 +89,13 @@ export const startExploring = async ({
87
89
  livereloadSSE: livereloading,
88
90
  jsenvToolbarInjection: jsenvToolbar,
89
91
  customServices: {
92
+ ...customServices,
90
93
  "service:exploring-redirect": (request) => redirectFiles(request),
91
94
  "service:exploring-data": (request) => serveExploringData(request),
92
95
  "service:explorables": (request) => serveExplorableListAsJson(request),
93
96
  },
94
97
  customCompilers,
98
+ serverPlugins,
95
99
  jsenvDirectoryRelativeUrl,
96
100
  outDirectoryName,
97
101
  inlineImportMapIntoHTML,