MCPcopy
hub / github.com/QwikDev/qwik / submoduleQwikLoader

Function submoduleQwikLoader

scripts/submodule-qwikloader.ts:19–67  ·  view source on GitHub ↗
(config: BuildConfig)

Source from the content-addressed store, hash-verified

17 * provides a utility function.
18 */
19export async function submoduleQwikLoader(config: BuildConfig) {
20 // Build the debug version first
21 await build({
22 build: {
23 emptyOutDir: false,
24 copyPublicDir: false,
25 target: 'es2020',
26 lib: {
27 entry: join(config.srcQwikDir, 'qwikloader.ts'),
28 formats: ['es'],
29 fileName: () => 'qwikloader.debug.js',
30 },
31 minify: false,
32 outDir: config.distQwikPkgDir,
33 },
34 });
35
36 // Read the debug version
37 const debugFilePath = join(config.distQwikPkgDir, 'qwikloader.debug.js');
38 const debugContent = await readFile(debugFilePath, 'utf-8');
39
40 // Create the minified version using terser
41 const minifyResult = await minify(debugContent, {
42 compress: {
43 global_defs: {
44 'window.BuildEvents': false,
45 },
46 keep_fargs: false,
47 unsafe: true,
48 passes: 2,
49 },
50 mangle: {
51 keep_fnames: false,
52 properties: false,
53 toplevel: true,
54 },
55 // uncomment this to understand the minified version better
56 // format: { semicolons: false },
57 });
58
59 // Write the minified version
60 const minifiedFilePath = join(config.distQwikPkgDir, 'qwikloader.js');
61 await writeFile(minifiedFilePath, minifyResult.code || '');
62
63 await generateLoaderSubmodule(config);
64
65 const loaderSize = await fileSize(join(config.distQwikPkgDir, 'qwikloader.js'));
66 console.log(`🐸 qwikloader:`, loaderSize);
67}
68
69const getLoaderJsonString = async (config: BuildConfig, name: string) => {
70 const filePath = join(config.distQwikPkgDir, name);

Callers 1

buildFunction · 0.90

Calls 5

readFileFunction · 0.90
fileSizeFunction · 0.90
joinFunction · 0.85
generateLoaderSubmoduleFunction · 0.85
buildFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…