@jsenv/core 38.3.0 → 38.3.2

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/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # @jsenv/core [![npm package](https://img.shields.io/npm/v/@jsenv/core.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/core)
2
2
 
3
- Jsenv is a tool to develop test and build projects using JavaScript. Jsenv is simple, easy to understand and well documented.
4
-
5
- Jsenv cares a lot about the developper experience, especially when it comes to tests.
3
+ Jsenv is a tool to develop test and build projects using JavaScript. Jsenv encourages standards and simplicity.
6
4
 
7
5
  The pillars of jsenv are:
8
6
 
@@ -11,6 +9,9 @@ The pillars of jsenv are:
11
9
  3. A build server serving build files
12
10
  4. A test runner executing test files in web browser(s)
13
11
 
12
+ Jsenv cares a lot about the developer experience.
13
+ As a result it can be enjoyed by people without much experience in tooling or seeking for a simple tool without hidden complexities.
14
+
14
15
  [Link to documentation](<https://github.com/jsenv/core/wiki/A)-directory-structure>)
15
16
 
16
17
  # The best parts
@@ -1,37 +1,45 @@
1
1
  function _getRequireWildcardCache(nodeInterop) {
2
- if (typeof WeakMap !== "function") return null
3
- var cacheBabelInterop = new WeakMap()
4
- var cacheNodeInterop = new WeakMap()
2
+ if (typeof WeakMap !== "function") return null;
3
+
4
+ var cacheBabelInterop = new WeakMap();
5
+ var cacheNodeInterop = new WeakMap();
5
6
  return (_getRequireWildcardCache = function (nodeInterop) {
6
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop
7
- })(nodeInterop)
7
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
8
+ })(nodeInterop);
8
9
  }
10
+
9
11
  export default function _interopRequireWildcard(obj, nodeInterop) {
10
12
  if (!nodeInterop && obj && obj.__esModule) {
11
- return obj
13
+ return obj;
12
14
  }
15
+
13
16
  if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
14
- return { default: obj }
17
+ return { default: obj };
15
18
  }
16
- var cache = _getRequireWildcardCache(nodeInterop)
19
+
20
+ var cache = _getRequireWildcardCache(nodeInterop);
17
21
  if (cache && cache.has(obj)) {
18
- return cache.get(obj)
22
+ return cache.get(obj);
19
23
  }
20
- var newObj = {}
21
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor
24
+
25
+ var newObj = { __proto__: null };
26
+ var hasPropertyDescriptor =
27
+ Object.defineProperty && Object.getOwnPropertyDescriptor;
22
28
  for (var key in obj) {
23
29
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
24
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null
30
+ var desc = hasPropertyDescriptor
31
+ ? Object.getOwnPropertyDescriptor(obj, key)
32
+ : null;
25
33
  if (desc && (desc.get || desc.set)) {
26
- Object.defineProperty(newObj, key, desc)
34
+ Object.defineProperty(newObj, key, desc);
27
35
  } else {
28
- newObj[key] = obj[key]
36
+ newObj[key] = obj[key];
29
37
  }
30
38
  }
31
39
  }
32
- newObj.default = obj
40
+ newObj.default = obj;
33
41
  if (cache) {
34
- cache.set(obj, newObj)
42
+ cache.set(obj, newObj);
35
43
  }
36
- return newObj
37
- }
44
+ return newObj;
45
+ }
@@ -1,4 +1,9 @@
1
- // Note: This function returns "true" for core-js functions.
2
- export default function (fn) {
3
- return Function.toString.call(fn).indexOf("[native code]") !== -1
4
- }
1
+ export default function _isNativeFunction(fn) {
2
+ // Note: This function returns "true" for core-js functions.
3
+ try {
4
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
5
+ } catch (e) {
6
+ // Firefox 31 throws when "toString" is applied to an HTMLElement
7
+ return typeof fn === "function";
8
+ }
9
+ }
@@ -3245,8 +3245,7 @@ function isUnicodeSupported() {
3245
3245
  return process$1.env.TERM !== 'linux'; // Linux console (kernel)
3246
3246
  }
