auklet 0.0.16 → 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.
- package/dist/build/bundleConfig.d.ts +1 -4
- package/dist/build/bundleConfig.js +59 -71
- package/dist/build/cleanOutput.d.ts +2 -8
- package/dist/build/cleanOutput.js +7 -7
- package/dist/build/moduleConfig.d.ts +1 -3
- package/dist/build/moduleConfig.js +21 -40
- package/dist/build/runTsdown.d.ts +2 -5
- package/dist/build/runTsdown.js +18 -23
- package/dist/build/tsdown/common.d.ts +17 -28
- package/dist/build/tsdown/common.js +22 -25
- package/dist/build/tsdown/context.d.ts +16 -20
- package/dist/build/tsdown/context.js +41 -45
- package/dist/build/tsdown/define.d.ts +2 -7
- package/dist/build/tsdown/define.js +13 -22
- package/dist/build/tsdown/dependencies.d.ts +4 -12
- package/dist/build/tsdown/dependencies.js +47 -51
- package/dist/build/tsdown/entries.d.ts +4 -6
- package/dist/build/tsdown/entries.js +39 -38
- package/dist/build/tsdown/parseModuleId.d.ts +4 -4
- package/dist/build/tsdown/parseModuleId.js +92 -77
- package/dist/build/tsdown/types.d.ts +24 -31
- package/dist/build/tsdownConfig.js +1 -4
- package/dist/config.d.ts +37 -37
- package/dist/config.js +38 -41
- package/dist/configLoader.d.ts +2 -7
- package/dist/configLoader.js +59 -64
- package/dist/css/config.js +8 -8
- package/dist/css/constants.d.ts +6 -6
- package/dist/css/core/resolvers/packageImports.d.ts +1 -5
- package/dist/css/core/resolvers/packageImports.js +35 -40
- package/dist/css/core/resolvers/relative.d.ts +1 -4
- package/dist/css/core/resolvers/relative.js +3 -2
- package/dist/css/core/resolvers/tsconfigPaths.d.ts +1 -5
- package/dist/css/core/resolvers/tsconfigPaths.js +59 -66
- package/dist/css/core/style/dependencies.d.ts +6 -16
- package/dist/css/core/style/dependencies.js +35 -38
- package/dist/css/core/style/entries.d.ts +35 -58
- package/dist/css/core/style/entries.js +20 -31
- package/dist/css/core/style/files.d.ts +2 -7
- package/dist/css/core/style/files.js +11 -11
- package/dist/css/core/style/specifier.d.ts +5 -8
- package/dist/css/core/style/specifier.js +21 -18
- package/dist/css/core/styleImports/collector.d.ts +17 -25
- package/dist/css/core/styleImports/collector.js +162 -201
- package/dist/css/core/styleImports/sourceReference.d.ts +8 -16
- package/dist/css/core/styleImports/sourceReference.js +153 -173
- package/dist/css/core/styleModuleEntryPlanner.d.ts +21 -24
- package/dist/css/core/styleModuleEntryPlanner.js +44 -61
- package/dist/css/core/stylePackageContext.d.ts +16 -20
- package/dist/css/core/stylePackageContext.js +33 -49
- package/dist/css/core/styleProcessor.js +105 -104
- package/dist/css/core/workspaceStyleResolver.d.ts +9 -15
- package/dist/css/core/workspaceStyleResolver.js +62 -72
- package/dist/css/production/builder.d.ts +9 -16
- package/dist/css/production/builder.js +51 -57
- package/dist/css/production/format/componentWriter.js +45 -66
- package/dist/css/production/format/entryWriter.js +36 -49
- package/dist/css/production/format/externalWriter.js +21 -33
- package/dist/css/production/format/moduleWriter.js +23 -26
- package/dist/css/production/format/shared.d.ts +8 -15
- package/dist/css/production/format/shared.js +5 -6
- package/dist/css/production/format/sourceWriter.js +11 -11
- package/dist/css/production/format/themeWriter.js +56 -71
- package/dist/css/production/moduleOutputWriter.d.ts +18 -21
- package/dist/css/production/moduleOutputWriter.js +56 -65
- package/dist/css/production/packageEntryWriter.d.ts +12 -15
- package/dist/css/production/packageEntryWriter.js +42 -45
- package/dist/css/vite/hmr.d.ts +11 -11
- package/dist/css/vite/hmr.js +93 -109
- package/dist/css/vite/moduleGraph/devDependency.d.ts +7 -12
- package/dist/css/vite/moduleGraph/devDependency.js +8 -8
- package/dist/css/vite/moduleGraph/graph.d.ts +20 -23
- package/dist/css/vite/moduleGraph/graph.js +46 -49
- package/dist/css/vite/moduleGraph/loadResult.d.ts +3 -5
- package/dist/css/vite/moduleGraph/loadResult.js +7 -9
- package/dist/css/vite/moduleGraph/packageSource/monorepo.d.ts +4 -6
- package/dist/css/vite/moduleGraph/packageSource/monorepo.js +59 -64
- package/dist/css/vite/moduleGraph/packageSource/types.d.ts +7 -7
- package/dist/css/vite/moduleGraph/requestCache.d.ts +46 -57
- package/dist/css/vite/moduleGraph/requestCache.js +53 -51
- package/dist/css/vite/moduleGraph/styleCodeFactory.d.ts +15 -18
- package/dist/css/vite/moduleGraph/styleCodeFactory.js +182 -263
- package/dist/css/vite/moduleGraph/styleId.d.ts +3 -6
- package/dist/css/vite/moduleGraph/styleId.js +12 -11
- package/dist/css/vite/moduleGraph/types.d.ts +11 -14
- package/dist/css/vite/vitePlugin.d.ts +16 -20
- package/dist/css/vite/vitePlugin.js +110 -109
- package/dist/css/watch/watcher.d.ts +15 -21
- package/dist/css/watch/watcher.js +83 -80
- package/dist/index.d.ts +3 -25
- package/dist/index.js +2 -9
- package/dist/types.d.ts +59 -62
- package/dist/utils.d.ts +3 -7
- package/dist/utils.js +50 -47
- package/package.json +31 -33
|
@@ -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
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
cjs: '.cjs',
|
|
6
|
+
iife: '.global.js',
|
|
7
|
+
esm: ['.js', '.mjs'],
|
|
14
8
|
};
|
|
15
9
|
const createBundleInputOptions = (context, format) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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>;
|
package/dist/build/runTsdown.js
CHANGED
|
@@ -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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { PackageBuildOptions } from '#auklet/types';
|
|
2
2
|
import type { BuildContext, PackageJsonLike } from '#auklet/build/tsdown/types';
|
|
3
|
-
export declare function getPackageExternal(
|
|
4
|
-
|
|
5
|
-
options: PackageBuildOptions,
|
|
6
|
-
): string[];
|
|
7
|
-
export declare function getPeerExternal(
|
|
8
|
-
pkg: PackageJsonLike,
|
|
9
|
-
options: PackageBuildOptions,
|
|
10
|
-
): string[];
|
|
3
|
+
export declare function getPackageExternal(pkg: PackageJsonLike, options: PackageBuildOptions): string[];
|
|
4
|
+
export declare function getPeerExternal(pkg: PackageJsonLike, options: PackageBuildOptions): string[];
|
|
11
5
|
export declare function getIifeGlobals(context: BuildContext): {
|
|
12
|
-
|
|
6
|
+
[x: string]: string;
|
|
13
7
|
};
|
|
14
|
-
export declare function getIifeAlwaysBundle(
|
|
15
|
-
context: BuildContext,
|
|
16
|
-
): (id: string) => boolean;
|
|
8
|
+
export declare function getIifeAlwaysBundle(context: BuildContext): (id: string) => boolean;
|