Home / File/ check-treeshakeability.js — svelte Source File

check-treeshakeability.js — svelte Source File

Architecture documentation for check-treeshakeability.js, a javascript file in the svelte codebase. 7 imports, 0 dependents.

File javascript BuildSystem QualityControl 7 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed["check-treeshakeability.js"]
  f596e027_a951_36c9_7695_83acc4f0d6b9["node:fs"]
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed --> f596e027_a951_36c9_7695_83acc4f0d6b9
  f8929fbd_6327_2bb8_f43b_31a3db2e4d74["node:path"]
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed --> f8929fbd_6327_2bb8_f43b_31a3db2e4d74
  1e87bdd2_077b_eeb5_2d65_2e3fa5e0d403["node:process"]
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed --> 1e87bdd2_077b_eeb5_2d65_2e3fa5e0d403
  e2463258_8ded_a111_6a43_1837006b5f4e["rollup"]
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed --> e2463258_8ded_a111_6a43_1837006b5f4e
  93977102_c7e2_229a_85df_137be093b3fc["plugin-virtual"]
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed --> 93977102_c7e2_229a_85df_137be093b3fc
  b9433fbb_934d_d0a3_1b33_4ffc69ffe069["plugin-node-resolve"]
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed --> b9433fbb_934d_d0a3_1b33_4ffc69ffe069
  a8d49317_f479_a216_78e7_48c9e32499d5["compiler"]
  a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed --> a8d49317_f479_a216_78e7_48c9e32499d5
  style a1cf3ce1_4e6b_8aaa_e102_ea18e7bc71ed fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { rollup } from 'rollup';
import virtual from '@rollup/plugin-virtual';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { compile } from 'svelte/compiler';

/**
 * @param {string} entry
 */
async function bundle_code(entry) {
	const bundle = await rollup({
		input: '__entry__',
		plugins: [
			virtual({
				__entry__: entry
			}),
			{
				name: 'resolve-svelte',
				resolveId(importee) {
					if (importee.startsWith('svelte')) {
						const entry = pkg.exports[importee.replace('svelte', '.')];
						return path.resolve(entry.browser ?? entry.default);
					}
				}
			},
			nodeResolve({
				exportConditions: ['production', 'import', 'browser', 'default']
			})
		],
		onwarn: (warning, handle) => {
			if (warning.code !== 'EMPTY_BUNDLE' && warning.code !== 'CIRCULAR_DEPENDENCY') {
				handle(warning);
			}
		}
	});

	const { output } = await bundle.generate({});

	if (output.length > 1) {
		throw new Error('errr what');
	}

	return output[0].code.trim();
}

const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));

let failed = false;

// eslint-disable-next-line no-console
console.group('checking treeshakeability');

for (const key in pkg.exports) {
	// special cases
	if (key === './compiler') continue;
	if (key === './internal') continue;
	if (key === './internal/disclose-version') continue;
	if (key === './internal/flags/legacy') continue;
// ... (104 more lines)

Domain

Subdomains

Dependencies

  • compiler
  • node:fs
  • node:path
  • node:process
  • plugin-node-resolve
  • plugin-virtual
  • rollup

Frequently Asked Questions

What does check-treeshakeability.js do?
check-treeshakeability.js is a source file in the svelte codebase, written in javascript. It belongs to the BuildSystem domain, QualityControl subdomain.
What functions are defined in check-treeshakeability.js?
check-treeshakeability.js defines 2 function(s): bundle_code, check_bundle.
What does check-treeshakeability.js depend on?
check-treeshakeability.js imports 7 module(s): compiler, node:fs, node:path, node:process, plugin-node-resolve, plugin-virtual, rollup.
Where is check-treeshakeability.js in the architecture?
check-treeshakeability.js is located at packages/svelte/scripts/check-treeshakeability.js (domain: BuildSystem, subdomain: QualityControl, directory: packages/svelte/scripts).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free