auklet 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/bin/entry.cjs +4 -6
  2. package/dist/build/bundleConfig.d.ts +1 -4
  3. package/dist/build/bundleConfig.js +59 -71
  4. package/dist/build/cleanOutput.d.ts +2 -8
  5. package/dist/build/cleanOutput.js +7 -7
  6. package/dist/build/moduleConfig.d.ts +1 -3
  7. package/dist/build/moduleConfig.js +21 -40
  8. package/dist/build/runTsdown.d.ts +2 -5
  9. package/dist/build/runTsdown.js +18 -23
  10. package/dist/build/tsdown/common.d.ts +17 -28
  11. package/dist/build/tsdown/common.js +22 -25
  12. package/dist/build/tsdown/context.d.ts +16 -20
  13. package/dist/build/tsdown/context.js +41 -45
  14. package/dist/build/tsdown/define.d.ts +2 -7
  15. package/dist/build/tsdown/define.js +13 -22
  16. package/dist/build/tsdown/dependencies.d.ts +4 -12
  17. package/dist/build/tsdown/dependencies.js +47 -51
  18. package/dist/build/tsdown/entries.d.ts +4 -6
  19. package/dist/build/tsdown/entries.js +39 -38
  20. package/dist/build/tsdown/parseModuleId.d.ts +4 -4
  21. package/dist/build/tsdown/parseModuleId.js +92 -77
  22. package/dist/build/tsdown/types.d.ts +24 -31
  23. package/dist/build/tsdownConfig.d.ts +2 -6
  24. package/dist/build/tsdownConfig.js +1 -4
  25. package/dist/config.d.ts +37 -37
  26. package/dist/config.js +38 -41
  27. package/dist/configLoader.d.ts +2 -7
  28. package/dist/configLoader.js +59 -64
  29. package/dist/css/config.js +8 -8
  30. package/dist/css/constants.d.ts +6 -6
  31. package/dist/css/core/resolvers/packageImports.d.ts +1 -5
  32. package/dist/css/core/resolvers/packageImports.js +35 -40
  33. package/dist/css/core/resolvers/relative.d.ts +1 -4
  34. package/dist/css/core/resolvers/relative.js +3 -2
  35. package/dist/css/core/resolvers/tsconfigPaths.d.ts +1 -5
  36. package/dist/css/core/resolvers/tsconfigPaths.js +59 -66
  37. package/dist/css/core/style/dependencies.d.ts +6 -16
  38. package/dist/css/core/style/dependencies.js +35 -38
  39. package/dist/css/core/style/entries.d.ts +35 -58
  40. package/dist/css/core/style/entries.js +20 -31
  41. package/dist/css/core/style/files.d.ts +2 -7
  42. package/dist/css/core/style/files.js +11 -11
  43. package/dist/css/core/style/specifier.d.ts +5 -8
  44. package/dist/css/core/style/specifier.js +21 -18
  45. package/dist/css/core/styleImports/collector.d.ts +17 -25
  46. package/dist/css/core/styleImports/collector.js +162 -201
  47. package/dist/css/core/styleImports/sourceReference.d.ts +8 -16
  48. package/dist/css/core/styleImports/sourceReference.js +153 -173
  49. package/dist/css/core/styleModuleEntryPlanner.d.ts +21 -24
  50. package/dist/css/core/styleModuleEntryPlanner.js +44 -61
  51. package/dist/css/core/stylePackageContext.d.ts +16 -20
  52. package/dist/css/core/stylePackageContext.js +33 -49
  53. package/dist/css/core/styleProcessor.d.ts +12 -12
  54. package/dist/css/core/styleProcessor.js +105 -104
  55. package/dist/css/core/workspaceStyleResolver.d.ts +9 -15
  56. package/dist/css/core/workspaceStyleResolver.js +62 -72
  57. package/dist/css/production/builder.d.ts +9 -16
  58. package/dist/css/production/builder.js +51 -57
  59. package/dist/css/production/format/componentWriter.d.ts +8 -8
  60. package/dist/css/production/format/componentWriter.js +45 -66
  61. package/dist/css/production/format/entryWriter.d.ts +5 -9
  62. package/dist/css/production/format/entryWriter.js +36 -49
  63. package/dist/css/production/format/externalWriter.d.ts +6 -6
  64. package/dist/css/production/format/externalWriter.js +21 -33
  65. package/dist/css/production/format/moduleWriter.d.ts +5 -5
  66. package/dist/css/production/format/moduleWriter.js +23 -26
  67. package/dist/css/production/format/shared.d.ts +8 -15
  68. package/dist/css/production/format/shared.js +5 -6
  69. package/dist/css/production/format/sourceWriter.d.ts +3 -3
  70. package/dist/css/production/format/sourceWriter.js +11 -11
  71. package/dist/css/production/format/themeWriter.d.ts +8 -14
  72. package/dist/css/production/format/themeWriter.js +56 -71
  73. package/dist/css/production/moduleOutputWriter.d.ts +18 -21
  74. package/dist/css/production/moduleOutputWriter.js +56 -65
  75. package/dist/css/production/packageEntryWriter.d.ts +12 -15
  76. package/dist/css/production/packageEntryWriter.js +42 -45
  77. package/dist/css/vite/hmr.d.ts +11 -11
  78. package/dist/css/vite/hmr.js +93 -109
  79. package/dist/css/vite/moduleGraph/devDependency.d.ts +7 -12
  80. package/dist/css/vite/moduleGraph/devDependency.js +8 -8
  81. package/dist/css/vite/moduleGraph/graph.d.ts +20 -24
  82. package/dist/css/vite/moduleGraph/graph.js +49 -64
  83. package/dist/css/vite/moduleGraph/loadResult.d.ts +3 -5
  84. package/dist/css/vite/moduleGraph/loadResult.js +7 -9
  85. package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +7 -0
  86. package/dist/css/vite/moduleGraph/packageSource/monorepo.js +72 -0
  87. package/dist/css/vite/moduleGraph/packageSource/types.d.ts +11 -0
  88. package/dist/css/vite/moduleGraph/packageSource/types.js +0 -0
  89. package/dist/css/vite/moduleGraph/requestCache.d.ts +47 -61
  90. package/dist/css/vite/moduleGraph/requestCache.js +51 -84
  91. package/dist/css/vite/moduleGraph/styleCodeFactory.d.ts +15 -18
  92. package/dist/css/vite/moduleGraph/styleCodeFactory.js +182 -263
  93. package/dist/css/vite/moduleGraph/styleId.d.ts +3 -6
  94. package/dist/css/vite/moduleGraph/styleId.js +12 -11
  95. package/dist/css/vite/moduleGraph/types.d.ts +11 -13
  96. package/dist/css/vite/vitePlugin.d.ts +16 -20
  97. package/dist/css/vite/vitePlugin.js +111 -110
  98. package/dist/css/watch/watcher.d.ts +15 -21
  99. package/dist/css/watch/watcher.js +83 -80
  100. package/dist/index.d.ts +3 -25
  101. package/dist/index.js +2 -9
  102. package/dist/types.d.ts +59 -62
  103. package/dist/utils.d.ts +3 -7
  104. package/dist/utils.js +50 -47
  105. package/package.json +31 -32
