@jsenv/core 27.0.0-alpha.25 → 27.0.0-alpha.28

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": "27.0.0-alpha.25",
3
+ "version": "27.0.0-alpha.28",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "@jsenv/node-esm-resolution": "0.0.4",
67
67
  "@jsenv/server": "12.6.1",
68
68
  "@jsenv/uneval": "1.6.0",
69
- "@jsenv/utils": "1.4.1",
69
+ "@jsenv/utils": "1.4.2",
70
70
  "construct-style-sheets-polyfill": "3.1.0",
71
71
  "cssnano": "5.1.7",
72
72
  "cssnano-preset-default": "5.2.7",
@@ -91,12 +91,12 @@
91
91
  "@jsenv/assert": "2.5.4",
92
92
  "@jsenv/eslint-config": "16.0.9",
93
93
  "@jsenv/file-size-impact": "12.1.11",
94
- "@jsenv/github-release-package": "1.3.6",
94
+ "@jsenv/github-release-package": "1.4.0",
95
95
  "@jsenv/https-local": "1.0.8",
96
96
  "@jsenv/importmap-node-module": "5.1.3",
97
97
  "@jsenv/package-workspace": "0.0.5",
98
98
  "@jsenv/performance-impact": "2.2.10",
99
- "@jsenv/pwa": "4.0.1",
99
+ "@jsenv/pwa": "5.0.0",
100
100
  "eslint": "8.13.0",
101
101
  "eslint-plugin-html": "6.2.0",
102
102
  "eslint-plugin-import": "2.26.0",
@@ -22,7 +22,7 @@ const createUrlGraphReport = (urlGraph) => {
22
22
  html: 0,
23
23
  css: 0,
24
24
  js: 0,
25
- assets: 0,
25
+ other: 0,
26
26
  sourcemaps: 0,
27
27
  total: 0,
28
28
  }
@@ -31,7 +31,7 @@ const createUrlGraphReport = (urlGraph) => {
31
31
  css: 0,
32
32
  js: 0,
33
33
  sourcemaps: 0,
34
- assets: 0,
34
+ other: 0,
35
35
  total: 0,
36
36
  }
37
37
  Object.keys(urlInfos).forEach((url) => {
@@ -81,8 +81,8 @@ const createUrlGraphReport = (urlGraph) => {
81
81
  sizeGroups.js += urlContentSize
82
82
  return
83
83
  }
84
- countGroups.assets++
85
- sizeGroups.assets += urlContentSize
84
+ countGroups.other++
85
+ sizeGroups.other += urlContentSize
86
86
  return
87
87
  })
88
88
  return {
@@ -90,7 +90,7 @@ const createUrlGraphReport = (urlGraph) => {
90
90
  css: { count: countGroups.css, size: sizeGroups.css },
91
91
  js: { count: countGroups.js, size: sizeGroups.js },
92
92
  sourcemaps: { count: countGroups.sourcemaps, size: sizeGroups.sourcemaps },
93
- assets: { count: countGroups.assets, size: sizeGroups.assets },
93
+ other: { count: countGroups.other, size: sizeGroups.other },
94
94
  total: { count: countGroups.total, size: sizeGroups.total },
95
95
  }
96
96
  }
@@ -108,10 +108,10 @@ const determineCategory = (urlInfo) => {
108
108
  if (urlInfo.type === "js_module" || urlInfo.type === "js_classic") {
109
109
  return "js"
110
110
  }
111
- return "assets"
111
+ return "other"
112
112
  }
113
113
 
