@jsenv/plugin-transpilation 1.0.0 → 1.2.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.
Files changed (25) hide show
  1. package/package.json +26 -26
  2. package/src/as_js_module/jsenv_plugin_as_js_module.js +14 -28
  3. package/src/babel/babel_helper_directory/README.md +1 -1
  4. package/src/babel/babel_helper_directory/babel_helpers/applyDecs2301/applyDecs2301.js +547 -528
  5. package/src/babel/babel_helper_directory/babel_helpers/applyDecs2305/applyDecs2305.js +681 -0
  6. package/src/babel/babel_plugin_structure.js +1 -1
  7. package/src/babel/jsenv_plugin_babel.js +91 -19
  8. package/src/babel/new_stylesheet/babel_plugin_new_stylesheet_injector.js +11 -135
  9. package/src/babel/new_stylesheet/constructable_stylesheet_usage.js +114 -0
  10. package/src/babel/new_stylesheet/new_stylesheet_client_file_url.js +4 -0
  11. package/src/babel/regenerator_runtime/babel_plugin_regenerator_runtime_injector.js +11 -35
  12. package/src/babel/regenerator_runtime/regenerator_runtime_client_file_url.js +4 -0
  13. package/src/babel/regenerator_runtime/regenerator_runtime_usage.js +23 -0
  14. package/src/babel/{polyfill_injection_in_babel_ast.js → side_effect_injection_in_babel_ast.js} +8 -8
  15. package/src/css/jsenv_plugin_css_transpilation.js +2 -2
  16. package/src/import_assertions/jsenv_plugin_import_assertions.js +39 -78
  17. package/src/import_meta_resolve/jsenv_plugin_import_meta_resolve.js +17 -13
  18. package/src/js_module_fallback/jsenv_plugin_js_module_conversion.js +56 -48
  19. package/src/js_module_fallback/jsenv_plugin_js_module_fallback.js +3 -38
  20. package/src/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js +63 -122
  21. package/src/js_module_fallback/jsenv_plugin_js_module_fallback_on_workers.js +15 -6
  22. package/src/babel/apply_js_transpilation.js +0 -74
  23. package/src/babel/global_this/babel_plugin_global_this_injector.js +0 -56
  24. package/src/babel/global_this/client/global_this_js_classic.js +0 -25
  25. package/src/babel/global_this/client/global_this_js_module.js +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-transpilation",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "TODO",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,35 +26,35 @@
26
26
  "@babel/plugin-proposal-optional-catch-binding": "7.18.6",
27
27
  "@babel/plugin-proposal-optional-chaining": "7.21.0",
28
28
  "@babel/plugin-proposal-unicode-property-regex": "7.18.6",
29
- "@babel/plugin-syntax-import-assertions": "7.20.0",
29
+ "@babel/plugin-syntax-import-assertions": "7.22.5",
30
30
  "@babel/plugin-syntax-object-rest-spread": "7.8.3",
31
31
  "@babel/plugin-syntax-optional-catch-binding": "7.8.3",
32
- "@babel/plugin-transform-arrow-functions": "7.21.5",
33
- "@babel/plugin-transform-block-scoped-functions": "7.18.6",
34
- "@babel/plugin-transform-block-scoping": "7.21.0",
35
- "@babel/plugin-transform-classes": "7.21.0",
36
- "@babel/plugin-transform-computed-properties": "7.21.5",
37
- "@babel/plugin-transform-destructuring": "7.21.3",
38
- "@babel/plugin-transform-dotall-regex": "7.18.6",
39
- "@babel/plugin-transform-duplicate-keys": "7.18.9",
40
- "@babel/plugin-transform-exponentiation-operator": "7.18.6",
41
- "@babel/plugin-transform-for-of": "7.21.5",
42
- "@babel/plugin-transform-function-name": "7.18.9",
43
- "@babel/plugin-transform-literals": "7.18.9",
44
- "@babel/plugin-transform-new-target": "7.22.3",
45
- "@babel/plugin-transform-object-super": "7.18.6",
46
- "@babel/plugin-transform-parameters": "7.22.3",
47
- "@babel/plugin-transform-regenerator": "7.21.5",
48
- "@babel/plugin-transform-shorthand-properties": "7.18.6",
49
- "@babel/plugin-transform-spread": "7.20.7",
50
- "@babel/plugin-transform-sticky-regex": "7.18.6",
51
- "@babel/plugin-transform-template-literals": "7.18.9",
52
- "@babel/plugin-transform-typeof-symbol": "7.18.9",
53
- "@babel/plugin-transform-unicode-regex": "7.18.6",
32
+ "@babel/plugin-transform-arrow-functions": "7.22.5",
33
+ "@babel/plugin-transform-block-scoped-functions": "7.22.5",
34
+ "@babel/plugin-transform-block-scoping": "7.22.5",
35
+ "@babel/plugin-transform-classes": "7.22.6",
36
+ "@babel/plugin-transform-computed-properties": "7.22.5",
37
+ "@babel/plugin-transform-destructuring": "7.22.5",
38
+ "@babel/plugin-transform-dotall-regex": "7.22.5",
39
+ "@babel/plugin-transform-duplicate-keys": "7.22.5",
40
+ "@babel/plugin-transform-exponentiation-operator": "7.22.5",
41
+ "@babel/plugin-transform-for-of": "7.22.5",
42
+ "@babel/plugin-transform-function-name": "7.22.5",
43
+ "@babel/plugin-transform-literals": "7.22.5",
44
+ "@babel/plugin-transform-new-target": "7.22.5",
45
+ "@babel/plugin-transform-object-super": "7.22.5",
46
+ "@babel/plugin-transform-parameters": "7.22.5",
47
+ "@babel/plugin-transform-regenerator": "7.22.5",
48
+ "@babel/plugin-transform-shorthand-properties": "7.22.5",
49
+ "@babel/plugin-transform-spread": "7.22.5",
50
+ "@babel/plugin-transform-sticky-regex": "7.22.5",
51
+ "@babel/plugin-transform-template-literals": "7.22.5",
52
+ "@babel/plugin-transform-typeof-symbol": "7.22.5",
53
+ "@babel/plugin-transform-unicode-regex": "7.22.5",
54
54
  "babel-plugin-transform-async-to-promises": "0.8.18",