3247
3247
 
3248
- return Boolean(process$1.env.CI)
3249
- || Boolean(process$1.env.WT_SESSION) // Windows Terminal
3248
+ return Boolean(process$1.env.WT_SESSION) // Windows Terminal
3250
3249
  || Boolean(process$1.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
3251
3250
  || process$1.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
3252
3251
  || process$1.env.TERM_PROGRAM === 'Terminus-Sublime'
@@ -15759,22 +15758,39 @@ const jsenvPluginHtmlReferenceAnalysis = ({
15759
15758
 
15760
15759
  let globalImportmap = null;
15761
15760
  const importmaps = {};
15762
- const onImportmapParsed = (htmlUrl, importmap) => {
15763
- if (importmap) {
15764
- importmaps[htmlUrl] = normalizeImportMap(importmap, htmlUrl);
15765
- } else {
15766
- importmaps[htmlUrl] = null;
15767
- }
15768
- globalImportmap = Object.keys(importmaps).reduce((previous, url) => {
15769
- const importmap = importmaps[url];
15770
- if (!previous) {
15771
- return importmap;
15761
+ let importmapLoadingCount = 0;
15762
+ const allImportmapLoadedCallbackSet = new Set();
15763
+ const startLoadingImportmap = (htmlUrlInfo) => {
15764
+ importmapLoadingCount++;
15765
+ return (importmapUrlInfo) => {
15766
+ const htmlUrl = htmlUrlInfo.url;
15767
+ if (importmapUrlInfo) {
15768
+ // importmap was found in this HTML file and is known
15769
+ const importmap = JSON.parse(importmapUrlInfo.content);
15770
+ importmaps[htmlUrl] = normalizeImportMap(importmap, htmlUrl);
15771
+ } else {
15772
+ // no importmap in this HTML file
15773
+ importmaps[htmlUrl] = null;
15772
15774
  }
15773
- if (!importmap) {
15774
- return previous;
15775
+ globalImportmap = Object.keys(importmaps).reduce((previous, url) => {
15776
+ const importmap = importmaps[url];
15777
+ if (!previous) {
15778
+ return importmap;
15779
+ }
15780
+ if (!importmap) {
15781
+ return previous;
15782
+ }
15783
+ return composeTwoImportMaps(previous, importmap);
15784
+ }, null);
15785
+
15786
+ importmapLoadingCount--;
15787
+ if (importmapLoadingCount === 0) {
15788
+ allImportmapLoadedCallbackSet.forEach((callback) => {
15789
+ callback();
15790
+ });
15791
+ allImportmapLoadedCallbackSet.clear();
15775
15792
  }
15776
- return composeTwoImportMaps(previous, importmap);
15777
- }, null);
15793
+ };
15778
15794
  };
15779
15795
 
15780
15796
  return {
@@ -15813,16 +15829,18 @@ const jsenvPluginHtmlReferenceAnalysis = ({
15813
15829
  },
15814
15830
  },
15815
15831
  transformUrlContent: {
15832
+ js_module: async () => {
15833
+ // wait for importmap if any
15834
+ // so that resolveReference can happen with importmap
15835
+ if (importmapLoadingCount) {
15836
+ await new Promise((resolve) => {
15837
+ allImportmapLoadedCallbackSet.add(resolve);
15838
+ });
15839
+ }
15840
+ },
15816
15841
  html: async (urlInfo) => {
15817
15842
  let importmapFound = false;
15818
- let importmapParsedCallbackSet = new Set();
15819
- const onImportmapReady = (importmap) => {
15820
- onImportmapParsed(urlInfo.url, importmap);
15821
- importmapParsedCallbackSet.forEach((callback) => {
15822
- callback();
15823
- });
15824
- importmapParsedCallbackSet.clear();
15825
- };
15843
+ const importmapLoaded = startLoadingImportmap(urlInfo);
15826
15844
 
15827
15845
  const content = urlInfo.content;
15828
15846
  const htmlAst = parseHtmlString(content);
@@ -15962,11 +15980,6 @@ const jsenvPluginHtmlReferenceAnalysis = ({
15962
15980
  });
15963
15981
 
15964
15982
  actions.push(async () => {
15965
- if (expectedType === "js_module" && importmapFound) {
15966
- await new Promise((resolve) => {
15967
- importmapParsedCallbackSet.add(resolve);
15968
- });
15969
- }
15970
15983
  await inlineReference.urlInfo.cook();
15971
15984
  mutations.push(() => {
15972
15985
  if (hotAccept) {
@@ -16078,7 +16091,7 @@ const jsenvPluginHtmlReferenceAnalysis = ({
16078
16091
  importmapReferenceInlined.urlInfo;
16079
16092
  actions.push(async () => {
16080
16093
  await importmapInlineUrlInfo.cook();
16081
- onImportmapReady(JSON.parse(importmapInlineUrlInfo.content));
16094
+ importmapLoaded(importmapInlineUrlInfo);
16082
16095
  mutations.push(() => {
16083
16096
  setHtmlNodeText(
16084
16097
  scriptNode,
@@ -16109,9 +16122,7 @@ const jsenvPluginHtmlReferenceAnalysis = ({
16109
16122
  const inlineImportmapUrlInfo = importmapReference.urlInfo;
16110
16123
  actions.push(async () => {
16111
16124
  await inlineImportmapUrlInfo.cook();
16112
- onImportmapReady(
16113
- JSON.parse(inlineImportmapUrlInfo.content),
16114
- );
16125
+ importmapLoaded(inlineImportmapUrlInfo);
16115
16126
  mutations.push(() => {
16116
16127
  setHtmlNodeText(
16117
16128
  scriptNode,
@@ -16227,7 +16238,7 @@ const jsenvPluginHtmlReferenceAnalysis = ({
16227
16238
  },
16228
16239
  });
16229
16240
  if (!importmapFound) {
16230
- onImportmapReady();
16241
+ importmapLoaded();
16231
16242
  }
16232
16243
  finalizeCallbacks.forEach((finalizeCallback) => {
16233
16244
  finalizeCallback();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "38.3.0",
3
+ "version": "38.3.2",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -44,14 +44,16 @@
44
44
  "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
45
45
  "dev": "node --conditions=development ./scripts/dev/dev.mjs",
46
46
  "test": "node --conditions=development ./scripts/test/test.mjs",
47
- "test:packages": "npm run test --workspaces --if-present -- --workspace",
48
47
  "snapshots:core": "npm run test -- --no-snapshot-assertion",
49
48
  "snapshots:packages": "npm run test --workspaces --if-present -- --workspace --no-snapshot-assertion",
50
49
  "snapshots:only_dev_server_errors": "node --conditions=development ./tests/dev_server/errors/generate_snapshot_files.mjs",
50
+ "workspace:test": "npm run test --workspaces --if-present -- --workspace",
51
51
  "build": "node --conditions=development ./scripts/build/build.mjs",
52
52
  "build:file_size": "node ./scripts/build/build_file_size.mjs --log",
53
- "workspace:versions": "node ./scripts/publish/workspace_versions.mjs",
54
- "workspace:publish": "node ./scripts/publish/workspace_publish.mjs",
53
+ "workspace:build": "npm run build --workspaces --if-present",
54
+ "monorepo:upgrade_versions": "node ./scripts/monorepo/upgrade_external_versions.mjs",
55
+ "monorepo:sync_packages_versions": "node ./scripts/monorepo/sync_packages_versions.mjs",
56
+ "monorepo:publish": "node ./scripts/monorepo/publish_packages.mjs",
55
57
  "performances": "node --expose-gc ./scripts/performance/generate_performance_report.mjs --log --once",
56
58
  "prettier": "prettier --write .",
57
59
  "playwright:install": "npx playwright install-deps && npx playwright install",
@@ -61,20 +63,20 @@
61
63
  "dependencies": {
62
64
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
63
65
  "@jsenv/abort": "4.2.4",
64
- "@jsenv/ast": "5.2.0",
66
+ "@jsenv/ast": "5.2.1",
65
67
  "@jsenv/filesystem": "4.3.2",
66
68
  "@jsenv/importmap": "1.2.1",
67
69
  "@jsenv/integrity": "0.0.1",
68
- "@jsenv/js-module-fallback": "1.3.6",
69
- "@jsenv/log": "3.4.1",
70
+ "@jsenv/js-module-fallback": "1.3.7",
71
+ "@jsenv/log": "3.4.2",
70
72
  "@jsenv/node-esm-resolution": "1.0.1",
71
- "@jsenv/plugin-bundling": "2.5.7",
72
- "@jsenv/plugin-minification": "1.5.3",
73
- "@jsenv/plugin-supervisor": "1.3.6",
74
- "@jsenv/plugin-transpilation": "1.3.5",
73
+ "@jsenv/plugin-bundling": "2.5.8",
74
+ "@jsenv/plugin-minification": "1.5.4",
75
+ "@jsenv/plugin-supervisor": "1.3.7",
76
+ "@jsenv/plugin-transpilation": "1.3.6",
75
77
  "@jsenv/runtime-compat": "1.2.0",
76
- "@jsenv/server": "15.1.4",
77
- "@jsenv/sourcemap": "1.2.3",
78
+ "@jsenv/server": "15.1.5",
79
+ "@jsenv/sourcemap": "1.2.4",
78
80
  "@jsenv/url-meta": "8.1.0",
79
81
  "@jsenv/urls": "2.2.1",
80
82
  "@jsenv/utils": "2.0.1"
@@ -87,12 +89,12 @@
87
89
  "@jsenv/eslint-config": "./packages/independent/eslint-config/",
88
90
  "@jsenv/file-size-impact": "14.1.3",
89
91
  "@jsenv/https-local": "3.0.7",
90
- "@jsenv/package-workspace": "0.5.3",
92
+ "@jsenv/monorepo": "0.0.2",
91
93
  "@jsenv/performance-impact": "4.1.3",
92
94
  "@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
93
95
  "@jsenv/test": "./packages/related/test/",
94
96
  "babel-plugin-transform-async-to-promises": "0.8.18",
95
- "eslint": "8.52.0",
97
+ "eslint": "8.53.0",
96
98
  "eslint-plugin-html": "7.1.0",
97
99
  "eslint-plugin-import": "2.29.0",
98
100
  "eslint-plugin-react": "7.33.2",
@@ -45,22 +45,39 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
45
45
 
46
46
  let globalImportmap = null;
47
47
  const importmaps = {};
48
- const onImportmapParsed = (htmlUrl, importmap) => {
49
- if (importmap) {
50
- importmaps[htmlUrl] = normalizeImportMap(importmap, htmlUrl);
51
- } else {
52
- importmaps[htmlUrl] = null;
53
- }
54
- globalImportmap = Object.keys(importmaps).reduce((previous, url) => {
55
- const importmap = importmaps[url];
56
- if (!previous) {
57
- return importmap;
48
+ let importmapLoadingCount = 0;
49
+ const allImportmapLoadedCallbackSet = new Set();
50
+ const startLoadingImportmap = (htmlUrlInfo) => {
51
+ importmapLoadingCount++;
52
+ return (importmapUrlInfo) => {
53
+ const htmlUrl = htmlUrlInfo.url;
54
+ if (importmapUrlInfo) {
55
+ // importmap was found in this HTML file and is known
56
+ const importmap = JSON.parse(importmapUrlInfo.content);
57
+ importmaps[htmlUrl] = normalizeImportMap(importmap, htmlUrl);
58
+ } else {
59
+ // no importmap in this HTML file
60
+ importmaps[htmlUrl] = null;
58
61
  }
59
- if (!importmap) {
60
- return previous;
62
+ globalImportmap = Object.keys(importmaps).reduce((previous, url) => {
63
+ const importmap = importmaps[url];
64
+ if (!previous) {
65
+ return importmap;
66
+ }
67
+ if (!importmap) {
68
+ return previous;
69
+ }
70
+ return composeTwoImportMaps(previous, importmap);
71
+ }, null);
72
+
73
+ importmapLoadingCount--;
74
+ if (importmapLoadingCount === 0) {
75
+ allImportmapLoadedCallbackSet.forEach((callback) => {
76
+ callback();
77
+ });
78
+ allImportmapLoadedCallbackSet.clear();
61
79
  }
62
- return composeTwoImportMaps(previous, importmap);
63
- }, null);
80
+ };
64
81
  };
65
82
 
66
83
  return {
@@ -99,16 +116,18 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
99
116
  },
100
117
  },
101
118
  transformUrlContent: {
119
+ js_module: async () => {
120
+ // wait for importmap if any
121
+ // so that resolveReference can happen with importmap
122
+ if (importmapLoadingCount) {
123
+ await new Promise((resolve) => {
124
+ allImportmapLoadedCallbackSet.add(resolve);
125
+ });
126
+ }
127
+ },
102
128
  html: async (urlInfo) => {
103
129
  let importmapFound = false;
104
- let importmapParsedCallbackSet = new Set();
105
- const onImportmapReady = (importmap) => {
106
- onImportmapParsed(urlInfo.url, importmap);
107
- importmapParsedCallbackSet.forEach((callback) => {
108
- callback();
109
- });
110
- importmapParsedCallbackSet.clear();
111
- };
130
+ const importmapLoaded = startLoadingImportmap(urlInfo);
112
131
 
113
132
  const content = urlInfo.content;
114
133
  const htmlAst = parseHtmlString(content);
@@ -248,11 +267,6 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
248
267
  });
249
268
 
250
269
  actions.push(async () => {
251
- if (expectedType === "js_module" && importmapFound) {
252
- await new Promise((resolve) => {
253
- importmapParsedCallbackSet.add(resolve);
254
- });
255
- }
256
270
  await inlineReference.urlInfo.cook();
257
271
  mutations.push(() => {
258
272
  if (hotAccept) {
@@ -366,7 +380,7 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
366
380
  importmapReferenceInlined.urlInfo;
367
381
  actions.push(async () => {
368
382
  await importmapInlineUrlInfo.cook();
369
- onImportmapReady(JSON.parse(importmapInlineUrlInfo.content));
383
+ importmapLoaded(importmapInlineUrlInfo);
370
384
  mutations.push(() => {
371
385
  setHtmlNodeText(
372
386
  scriptNode,
@@ -397,9 +411,7 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
397
411
  const inlineImportmapUrlInfo = importmapReference.urlInfo;
398
412
  actions.push(async () => {
399
413
  await inlineImportmapUrlInfo.cook();
400
- onImportmapReady(
401
- JSON.parse(inlineImportmapUrlInfo.content),
402
- );
414
+ importmapLoaded(inlineImportmapUrlInfo);
403
415
  mutations.push(() => {
404
416
  setHtmlNodeText(
405
417
  scriptNode,
@@ -515,7 +527,7 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
515
527
  },
516
528
  });
517
529
  if (!importmapFound) {
518
- onImportmapReady();
530
+ importmapLoaded();
519
531
  }
520
532
  finalizeCallbacks.forEach((finalizeCallback) => {
521
533
  finalizeCallback();