Restructure package files, add exports (#13530)
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
This commit is contained in:
1 parent
e132a9ba43
commit
31a796d32c
17 files changed
+232
-111
No files matched your search
@@ -5,13 +5,15 @@
|
||||
importScripts("lib/parsers-location.js");
|
||||
importScripts("https://unpkg.com/sw-toolbox@3.6.0/sw-toolbox.js");
|
||||
|
||||
const parsers = Object.keys(parsersLocation).map((file) => `lib/${file}`);
|
||||
const plugins = [
|
||||
...new Set(Object.values(parsersLocation).map((file) => `lib/${file}`)),
|
||||
];
|
||||
|
||||
toolbox.precache([
|
||||
// Scripts
|
||||
"lib/standalone.js",
|
||||
"lib/parsers-location.js",
|
||||
...parsers,
|
||||
...plugins,
|
||||
"playground.js",
|
||||
"https://unpkg.com/sw-toolbox@3.6.0/sw-toolbox.js",
|
||||
|
||||
|
||||
+10
-11
@@ -15,17 +15,16 @@ importScripts("lib/standalone.js");
|
||||
|
||||
// this is required to only load parsers when we need them
|
||||
const parsers = Object.create(null);
|
||||
for (const file in parsersLocation) {
|
||||
const { parsers: moduleParsers, property } = parsersLocation[file];
|
||||
const url = `lib/${file}`;
|
||||
for (const parserName of moduleParsers) {
|
||||
Object.defineProperty(parsers, parserName, {
|
||||
get() {
|
||||
importScriptOnce(url);
|
||||
return prettierPlugins[property].parsers[parserName];
|
||||
},
|
||||
});
|
||||
}
|
||||
for (const [parser, file] of Object.entries(parsersLocation)) {
|
||||
Object.defineProperty(parsers, parser, {
|
||||
get() {
|
||||
const url = `lib/${file}`;
|
||||
importScriptOnce(url);
|
||||
return Object.values(prettierPlugins).find((plugin) =>
|
||||
Object.hasOwn(plugin.parsers, parser)
|
||||
).parsers[parser];
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const docExplorerPlugin = {
|
||||
|
||||
Reference in new issue
Block a user