55
55
  "construct-style-sheets-polyfill": "3.1.0",
56
- "@jsenv/ast": "4.0.3",
56
+ "@jsenv/ast": "5.0.0",
57
57
  "@jsenv/runtime-compat": "1.0.0",
58
- "lightningcss": "1.20.0"
58
+ "lightningcss": "1.21.5"
59
59
  }
60
60
  }
@@ -20,38 +20,24 @@ export const jsenvPluginAsJsModule = () => {
20
20
  redirectReference: (reference) => {
21
21
  if (reference.searchParams.has("as_js_module")) {
22
22
  reference.expectedType = "js_module";
23
- const filename = urlToFilename(reference.url);
24
- const [basename] = splitFileExtension(filename);
25
- reference.filename = `${basename}.mjs`;
23
+ if (!reference.filename) {
24
+ const filename = urlToFilename(reference.url);
25
+ const [basename] = splitFileExtension(filename);
26
+ reference.filename = `${basename}.mjs`;
27
+ }
26
28
  }
27
29
  },
28
- fetchUrlContent: async (urlInfo, context) => {
29
- const [jsClassicReference, jsClassicUrlInfo] =
30
- context.getWithoutSearchParam({
31
- urlInfo,
32
- context,
33
- searchParam: "as_js_module",
34
- // override the expectedType to "js_classic"
35
- // because when there is ?as_js_module it means the underlying resource
36
- // is js_classic
37
- expectedType: "js_classic",
38
- });
39
- if (!jsClassicReference) {
40
- return null;
41
- }
42
- await context.fetchUrlContent(jsClassicUrlInfo, {
43
- reference: jsClassicReference,
30
+ fetchUrlContent: async (urlInfo) => {
31
+ const jsClassicUrlInfo = urlInfo.getWithoutSearchParam("as_js_module", {
32
+ // override the expectedType to "js_classic"
33
+ // because when there is ?as_js_module it means the underlying resource
34
+ // is js_classic
35
+ expectedType: "js_classic",
44
36
  });
45
- if (context.dev) {
46
- context.referenceUtils.found({
47
- type: "js_import",
48
- subtype: jsClassicReference.subtype,
49
- specifier: jsClassicReference.url,
50
- expectedType: "js_classic",
51
- });
52
- } else if (context.build && jsClassicUrlInfo.dependents.size === 0) {
53
- context.urlGraph.deleteUrlInfo(jsClassicUrlInfo.url);
37
+ if (!jsClassicUrlInfo) {
38
+ return null;
54
39
  }
40
+ await jsClassicUrlInfo.fetchContent();
55
41
  const { content, sourcemap } = await convertJsClassicToJsModule({
56
42
  input: jsClassicUrlInfo.content,
57
43
  inputSourcemap: jsClassicUrlInfo.sourcemap,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Babel helpers are copied in there to properly appear in sourcemap.
4
4
 
5
- - Last sync date: 3 May 2023
5
+ - Last sync date: 9 June 2023
6
6
 
7
7
  - Helpers file: https://github.com/babel/babel/blob/main/packages/babel-helpers/src/helpers.ts
8
8
  - Individual helpers: https://github.com/babel/babel/tree/main/packages/babel-helpers/src/helpers