auklet 0.0.9 → 0.0.10

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/README.md CHANGED
@@ -76,6 +76,10 @@ export const config: AukletConfig = {
76
76
  build: {
77
77
  formats: ['esm', 'cjs'],
78
78
  target: 'es2020',
79
+ alias: {
80
+ '@shared': './src/shared',
81
+ },
82
+ mainFields: ['browser', 'module', 'main'],
79
83
  globals: {
80
84
  react: 'React',
81
85
  },
@@ -145,6 +149,8 @@ export const config: AukletConfig = {
145
149
  - `build.platform`: build target runtime platform: `neutral`, `node`, or `browser`. Defaults to `neutral`.
146
150
  - `build.banner`: custom bundle banner. Defaults to a package name/version banner.
147
151
  - `build.externals`: additional external packages. Defaults to `[]`.
152
+ - `build.alias`: path aliases passed to tsdown `alias`. Defaults to `{}`.
153
+ - `build.mainFields`: bundle package entry resolution order passed to rolldown `resolve.mainFields`. When omitted, auklet only sets `['browser', 'module', 'main']` for IIFE bundles.
148
154
  - `build.globals`: IIFE external global names passed to tsdown `output.globals`. Values override auklet's generated global names.
149
155
  - `build.configureTsdown`: final customization hook for each generated tsdown config. It receives `(config, context)` and should return a tsdown config.
150
156
  - `build.tsconfig`: TypeScript config path relative to the package root. Defaults to the nearest `tsconfig.json` found from the package root upward.
@@ -139,6 +139,8 @@ const createBuildContext = (packageRoot, options, output) => {
139
139
  runtimeDependencyNames: Object.keys(pkg.dependencies ?? {}),
140
140
  packageExternal: getPackageExternal(pkg, options),
141
141
  peerExternal: getPeerExternal(pkg, options),
142
+ alias: options.alias ?? {},
143
+ mainFields: options.mainFields,
142
144
  globals: options.globals ?? {},
143
145
  globalName: getGlobalName(pkg),
144
146
  platform: options.platform,
@@ -158,6 +160,7 @@ const createCommonConfig = (context, deps) => {
158
160
  tsconfig: context.tsconfig,
159
161
  target: context.target,
160
162
  platform: context.platform,
163
+ alias: context.alias,
161
164
  deps,
162
165
  define: {
163
166
  __TEST__: 'false',
@@ -167,6 +170,21 @@ const createCommonConfig = (context, deps) => {
167
170
  },
168
171
  };
169
172
  };
173
+ const createBundleInputOptions = (context, format) => {
174
+ const mainFields =
175
+ context.mainFields ??
176
+ (format === 'iife' ? ['browser', 'module', 'main'] : undefined);
177
+ return (options) => {
178
+ if (!mainFields) return options;
179
+ return {
180
+ ...options,
181
+ resolve: {
182
+ ...options.resolve,
183
+ mainFields,
184
+ },
185
+ };
186
+ };
187
+ };
170
188
  const configureTsdown = (context, config, options) => {
171
189
  return (
172
190
  context.configureTsdown?.(config, {
@@ -199,6 +217,10 @@ const createBundleConfigs = (context, formats) => {
199
217
  : {
200
218
  neverBundle: context.packageExternal,
201
219
  };
220
+ const inputOptions =
221
+ context.mainFields || format === 'iife'
222
+ ? createBundleInputOptions(context, format)
223
+ : undefined;
202
224
  return configureTsdown(
203
225
  context,
204
226
  {
@@ -218,6 +240,7 @@ const createBundleConfigs = (context, formats) => {
218
240
  chunkFileNames: `[name]-[hash]${extname}`,
219
241
  globals: format === 'iife' ? getIifeGlobals(context) : {},
220
242
  },
243
+ inputOptions,
221
244
  },
222
245
  { kind: 'bundle', format },
223
246
  );
package/dist/config.d.ts CHANGED
@@ -25,6 +25,8 @@ export declare function normalizeAukletConfig(config?: AukletConfig): {
25
25
  platform: import('#auklet/types').PackageBuildPlatform;
26
26
  banner?: string;
27
27
  externals?: Array<string>;
28
+ alias?: Record<string, string>;
29
+ mainFields?: Array<string>;
28
30
  globals?: Record<string, string>;
29
31
  configureTsdown?: import('#auklet/types').ConfigureTsdown;
30
32
  tsconfig?: string;
@@ -48,6 +48,8 @@ export declare class ModuleStyleGraphRequestCache {
48
48
  platform: import('#auklet/types').PackageBuildPlatform;
49
49
  banner?: string;
50
50
  externals?: Array<string>;
51
+ alias?: Record<string, string>;
52
+ mainFields?: Array<string>;
51
53
  globals?: Record<string, string>;
52
54
  configureTsdown?: import('#auklet/types').ConfigureTsdown;
53
55
  tsconfig?: string;
package/dist/types.d.ts CHANGED
@@ -43,6 +43,8 @@ export type PackageBuildOptions = {
43
43
  platform?: PackageBuildPlatform;
44
44
  banner?: string;
45
45
  externals?: Array<string>;
46
+ alias?: Record<string, string>;
47
+ mainFields?: Array<string>;
46
48
  globals?: Record<string, string>;
47
49
  configureTsdown?: ConfigureTsdown;
48
50
  tsconfig?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auklet",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "author": "chentao.arthur",
6
6
  "packageManager": "pnpm@10.27.0",