MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / esm

Function esm

packages/tooling/src/vite.ts:287–319  ·  view source on GitHub ↗
(
    config: UserConfig,
    projectDir: string,
    name: string,
    entry: string,
    options: EsmOptions = {}
)

Source from the content-addressed store, hash-verified

285}
286
287export function esm(
288 config: UserConfig,
289 projectDir: string,
290 name: string,
291 entry: string,
292 options: EsmOptions = {}
293) {
294 const { withMin = true } = options;
295
296 const lib = config.build!.lib! as LibraryOptions;
297 const libEntry = lib.entry! as Record<string, string>;
298 libEntry[name] = path.resolve(projectDir, entry);
299
300 const output = config.build!.rollupOptions!.output as OutputOptions[];
301 if (!output.some(o => o.format === 'es')) {
302 output.push({
303 globals: {
304 jQuery: 'jQuery'
305 },
306 dir: 'dist/',
307 format: 'es',
308 entryFileNames: '[name].mjs',
309 chunkFileNames: '[name].mjs'
310 });
311 }
312
313 if (withMin) {
314 for (const o of output) {
315 o.plugins ??= [];
316 (o.plugins as OutputPlugin[]).push(min(terserOptions));
317 }
318 }
319}
320
321export function defineEsmCjsLibConfig(setup?: (config: UserConfig) => void) {
322 return defineEsmLibConfig(config => {

Callers 5

vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90

Calls 4

minFunction · 0.85
someMethod · 0.80
resolveMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected