@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.
- package/dist/main.js +75 -940
- package/package.json +8 -8
- package/src/build/build.js +38 -28
- package/src/main.js +0 -2
- package/src/plugins/plugins.js +0 -7
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_library.js +2 -2
- package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +5 -5
- package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +23 -3
- package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +5 -5
- package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +5 -5
- package/src/kitchen/file_url_converter.js +0 -21
- package/src/plugins/bundling/css/bundle_css.js +0 -140
- package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +0 -13
- package/src/plugins/bundling/js_module/bundle_js_modules.js +0 -424
- package/src/plugins/bundling/jsenv_plugin_bundling.js +0 -52
- package/src/plugins/inject_globals/inject_globals.js +0 -57
- package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +0 -36
- package/src/plugins/minification/css/minify_css.js +0 -9
- package/src/plugins/minification/html/minify_html.js +0 -13
- package/src/plugins/minification/js/minify_js.js +0 -31
- package/src/plugins/minification/jsenv_plugin_minification.js +0 -79
- package/src/plugins/minification/json/minify_json.js +0 -8
- package/src/plugins/placeholders/jsenv_plugin_placeholders.js +0 -36
- package/src/plugins/placeholders/replace_placeholders.js +0 -25
|
@@ -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
|
-
}
|