@jsenv/core 29.9.2 → 30.0.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 (24) hide show
  1. package/dist/main.js +75 -940
  2. package/package.json +8 -8
  3. package/src/build/build.js +38 -28
  4. package/src/main.js +0 -2
  5. package/src/plugins/plugins.js +0 -7
  6. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_library.js +2 -2
  7. package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +5 -5
  8. package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +23 -3
  9. package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +5 -5
  10. package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +5 -5
  11. package/src/kitchen/file_url_converter.js +0 -21
  12. package/src/plugins/bundling/css/bundle_css.js +0 -140
  13. package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +0 -13
  14. package/src/plugins/bundling/js_module/bundle_js_modules.js +0 -424
  15. package/src/plugins/bundling/jsenv_plugin_bundling.js +0 -52
  16. package/src/plugins/inject_globals/inject_globals.js +0 -57
  17. package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +0 -36
  18. package/src/plugins/minification/css/minify_css.js +0 -9
  19. package/src/plugins/minification/html/minify_html.js +0 -13
  20. package/src/plugins/minification/js/minify_js.js +0 -31
  21. package/src/plugins/minification/jsenv_plugin_minification.js +0 -79
  22. package/src/plugins/minification/json/minify_json.js +0 -8
  23. package/src/plugins/placeholders/jsenv_plugin_placeholders.js +0 -36
  24. package/src/plugins/placeholders/replace_placeholders.js +0 -25
@@ -1,8 +0,0 @@
1
- export const minifyJson = ({ jsonUrlInfo }) => {
2
- const { content } = jsonUrlInfo
3
- if (content.startsWith("{\n")) {
4
- const jsonWithoutWhitespaces = JSON.stringify(JSON.parse(content))
5
- return jsonWithoutWhitespaces
6
- }
7
- return null
8
- }
@@ -1,36 +0,0 @@
1
- import { URL_META } from "@jsenv/url-meta"
2
- import { asUrlWithoutSearch } from "@jsenv/urls"
3
-
4
- import { replacePlaceholders } from "./replace_placeholders.js"
5
-
6
- export const jsenvPluginPlaceholders = (rawAssociations) => {
7
- let resolvedAssociations
8
-
9
- return {
10
- name: "jsenv:placeholders",
11
- appliesDuring: "*",
12
- init: (context) => {
13
- resolvedAssociations = URL_META.resolveAssociations(
14
- { replacer: rawAssociations },
15
- context.rootDirectoryUrl,
16
- )
17
- },
18
- transformUrlContent: async (urlInfo, context) => {
19
- const { replacer } = URL_META.applyAssociations({
20
- url: asUrlWithoutSearch(urlInfo.url),
21
- associations: resolvedAssociations,
22
- })
23
- if (!replacer) {
24
- return null
25
- }
26
- if (typeof replacer !== "function") {
27
- throw new TypeError("replacer must be a function")
28
- }
29
- const replacements = await replacer(urlInfo, context)
30
- if (!replacements || Object.keys(replacements).length === 0) {
31
- return null
32
- }
33
- return replacePlaceholders(urlInfo, replacements)
34
- },
35
- }
36
- }
@@ -1,25 +0,0 @@
1
- import { createMagicSource } from "@jsenv/sourcemap"
2
-
3
- export const replacePlaceholders = (urlInfo, replacements) => {
4
- const content = urlInfo.content
5
- const magicSource = createMagicSource(content)
6
- Object.keys(replacements).forEach((key) => {
7
- let index = content.indexOf(key)
8
- while (index !== -1) {
9
- const start = index
10
- const end = index + key.length
11
- magicSource.replace({
12
- start,
13
- end,
14
- replacement:
15
- urlInfo.type === "js_classic" ||
16
- urlInfo.type === "js_module" ||
17
- urlInfo.type === "html"
18
- ? JSON.stringify(replacements[key], null, " ")
19
- : replacements[key],
20
- })
21
- index = content.indexOf(key, end)
22
- }
23
- })
24
- return magicSource.toContentAndSourcemap()
25
- }