snapshot of https://github.com/dream-num/univer.git (dev, 2026-09-16; blobs > 131072B omitted)
Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled
Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled
This commit is contained in:
55
common/shared/tsdown/utils/base-config.ts
Normal file
55
common/shared/tsdown/utils/base-config.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { UserConfig } from 'tsdown';
|
||||
import type { IBuildContext, IBuildOptions } from '../types.ts';
|
||||
import path from 'node:path';
|
||||
import vue from 'unplugin-vue/rolldown';
|
||||
import { DEFAULT_BROWSER_TARGET } from '../constants.ts';
|
||||
import { createClassNameWhitespaceCleanupPlugin } from '../plugins/class-name-whitespace-cleanup.ts';
|
||||
import { hasSourceFiles } from './files.ts';
|
||||
|
||||
/**
|
||||
* Resolves extra bundler plugins based on the package source layout.
|
||||
*/
|
||||
export function createInputPlugins(packageDir: string): any[] {
|
||||
return [
|
||||
createClassNameWhitespaceCleanupPlugin(),
|
||||
...(hasSourceFiles(packageDir, '.vue') ? [vue()] : []),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds resolver conditions for packages that prefer Node-first exports.
|
||||
*/
|
||||
export function createInputOptions(options: IBuildOptions): IBuildContext['inputOptions'] {
|
||||
if (!options.nodeFirst) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
resolve: {
|
||||
conditionNames: ['node', 'default'],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the shared tsdown base config used by all output formats.
|
||||
*/
|
||||
export function createBaseConfig(context: IBuildContext): Partial<UserConfig> {
|
||||
return {
|
||||
clean: false,
|
||||
css: {
|
||||
transformer: 'postcss' as const,
|
||||
},
|
||||
cwd: context.packageDir,
|
||||
define: {
|
||||
'process.env.BUILD_TIMESTAMP': JSON.stringify(Math.floor(Date.now() / 1000)),
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
'process.env.WS_NO_BUFFER_UTIL': JSON.stringify(true),
|
||||
},
|
||||
inputOptions: context.inputOptions,
|
||||
outExtensions: () => ({ js: '.js' }),
|
||||
report: true,
|
||||
target: DEFAULT_BROWSER_TARGET,
|
||||
tsconfig: path.join(context.packageDir, 'tsconfig.json'),
|
||||
} satisfies Partial<UserConfig>;
|
||||
}
|
||||
Reference in New Issue
Block a user