114
- const createRepartitionMessage = ({ html, css, js, assets }) => {
114
+ const createRepartitionMessage = ({ html, css, js, other }) => {
115
115
  const parts = []
116
116
  if (html.count) {
117
117
  parts.push(
@@ -141,10 +141,10 @@ const createRepartitionMessage = ({ html, css, js, assets }) => {
141
141
  // } (${byteAsFileSize(sourcemaps.size)})`,
142
142
  // )
143
143
  // }
144
- if (assets.count) {
144
+ if (other.count) {
145
145
  parts.push(
146
- `${ANSI.color(`assets:`, ANSI.GREY)} ${assets.count} (${byteAsFileSize(
147
- assets.size,
146
+ `${ANSI.color(`other:`, ANSI.GREY)} ${other.count} (${byteAsFileSize(
147
+ other.size,
148
148
  )})`,
149
149
  )
150
150
  }
@@ -244,7 +244,10 @@ const willBeInsideJsDirectory = ({
244
244
  // generated by rollup
245
245
  return true
246
246
  }
247
- if (!jsModuleUrlInfo.data.isEntryPoint) {
247
+ if (
248
+ !jsModuleUrlInfo.data.isEntryPoint &&
249
+ !jsModuleUrlInfo.data.isWebWorkerEntryPoint
250
+ ) {
248
251
  // not an entry point, jsenv will put it inside js/ directory
249
252
  return true
250
253
  }
@@ -49,13 +49,16 @@ const asJsClassic = ({ systemJsInjection, systemJsClientFileUrl }) => {
49
49
  appliesDuring: "*",
50
50
  // forward ?as_js_classic to referenced urls
51
51
  normalizeUrl: (reference, context) => {
52
- if (reference.isInline) {
53
- if (reference.contentType !== "text/javascript") {
54
- // We want to propagate transformation of js module to js classic
55
- // so we don't want to propagate when the reference is not js:
56
- // - ignore "string" in `JSON.parse(string)` for instance
57
- return null
58
- }
52
+ // We want to propagate transformation of js module to js classic
53
+ // but only for import specifier (static/dynamic import + re-export)
54
+ // All other references won't get the ?as_js_classic
55
+ // otherwise we could try to transform inline ressources, specifiers inside new URL(). ...
56
+ if (
57
+ reference.type !== "js_import_export" &&
58
+ reference.subtype !== "system_register_arg" &&
59
+ reference.subtype !== "system_import_arg"
60
+ ) {
61
+ return null
59
62
  }
60
63
  const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
61
64
  if (
@@ -25,6 +25,7 @@ export const jsenvPluginWorkersTypeModuleAsClassic = ({
25
25
  babelPluginMetadataWorkerMentions,
26
26
  {
27
27
  workersToTranspile,
28
+ isJsModule: urlInfo.type === "js_module",
28
29
  },
29
30
  ],
30
31
  ],
@@ -101,7 +102,10 @@ const getWorkersToTranspile = (urlInfo, context) => {
101
102
  return { worker, serviceWorker, sharedWorker }
102
103
  }
103
104
 
104
- const babelPluginMetadataWorkerMentions = (_, { workersToTranspile }) => {
105
+ const babelPluginMetadataWorkerMentions = (
106
+ _,
107
+ { workersToTranspile, isJsModule },
108
+ ) => {
105
109
  return {
106
110
  name: "metadata-worker-mentions",
107
111
  visitor: {
@@ -110,7 +114,9 @@ const babelPluginMetadataWorkerMentions = (_, { workersToTranspile }) => {
110
114
  const visitors = {
111
115
  NewExpression: (path) => {
112
116
  if (workersToTranspile.worker || workersToTranspile.sharedWorker) {
113
- const mentions = analyzeNewWorkerOrNewSharedWorker(path)
117
+ const mentions = analyzeNewWorkerOrNewSharedWorker(path, {
118
+ isJsModule,
119
+ })
114
120
  if (mentions) {
115
121
  workerMentions.push(...mentions)
116
122
  }
@@ -18,10 +18,7 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
18
18
  const isWebWorker = isWebWorkerUrlInfo(urlInfo)
19
19
  const { metadata } = await applyBabelPlugins({
20
20
  babelPlugins: [
21
- [
22
- babelPluginMetadataJsUrlMentions,
23
- { isJsModule, isWebWorker, searchSystemJs: !isJsModule },
24
- ],
21
+ [babelPluginMetadataJsUrlMentions, { isJsModule, isWebWorker }],
25
22
  ],
26
23
  urlInfo,
27
24
  })
@@ -67,10 +64,7 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
67
64
  * https://github.com/mjackson/babel-plugin-import-visitor
68
65
  *
69
66
  */
70
- const babelPluginMetadataJsUrlMentions = (
71
- _,
72
- { isJsModule, isWebWorker, searchSystemJs },
73
- ) => {
67
+ const babelPluginMetadataJsUrlMentions = (_, { isJsModule, isWebWorker }) => {
74
68
  return {
75
69
  name: "metadata-js-mentions",
76
70
  visitor: {
@@ -112,17 +106,16 @@ const babelPluginMetadataJsUrlMentions = (
112
106
  },
113
107
  NewExpression: (path) => {
114
108
  callStaticAnalyzers(path, [
115
- analyzeNewWorkerOrNewSharedWorker,
116
- analyzeNewUrlCall,
109
+ (path) => analyzeNewWorkerOrNewSharedWorker(path, { isJsModule }),
110
+ (path) => analyzeNewUrlCall(path, { isJsModule }),
117
111
  ])
118
112
  },
119
113
  }
120
114
  const callExpressionStaticAnalysers = [
121
- ...(isJsModule ? [analyzeImportCall] : []),
115
+ ...(isJsModule
116
+ ? [analyzeImportCall]
117
+ : [analyzeSystemRegisterCall, analyzeSystemImportCall]),
122
118
  ...(isWebWorker ? [analyzeImportScriptCalls] : []),
123
- ...(searchSystemJs
124
- ? [analyzeSystemRegisterCall, analyzeSystemImportCall]
125
- : []),
126
119
  analyzeServiceWorkerRegisterCall,
127
120
  ]
128
121
  visitors.CallExpression = (path) => {