package/bin/entry.cjs CHANGED
@@ -45,9 +45,8 @@ const runBuildStyle = async (args, options = {}) => {
45
45
  return 0;
46
46
  }
47
47
 
48
- const { ModuleStyleBuilder } = await import(
49
- '../dist/css/production/builder.js'
50
- );
48
+ const { ModuleStyleBuilder } =
49
+ await import('../dist/css/production/builder.js');
51
50
  const builder = new ModuleStyleBuilder({ aukletConfig, logger: console });
52
51
  await builder.build();
53
52
  return 0;
@@ -60,9 +59,8 @@ const runBuildJs = async (args) => {
60
59
 
61
60
  const runBuild = async (args) => {
62
61
  const aukletConfig = await loadCurrentAukletConfig();
63
- const { cleanAukletOutputByConfig } = await import(
64
- '../dist/build/cleanOutput.js'
65
- );
62
+ const { cleanAukletOutputByConfig } =
63
+ await import('../dist/build/cleanOutput.js');
66
64
  cleanAukletOutputByConfig(process.cwd(), aukletConfig);
67
65
 
68
66
  const jsExitCode = await runBuildJs(args);
@@ -1,6 +1,3 @@
1
1
  import type { UserConfig } from 'tsdown/config';
2
2
  import type { BuildContext, TsdownFormat } from '#auklet/build/tsdown/types';
3
- export declare function createBundleConfigs(
4
- context: BuildContext,
5
- formats: Array<TsdownFormat>,
6
- ): UserConfig[];
3
+ export declare function createBundleConfigs(context: BuildContext, formats: Array<TsdownFormat>): UserConfig[];
@@ -1,80 +1,68 @@
1
1
  import { getBundleEntry } from '#auklet/build/tsdown/entries';
2
- import {
3
- getIifeAlwaysBundle,
4
- getIifeGlobals,
5
- } from '#auklet/build/tsdown/dependencies';
6
- import {
7
- configureTsdown,
8
- createCommonConfig,
9
- } from '#auklet/build/tsdown/common';
2
+ import { getIifeAlwaysBundle, getIifeGlobals, } from '#auklet/build/tsdown/dependencies';
3
+ import { configureTsdown, createCommonConfig, } from '#auklet/build/tsdown/common';
10
4
  const formatMap = {
11
- cjs: '.cjs',
12
- iife: '.global.js',
13
- esm: ['.js', '.mjs'],
5
+ cjs: '.cjs',
6
+ iife: '.global.js',
7
+ esm: ['.js', '.mjs'],
14
8
  };
15
9
  const createBundleInputOptions = (context, format) => {
16
- const mainFields =
17
- context.mainFields ??
18
- (format === 'iife' ? ['browser', 'module', 'main'] : undefined);
19
- return (options) => {
20
- if (!mainFields) return options;
21
- return {
22
- ...options,
23
- resolve: {
24
- ...options.resolve,
25
- mainFields,
26
- },
10
+ const mainFields = context.mainFields ??
11
+ (format === 'iife' ? ['browser', 'module', 'main'] : undefined);
12
+ return (options) => {
13
+ if (!mainFields)
14
+ return options;
15
+ return {
16
+ ...options,
17
+ resolve: {
18
+ ...options.resolve,
19
+ mainFields,
20
+ },
21
+ };
27
22
  };
28
- };
29
23
  };
30
24
  export function createBundleConfigs(context, formats) {
31
- const outputConfigs = [];
32
- let hasDtsConfig = false;
33
- for (const format of formats) {
34
- const extnames = formatMap[format];
35
- for (const extname of Array.isArray(extnames) ? extnames : [extnames]) {
36
- const emitDts = !hasDtsConfig;
37
- outputConfigs.push({ format, extname, dts: emitDts });
38
- hasDtsConfig ||= emitDts;
25
+ const outputConfigs = [];
26
+ let hasDtsConfig = false;
27
+ for (const format of formats) {
28
+ const extnames = formatMap[format];
29
+ for (const extname of Array.isArray(extnames) ? extnames : [extnames]) {
30
+ const emitDts = !hasDtsConfig;
31
+ outputConfigs.push({ format, extname, dts: emitDts });
32
+ hasDtsConfig ||= emitDts;
33
+ }
39
34
  }
40
- }
41
- return outputConfigs.map(({ format, extname, dts }) => {
42
- const deps =
43
- format === 'iife'
44
- ? {
45
- neverBundle: context.peerExternal,
46
- alwaysBundle: getIifeAlwaysBundle(context),
47
- onlyBundle: false,
48
- }
49
- : {
50
- neverBundle: context.packageExternal,
51
- };
52
- const inputOptions =
53
- context.mainFields || format === 'iife'
54
- ? createBundleInputOptions(context, format)
55
- : undefined;
56
- return configureTsdown(
57
- context,
58
- {
59
- ...createCommonConfig(context, deps),
60
- entry: getBundleEntry(context.packageRoot),
61
- format,
62
- globalName: context.globalName,
63
- outDir: context.output,
64
- dts,
65
- treeshake: true,
66
- banner: context.banner,
67
- outExtensions: () => ({
68
- js: extname,
69
- }),
70
- outputOptions: {
71
- entryFileNames: `[name]${extname}`,
72
- chunkFileNames: `[name]-[hash]${extname}`,
73
- globals: format === 'iife' ? getIifeGlobals(context) : {},
74
- },
75
- inputOptions,
76
- },
77
- { kind: 'bundle', format },
78
- );
79
- });
35
+ return outputConfigs.map(({ format, extname, dts }) => {
36
+ const deps = format === 'iife'
37
+ ? {
38
+ neverBundle: context.peerExternal,
39
+ alwaysBundle: getIifeAlwaysBundle(context),
40
+ onlyBundle: false,
41
+ }
42
+ : {
43
+ neverBundle: context.packageExternal,
44
+ };
45
+ const inputOptions = context.mainFields || format === 'iife'
46
+ ? createBundleInputOptions(context, format)
47
+ : undefined;
48
+ return configureTsdown(context, {
49
+ ...createCommonConfig(context, deps),
50
+ entry: getBundleEntry(context.packageRoot),
51
+ format,
52
+ globalName: context.globalName,
53
+ outDir: context.output,
54
+ dts,
55
+ treeshake: true,
56
+ banner: context.banner,
57
+ outExtensions: () => ({
58
+ js: extname,
59
+ }),
60
+ outputOptions: {
61
+ entryFileNames: `[name]${extname}`,
62
+ chunkFileNames: `[name]-[hash]${extname}`,
63
+ globals: format === 'iife' ? getIifeGlobals(context) : {},
64
+ },
65
+ inputOptions,
66
+ }, { kind: 'bundle', format });
67
+ });
80
68
  }
@@ -1,9 +1,3 @@
1
1
  import type { AukletConfig, LoadAukletConfigOptions } from '#auklet/types';
2
- export declare function cleanAukletOutputByConfig(
3
- packageRoot: string,
4
- config?: AukletConfig,
5
- ): void;
6
- export declare function cleanAukletOutput(
7
- packageRoot: string,
8
- options?: LoadAukletConfigOptions,
9
- ): Promise<void>;
2
+ export declare function cleanAukletOutputByConfig(packageRoot: string, config?: AukletConfig): void;
3
+ export declare function cleanAukletOutput(packageRoot: string, options?: LoadAukletConfigOptions): Promise<void>;
@@ -3,13 +3,13 @@ import path from 'node:path';
3
3
  import { normalizeAukletConfig } from '#auklet/config';
4
4
  import { loadAukletConfig } from '#auklet/configLoader';
5
5
  export function cleanAukletOutputByConfig(packageRoot, config = {}) {
6
- const normalizedConfig = normalizeAukletConfig(config);
7
- fs.rmSync(path.join(packageRoot, normalizedConfig.output), {
8
- recursive: true,
9
- force: true,
10
- });
6
+ const normalizedConfig = normalizeAukletConfig(config);
7
+ fs.rmSync(path.join(packageRoot, normalizedConfig.output), {
8
+ recursive: true,
9
+ force: true,
10
+ });
11
11
  }
12
12
  export async function cleanAukletOutput(packageRoot, options = {}) {
13
- const rawConfig = await loadAukletConfig(packageRoot, options);
14
- cleanAukletOutputByConfig(packageRoot, rawConfig);
13
+ const rawConfig = await loadAukletConfig(packageRoot, options);
14
+ cleanAukletOutputByConfig(packageRoot, rawConfig);
15
15
  }
@@ -1,5 +1,3 @@
1
1
  import type { UserConfig } from 'tsdown/config';
2
2
  import type { BuildContext } from '#auklet/build/tsdown/types';
3
- export declare function createModuleConfigs(
4
- context: BuildContext,
5
- ): UserConfig[];
3
+ export declare function createModuleConfigs(context: BuildContext): UserConfig[];
@@ -1,46 +1,27 @@
1
1
  import path from 'node:path';
2
- import {
3
- configureTsdown,
4
- createCommonConfig,
5
- } from '#auklet/build/tsdown/common';
2
+ import { configureTsdown, createCommonConfig, } from '#auklet/build/tsdown/common';
6
3
  import { getModuleEntries } from '#auklet/build/tsdown/entries';
7
4
  const createModuleConfig = (context, commonConfig, entry, format, outDir) => {
8
- return configureTsdown(
9
- context,
10
- {
11
- ...commonConfig,
12
- entry,
13
- format,
14
- outDir,
15
- dts: true,
16
- unbundle: true,
17
- outExtensions: () => ({
18
- js: '.js',
19
- dts: '.d.ts',
20
- }),
21
- },
22
- { kind: 'module', format },
23
- );
5
+ return configureTsdown(context, {
6
+ ...commonConfig,
7
+ entry,
8
+ format,
9
+ outDir,
10
+ dts: true,
11
+ unbundle: true,
12
+ outExtensions: () => ({
13
+ js: '.js',
14
+ dts: '.d.ts',
15
+ }),
16
+ }, { kind: 'module', format });
24
17
  };
25
18
  export function createModuleConfigs(context) {
26
- const commonConfig = createCommonConfig(context, {
27
- neverBundle: context.packageExternal,
28
- });
29
- const entry = getModuleEntries(context.packageRoot);
30
- return [
31
- createModuleConfig(
32
- context,
33
- commonConfig,
34
- entry,
35
- 'esm',
36
- path.join(context.output, 'es'),
37
- ),
38
- createModuleConfig(
39
- context,
40
- commonConfig,
41
- entry,
42
- 'cjs',
43
- path.join(context.output, 'lib'),
44
- ),
45
- ];
19
+ const commonConfig = createCommonConfig(context, {
20
+ neverBundle: context.packageExternal,
21
+ });
22
+ const entry = getModuleEntries(context.packageRoot);
23
+ return [
24
+ createModuleConfig(context, commonConfig, entry, 'esm', path.join(context.output, 'es')),
25
+ createModuleConfig(context, commonConfig, entry, 'cjs', path.join(context.output, 'lib')),
26
+ ];
46
27
  }
@@ -1,8 +1,5 @@
1
1
  export type RunTsdownOptions = {
2
- cwd?: string;
2
+ cwd?: string;
3
3
  };
4
4
  export declare function createTsdownArgs(args: Array<string>): string[];
5
- export declare function runTsdown(
6
- args: Array<string>,
7
- options?: RunTsdownOptions,
8
- ): Promise<number>;
5
+ export declare function runTsdown(args: Array<string>, options?: RunTsdownOptions): Promise<number>;
@@ -4,32 +4,27 @@ import { execa } from 'execa';
4
4
  const require = createRequire(import.meta.url);
5
5
  const tsdownRunFile = require.resolve('tsdown/run');
6
6
  const currentExtension = import.meta.url.endsWith('.ts') ? 'ts' : 'js';
7
- const defaultConfigFile = fileURLToPath(
8
- new URL(`./tsdownConfig.${currentExtension}`, import.meta.url),
9
- );
7
+ const defaultConfigFile = fileURLToPath(new URL(`./tsdownConfig.${currentExtension}`, import.meta.url));
10
8
  const hasConfigArg = (args) => {
11
- return args.some(
12
- (arg, index) =>
13
- arg === '--no-config' ||
14
- arg === '-c' ||
15
- arg === '--config' ||
16
- arg.startsWith('--config=') ||
17
- args[index - 1] === '-c' ||
18
- args[index - 1] === '--config',
19
- );
9
+ return args.some((arg, index) => arg === '--no-config' ||
10
+ arg === '-c' ||
11
+ arg === '--config' ||
12
+ arg.startsWith('--config=') ||
13
+ args[index - 1] === '-c' ||
14
+ args[index - 1] === '--config');
20
15
  };
21
16
  export function createTsdownArgs(args) {
22
- const tsdownArgs = hasConfigArg(args)
23
- ? args
24
- : ['--config', defaultConfigFile, ...args];
25
- return [tsdownRunFile, ...tsdownArgs];
17
+ const tsdownArgs = hasConfigArg(args)
18
+ ? args
19
+ : ['--config', defaultConfigFile, ...args];
20
+ return [tsdownRunFile, ...tsdownArgs];
26
21
  }
27
22
  export async function runTsdown(args, options = {}) {
28
- const tsdownArgs = createTsdownArgs(args);
29
- const result = await execa(process.execPath, tsdownArgs, {
30
- cwd: options.cwd ?? process.cwd(),
31
- stdio: 'inherit',
32
- reject: false,
33
- });
34
- return result.exitCode ?? 0;
23
+ const tsdownArgs = createTsdownArgs(args);
24
+ const result = await execa(process.execPath, tsdownArgs, {
25
+ cwd: options.cwd ?? process.cwd(),
26
+ stdio: 'inherit',
27
+ reject: false,
28
+ });
29
+ return result.exitCode ?? 0;
35
30
  }
@@ -1,30 +1,19 @@
1
1
  import type { UserConfig } from 'tsdown/config';
2
- import type {
3
- BuildContext,
4
- ConfigureTsdownOptions,
5
- TsdownDeps,
6
- } from '#auklet/build/tsdown/types';
7
- export declare function createCommonConfig(
8
- context: BuildContext,
9
- deps: TsdownDeps,
10
- ): {
11
- cwd: string;
12
- root: string;
13
- clean: false;
14
- sourcemap: false;
15
- tsconfig: string;
16
- target: NonNullable<import('../../types').PackageBuildTarget | undefined>;
17
- platform: NonNullable<import('../../types').PackageBuildPlatform | undefined>;
18
- alias: Record<string, string>;
19
- deps: import('node_modules/tsdown/dist/types-CQaSBA5U.mjs').L;
20
- define: {
21
- __TEST__: string;
22
- __VERSION__: string;
23
- __DEV__: string;
24
- };
2
+ import type { BuildContext, ConfigureTsdownOptions, TsdownDeps } from '#auklet/build/tsdown/types';
3
+ export declare function createCommonConfig(context: BuildContext, deps: TsdownDeps): {
4
+ cwd: string;
5
+ root: string;
6
+ clean: false;
7
+ sourcemap: false;
8
+ tsconfig: string;
9
+ target: NonNullable<import("../../types").PackageBuildTarget | undefined>;
10
+ platform: NonNullable<import("../../types").PackageBuildPlatform | undefined>;
11
+ alias: Record<string, string>;
12
+ deps: import("node_modules/tsdown/dist/types-CQaSBA5U.mjs").L;
13
+ define: {
14
+ __TEST__: string;
15
+ __VERSION__: string;
16
+ __DEV__: string;
17
+ };
25
18
  };
26
- export declare function configureTsdown(
27
- context: BuildContext,
28
- config: UserConfig,
29
- options: ConfigureTsdownOptions,
30
- ): UserConfig;
19
+ export declare function configureTsdown(context: BuildContext, config: UserConfig, options: ConfigureTsdownOptions): UserConfig;
@@ -1,29 +1,26 @@
1
1
  export function createCommonConfig(context, deps) {
2
- return {
3
- cwd: context.packageRoot,
4
- root: context.packageRoot,
5
- clean: false,
6
- sourcemap: false,
7
- tsconfig: context.tsconfig,
8
- target: context.target,
9
- platform: context.platform,
10
- alias: context.alias,
11
- deps,
12
- define: {
13
- __TEST__: 'false',
14
- __VERSION__: JSON.stringify(context.pkg.version),
15
- __DEV__:
16
- '(typeof process !== "undefined" ? (process.env?.NODE_ENV !== "production") : false)',
17
- },
18
- };
2
+ return {
3
+ cwd: context.packageRoot,
4
+ root: context.packageRoot,
5
+ clean: false,
6
+ sourcemap: false,
7
+ tsconfig: context.tsconfig,
8
+ target: context.target,
9
+ platform: context.platform,
10
+ alias: context.alias,
11
+ deps,
12
+ define: {
13
+ __TEST__: 'false',
14
+ __VERSION__: JSON.stringify(context.pkg.version),
15
+ __DEV__: '(typeof process !== "undefined" ? (process.env?.NODE_ENV !== "production") : false)',
16
+ },
17
+ };
19
18
  }
20
19
  export function configureTsdown(context, config, options) {
21
- return (
22
- context.configureTsdown?.(config, {
23
- ...options,
24
- packageRoot: context.packageRoot,
25
- output: context.output,
26
- packageName: context.pkg.name,
27
- }) ?? config
28
- );
20
+ return (context.configureTsdown?.(config, {
21
+ ...options,
22
+ packageRoot: context.packageRoot,
23
+ output: context.output,
24
+ packageName: context.pkg.name,
25
+ }) ?? config);
29
26
  }
@@ -1,23 +1,19 @@
1
1
  import type { PackageBuildOptions } from '#auklet/types';
2
2
  import type { PackageJsonLike } from '#auklet/build/tsdown/types';
3
- export declare function createBuildContext(
4
- packageRoot: string,
5
- options: PackageBuildOptions,
6
- output: string,
7
- ): {
8
- pkg: PackageJsonLike;
9
- banner: string;
10
- packageRoot: string;
11
- output: string;
12
- runtimeDependencyNames: string[];
13
- packageExternal: string[];
14
- peerExternal: string[];
15
- alias: Record<string, string>;
16
- mainFields: string[] | undefined;
17
- globals: Record<string, string>;
18
- globalName: string;
19
- platform: import('#auklet/types').PackageBuildPlatform;
20
- target: import('#auklet/types').PackageBuildTarget;
21
- configureTsdown: import('#auklet/types').ConfigureTsdown | undefined;
22
- tsconfig: string;
3
+ export declare function createBuildContext(packageRoot: string, options: PackageBuildOptions, output: string): {
4
+ pkg: PackageJsonLike;
5
+ banner: string;
6
+ packageRoot: string;
7
+ output: string;
8
+ runtimeDependencyNames: string[];
9
+ packageExternal: string[];
10
+ peerExternal: string[];
11
+ alias: Record<string, string>;
12
+ mainFields: string[] | undefined;
13
+ globals: Record<string, string>;
14
+ globalName: string;
15
+ platform: import("#auklet/types").PackageBuildPlatform;
16
+ target: import("#auklet/types").PackageBuildTarget;
17
+ configureTsdown: import("#auklet/types").ConfigureTsdown | undefined;
18
+ tsconfig: string;
23
19
  };
@@ -1,53 +1,49 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import {
4
- getPeerExternal,
5
- getPackageExternal,
6
- } from '#auklet/build/tsdown/dependencies';
3
+ import { getPeerExternal, getPackageExternal, } from '#auklet/build/tsdown/dependencies';
7
4
  const getGlobalName = (pkg) => {
8
- return (pkg?.name ?? '')
9
- .replace(/@/g, '')
10
- .split(/[/-]/g)
11
- .map((label) => label[0].toUpperCase() + label.slice(1))
12
- .join('');
5
+ return (pkg?.name ?? '')
6
+ .replace(/@/g, '')
7
+ .split(/[/-]/g)
8
+ .map((label) => label[0].toUpperCase() + label.slice(1))
9
+ .join('');
13
10
  };
14
11
  const findWorkspaceTsconfig = (packageRoot) => {
15
- let current = packageRoot;
16
- while (true) {
17
- const tsconfig = path.join(current, 'tsconfig.json');
18
- if (fs.existsSync(tsconfig)) return tsconfig;
19
- const parent = path.dirname(current);
20
- if (parent === current) return path.join(packageRoot, 'tsconfig.json');
21
- current = parent;
22
- }
12
+ let current = packageRoot;
13
+ while (true) {
14
+ const tsconfig = path.join(current, 'tsconfig.json');
15
+ if (fs.existsSync(tsconfig))
16
+ return tsconfig;
17
+ const parent = path.dirname(current);
18
+ if (parent === current)
19
+ return path.join(packageRoot, 'tsconfig.json');
20
+ current = parent;
21
+ }
23
22
  };
24
23
  export function createBuildContext(packageRoot, options, output) {
25
- const pkg = JSON.parse(
26
- fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'),
27
- );
28
- const banner =
29
- options.banner ??
30
- '/*!\n' +
31
- ` * ${pkg.name}.js v${pkg.version}\n` +
32
- (pkg.author ? ` * (c) ${new Date().getFullYear()} ${pkg.author}\n` : '') +
33
- ' */';
34
- return {
35
- pkg,
36
- banner,
37
- packageRoot,
38
- output,
39
- runtimeDependencyNames: Object.keys(pkg.dependencies ?? {}),
40
- packageExternal: getPackageExternal(pkg, options),
41
- peerExternal: getPeerExternal(pkg, options),
42
- alias: options.alias ?? {},
43
- mainFields: options.mainFields,
44
- globals: options.globals ?? {},
45
- globalName: getGlobalName(pkg),
46
- platform: options.platform,
47
- target: options.target,
48
- configureTsdown: options.configureTsdown,
49
- tsconfig: options.tsconfig
50
- ? path.resolve(packageRoot, options.tsconfig)
51
- : findWorkspaceTsconfig(packageRoot),
52
- };
24
+ const pkg = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
25
+ const banner = options.banner ??
26
+ '/*!\n' +
27
+ ` * ${pkg.name}.js v${pkg.version}\n` +
28
+ (pkg.author ? ` * (c) ${new Date().getFullYear()} ${pkg.author}\n` : '') +
29
+ ' */';
30
+ return {
31
+ pkg,
32
+ banner,
33
+ packageRoot,
34
+ output,
35
+ runtimeDependencyNames: Object.keys(pkg.dependencies ?? {}),
36
+ packageExternal: getPackageExternal(pkg, options),
37
+ peerExternal: getPeerExternal(pkg, options),
38
+ alias: options.alias ?? {},
39
+ mainFields: options.mainFields,
40
+ globals: options.globals ?? {},
41
+ globalName: getGlobalName(pkg),
42
+ platform: options.platform,
43
+ target: options.target,
44
+ configureTsdown: options.configureTsdown,
45
+ tsconfig: options.tsconfig
46
+ ? path.resolve(packageRoot, options.tsconfig)
47
+ : findWorkspaceTsconfig(packageRoot),
48
+ };
53
49
  }
@@ -1,9 +1,4 @@
1
1
  import type { AukletConfig } from '#auklet/types';
2
2
  export type { TsdownFormat } from '#auklet/build/tsdown/types';
3
- export declare function defineKernelPackageConfigFromOptions(
4
- packageRoot?: string,
5
- config?: AukletConfig,
6
- ): import('tsdown/config').UserConfig[];
7
- export declare function defineKernelPackageConfigFromFile(
8
- packageRoot?: string,
9
- ): Promise<import('tsdown/config').UserConfig[]>;
3
+ export declare function defineKernelPackageConfigFromOptions(packageRoot?: string, config?: AukletConfig): import("tsdown/config").UserConfig[];
4
+ export declare function defineKernelPackageConfigFromFile(packageRoot?: string): Promise<import("tsdown/config").UserConfig[]>;
@@ -3,27 +3,18 @@ import { normalizeAukletConfig } from '#auklet/config';
3
3
  import { createBundleConfigs } from '#auklet/build/bundleConfig';
4
4
  import { createModuleConfigs } from '#auklet/build/moduleConfig';
5
5
  import { createBuildContext } from '#auklet/build/tsdown/context';
6
- export function defineKernelPackageConfigFromOptions(
7
- packageRoot = process.cwd(),
8
- config = {},
9
- ) {
10
- const normalizedConfig = normalizeAukletConfig(config);
11
- const buildOptions = normalizedConfig.build;
12
- const formats = buildOptions.formats;
13
- const context = createBuildContext(
14
- packageRoot,
15
- buildOptions,
16
- normalizedConfig.output,
17
- );
18
- const bundleConfigs = createBundleConfigs(context, formats);
19
- const moduleConfigs = normalizedConfig.modules
20
- ? createModuleConfigs(context)
21
- : [];
22
- return [...bundleConfigs, ...moduleConfigs];
6
+ export function defineKernelPackageConfigFromOptions(packageRoot = process.cwd(), config = {}) {
7
+ const normalizedConfig = normalizeAukletConfig(config);
8
+ const buildOptions = normalizedConfig.build;
9
+ const formats = buildOptions.formats;
10
+ const context = createBuildContext(packageRoot, buildOptions, normalizedConfig.output);
11
+ const bundleConfigs = createBundleConfigs(context, formats);
12
+ const moduleConfigs = normalizedConfig.modules
13
+ ? createModuleConfigs(context)
14
+ : [];
15
+ return [...bundleConfigs, ...moduleConfigs];
23
16
  }
24
- export async function defineKernelPackageConfigFromFile(
25
- packageRoot = process.cwd(),
26
- ) {
27
- const config = await loadAukletConfig(packageRoot, { cacheBust: true });
28
- return defineKernelPackageConfigFromOptions(packageRoot, config);
17
+ export async function defineKernelPackageConfigFromFile(packageRoot = process.cwd()) {
18
+ const config = await loadAukletConfig(packageRoot, { cacheBust: true });
19
+ return defineKernelPackageConfigFromOptions(packageRoot, config);
29
20
  }