rollipop 1.0.0-alpha.27 → 1.0.0-alpha.28

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/client.d.ts CHANGED
@@ -4,6 +4,10 @@ interface ImportMetaEnv {
4
4
  }
5
5
 
6
6
  interface ImportMeta {
7
- hot?: import('./dist').HMRContext;
7
+ glob: import('./import-glob').ImportGlobFunction;
8
8
  env: ImportMetaEnv;
9
+ /**
10
+ * Only available in development mode.
11
+ */
12
+ hot?: import('./dist').HMRContext;
9
13
  }
@@ -1,4 +1,4 @@
1
- import { AnalyzerConfig, BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, RollipopReactNativeFlowConfig, RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig } from "./types.js";
1
+ import { AliasConfig, AnalyzerConfig, BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, RollipopReactNativeFlowConfig, RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig } from "./types.js";
2
2
  import { PluginFlattenConfig, mergeConfig } from "./merge-config.js";
3
3
  import { DefaultConfig, InternalConfig, ResolvedConfig, getDefaultConfig } from "./defaults.js";
4
4
  import { DefineConfigContext, DynamicUserConfig, UserConfig, defineConfig } from "./define-config.js";
@@ -1,8 +1,9 @@
1
1
  import { MaybePromise, NullValue, Reporter } from "../types.js";
2
2
  import { Plugin } from "../core/plugins/types.js";
3
+ import { AliasEntry } from "../core/plugins/alias-plugin.js";
3
4
  import { InteractiveCommand } from "../node/commands/start/setup-interactive-mode.js";
4
- import * as rolldown from "@rollipop/rolldown";
5
5
  import { DevWatchOptions, RollipopReactNativeFlowConfig, RollipopReactNativeWorkletsConfig } from "@rollipop/rolldown/experimental";
6
+ import * as rolldown from "@rollipop/rolldown";
6
7
  import { TopLevelFilterExpression } from "@rollipop/rolldown/filter";
7
8
  import * as babel from "@babel/core";
8
9
  import * as swc from "@swc/core";
@@ -197,7 +198,38 @@ interface Config {
197
198
  type PluginOption = MaybePromise<NullValue<Plugin> | {
198
199
  name: string;
199
200
  } | false | PluginOption[]>;
200
- type ResolverConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>, 'extensions'> & {
201
+ type ResolverConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>, 'alias' | 'extensions'> & {
202
+ /**
203
+ * Substitute one package or module path for another.
204
+ *
205
+ * Object aliases are forwarded to Rolldown's native `resolve.alias`.
206
+ * Array aliases are installed through Rollipop's alias plugin so plugin
207
+ * [`resolveId`](/reference/Interface.Plugin#resolveid) hooks can participate in resolving the replacement.
208
+ *
209
+ * @example
210
+ * ```js
211
+ * // Object alias
212
+ * resolve: {
213
+ * alias: {
214
+ * '@': '/src',
215
+ * 'utils': './src/utils',
216
+ * }
217
+ * }
218
+ *
219
+ * // Array alias
220
+ * resolve: {
221
+ * alias: [
222
+ * { find: '@', replacement: '/src' },
223
+ * { find: /^utils\//, replacement: './src/utils/' },
224
+ * ]
225
+ * }
226
+ * ```
227
+ *
228
+ * > [!WARNING]
229
+ * > Object aliases use `resolve.alias`, which will not call `resolveId` hooks of other plugins.
230
+ * > Use the array form when plugin-based resolution is required.
231
+ */
232
+ alias?: AliasConfig;
201
233
  /**
202
234
  * Defaults to: `['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json']`
203
235
  */
@@ -226,6 +258,7 @@ type ResolverConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>, 'exten
226
258
  */
227
259
  external?: rolldown.InputOptions['external'];
228
260
  };
261
+ type AliasConfig = NonNullable<rolldown.InputOptions['resolve']>['alias'] | AliasEntry[];
229
262
  type TransformerConfig = Omit<TransformOptions, 'cwd' | 'lang' | 'sourceType' | 'plugins'> & {
230
263
  /**
231
264
  * Flow specific configuration.
@@ -477,4 +510,4 @@ interface RolldownConfig {
477
510
  output?: rolldown.OutputOptions;
478
511
  }
479
512
  //#endregion
480
- export { AnalyzerConfig, BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, type RollipopReactNativeFlowConfig, type RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig };
513
+ export { AliasConfig, AnalyzerConfig, BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, type RollipopReactNativeFlowConfig, type RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig };
package/dist/constants.js CHANGED
@@ -19,7 +19,7 @@ var constants_exports = /* @__PURE__ */ __exportAll({
19
19
  ROLLIPOP_VIRTUAL_ENTRY_ID: () => ROLLIPOP_VIRTUAL_ENTRY_ID,
20
20
  ROLLIPOP_VIRTUAL_PREFIX: () => ROLLIPOP_VIRTUAL_PREFIX
21
21
  });
22
- const ROLLIPOP_VERSION = "1.0.0-alpha.27";
22
+ const ROLLIPOP_VERSION = "1.0.0-alpha.28";
23
23
  const ROLLIPOP_VIRTUAL_PREFIX = "\0rollipop/";
24
24
  const ROLLIPOP_VIRTUAL_ENTRY_ID = `${ROLLIPOP_VIRTUAL_PREFIX}entry`;
25
25
  /**
@@ -1,13 +1,13 @@
1
- import { FileStorage } from "../storage/file-storage.js";
2
1
  import { Logo } from "../common/logo.js";
2
+ import { FileStorage } from "../storage/file-storage.js";
3
3
  import { resolveBuildOptions } from "../utils/build-options.js";
4
4
  import { createId } from "../utils/id.js";
5
5
  import { getOverrideOptions, getOverrideOptionsForDevServer, resolveRolldownOptions } from "./rolldown.js";
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { invariant, merge } from "es-toolkit";
9
- import * as rolldown from "@rollipop/rolldown";
10
9
  import { dev } from "@rollipop/rolldown/experimental";
10
+ import * as rolldown from "@rollipop/rolldown";
11
11
  //#region src/core/bundler.ts
12
12
  var Bundler = class Bundler {
13
13
  config;
@@ -0,0 +1,13 @@
1
+ import * as rolldown from "@rollipop/rolldown";
2
+
3
+ //#region src/core/plugins/alias-plugin.d.ts
4
+ interface AliasEntry {
5
+ find: string | RegExp;
6
+ replacement: string;
7
+ }
8
+ interface AliasPluginOptions {
9
+ entries: AliasEntry[];
10
+ }
11
+ declare function aliasPlugin(options: AliasPluginOptions): rolldown.Plugin | null;
12
+ //#endregion
13
+ export { AliasEntry, AliasPluginOptions, aliasPlugin };
@@ -0,0 +1,8 @@
1
+ import { viteAliasPlugin } from "@rollipop/rolldown/experimental";
2
+ //#region src/core/plugins/alias-plugin.ts
3
+ function aliasPlugin(options) {
4
+ if (options.entries.length === 0) return null;
5
+ return viteAliasPlugin(options);
6
+ }
7
+ //#endregion
8
+ export { aliasPlugin };
@@ -1,5 +1,5 @@
1
- import { ResolvedConfig } from "../../config/defaults.js";
2
1
  import { ResolvedHmrConfig } from "../../utils/config.js";
2
+ import { ResolvedConfig } from "../../config/defaults.js";
3
3
  import * as rolldown from "@rollipop/rolldown";
4
4
 
5
5
  //#region src/core/plugins/dev-server-plugin.d.ts
@@ -8,6 +8,8 @@ interface DevServerPluginOptions {
8
8
  hmrClientPath: ResolvedConfig['reactNative']['hmrClientPath'];
9
9
  hmrConfig: ResolvedHmrConfig | null;
10
10
  }
11
+ declare const DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS: RegExp[];
12
+ declare const DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS: RegExp[];
11
13
  declare function devServerPlugin(options: DevServerPluginOptions): Promise<rolldown.Plugin[] | null>;
12
14
  //#endregion
13
- export { DevServerPluginOptions, devServerPlugin };
15
+ export { DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS, DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS, DevServerPluginOptions, devServerPlugin };
@@ -2,6 +2,8 @@ import { resolveFrom } from "../../utils/node-resolve.js";
2
2
  import { rollipopReactRefreshWrapperPlugin } from "@rollipop/rolldown/experimental";
3
3
  import { exactRegex, id, include } from "@rollipop/rolldown/filter";
4
4
  //#region src/core/plugins/dev-server-plugin.ts
5
+ const DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS = [/\.[tj]sx?(?:$|\?)/];
6
+ const DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS = [/node_modules/];
5
7
  async function devServerPlugin(options) {
6
8
  const { cwd, hmrClientPath, hmrConfig } = options;
7
9
  if (hmrConfig == null) return null;
@@ -19,9 +21,9 @@ async function devServerPlugin(options) {
19
21
  }
20
22
  }, rollipopReactRefreshWrapperPlugin({
21
23
  cwd,
22
- include: [/\.[tj]sx?(?:$|\?)/],
23
- exclude: [/\/node_modules\//]
24
+ include: DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS,
25
+ exclude: DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS
24
26
  })];
25
27
  }
26
28
  //#endregion
27
- export { devServerPlugin };
29
+ export { DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS, DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS, devServerPlugin };
@@ -0,0 +1,11 @@
1
+ import * as rolldown from "@rollipop/rolldown";
2
+
3
+ //#region src/core/plugins/import-glob-plugin.d.ts
4
+ interface ImportGlobPluginOptions {
5
+ root?: string;
6
+ sourcemap?: boolean;
7
+ restoreQueryExtension?: boolean;
8
+ }
9
+ declare function importGlobPlugin(options: ImportGlobPluginOptions): rolldown.Plugin;
10
+ //#endregion
11
+ export { ImportGlobPluginOptions, importGlobPlugin };
@@ -0,0 +1,7 @@
1
+ import { viteImportGlobPlugin } from "@rollipop/rolldown/experimental";
2
+ //#region src/core/plugins/import-glob-plugin.ts
3
+ function importGlobPlugin(options) {
4
+ return viteImportGlobPlugin(options);
5
+ }
6
+ //#endregion
7
+ export { importGlobPlugin };
@@ -3,12 +3,14 @@ import { EntryPluginOptions, entryPlugin } from "./entry-plugin.js";
3
3
  import { BabelPluginOptions, babelPlugin } from "./babel-plugin.js";
4
4
  import { SwcPluginOptions, swcPlugin } from "./swc-plugin.js";
5
5
  import { ReporterPluginOptions, reporterPlugin } from "./reporter-plugin.js";
6
- import { DevServerPluginOptions, devServerPlugin } from "./dev-server-plugin.js";
6
+ import { DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS, DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS, DevServerPluginOptions, devServerPlugin } from "./dev-server-plugin.js";
7
7
  import { AnalyzePluginOptions, analyzePlugin } from "./analyze-plugin.js";
8
+ import { ImportGlobPluginOptions, importGlobPlugin } from "./import-glob-plugin.js";
9
+ import { AliasEntry, AliasPluginOptions, aliasPlugin } from "./alias-plugin.js";
8
10
 
9
11
  //#region src/core/plugins/index.d.ts
10
12
  declare namespace index_d_exports {
11
- export { AnalyzePluginOptions, BabelPluginOptions, DevServerPluginOptions, EntryPluginOptions, ReactNativePluginOptions, ReporterPluginOptions, SwcPluginOptions, analyzePlugin as analyze, babelPlugin as babel, devServerPlugin as devServer, entryPlugin as entry, reactNativePlugin as reactNative, reporterPlugin as reporter, swcPlugin as swc };
13
+ export { AliasEntry, AliasPluginOptions, AnalyzePluginOptions, BabelPluginOptions, DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS, DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS, DevServerPluginOptions, EntryPluginOptions, ImportGlobPluginOptions, ReactNativePluginOptions, ReporterPluginOptions, SwcPluginOptions, aliasPlugin as alias, analyzePlugin as analyze, babelPlugin as babel, devServerPlugin as devServer, entryPlugin as entry, importGlobPlugin as importGlob, reactNativePlugin as reactNative, reporterPlugin as reporter, swcPlugin as swc };
12
14
  }
13
15
  //#endregion
14
16
  export { index_d_exports };
@@ -4,14 +4,20 @@ import { entryPlugin } from "./entry-plugin.js";
4
4
  import { babelPlugin } from "./babel-plugin.js";
5
5
  import { swcPlugin } from "./swc-plugin.js";
6
6
  import { reporterPlugin } from "./reporter-plugin.js";
7
- import { devServerPlugin } from "./dev-server-plugin.js";
7
+ import { DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS, DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS, devServerPlugin } from "./dev-server-plugin.js";
8
8
  import { analyzePlugin } from "./analyze-plugin.js";
9
+ import { importGlobPlugin } from "./import-glob-plugin.js";
10
+ import { aliasPlugin } from "./alias-plugin.js";
9
11
  //#region src/core/plugins/index.ts
10
12
  var plugins_exports = /* @__PURE__ */ __exportAll({
13
+ DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS: () => DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS,
14
+ DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS: () => DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS,
15
+ alias: () => aliasPlugin,
11
16
  analyze: () => analyzePlugin,
12
17
  babel: () => babelPlugin,
13
18
  devServer: () => devServerPlugin,
14
19
  entry: () => entryPlugin,
20
+ importGlob: () => importGlobPlugin,
15
21
  reactNative: () => reactNativePlugin,
16
22
  reporter: () => reporterPlugin,
17
23
  swc: () => swcPlugin
@@ -1,6 +1,6 @@
1
1
  import { BuildType, BundlerContext } from "../types.js";
2
- import * as rolldown from "@rollipop/rolldown";
3
2
  import { RollipopReactNativePluginConfig } from "@rollipop/rolldown/experimental";
3
+ import * as rolldown from "@rollipop/rolldown";
4
4
  import { TopLevelFilterExpression } from "@rollipop/rolldown/filter";
5
5
 
6
6
  //#region src/core/plugins/react-native-plugin.d.ts
@@ -19,8 +19,10 @@ import { entryPlugin } from "./plugins/entry-plugin.js";
19
19
  import { babelPlugin } from "./plugins/babel-plugin.js";
20
20
  import { swcPlugin } from "./plugins/swc-plugin.js";
21
21
  import { reporterPlugin } from "./plugins/reporter-plugin.js";
22
- import { devServerPlugin } from "./plugins/dev-server-plugin.js";
22
+ import { DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS, DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS, devServerPlugin } from "./plugins/dev-server-plugin.js";
23
23
  import { analyzePlugin } from "./plugins/analyze-plugin.js";
24
+ import { importGlobPlugin } from "./plugins/import-glob-plugin.js";
25
+ import { aliasPlugin } from "./plugins/alias-plugin.js";
24
26
  import "./plugins/index.js";
25
27
  import fs from "node:fs";
26
28
  import path from "node:path";
@@ -45,12 +47,16 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
45
47
  const { treeshake: rolldownTreeshake, minify: rolldownMinify, lazyBarrel: rolldownLazyBarrel, ...rolldownOptimization } = config.optimization;
46
48
  const { sourcemap: rolldownSourcemap, sourcemapBaseUrl: rolldownSourcemapBaseUrl, sourcemapDebugIds: rolldownSourcemapDebugIds, sourcemapIgnoreList: rolldownSourcemapIgnoreList, sourcemapPathTransform: rolldownSourcemapPathTransform } = config;
47
49
  const userPlugins = config.plugins;
50
+ const { rolldownAlias, aliasPluginOptions } = resolveAliasPluginOptions(config);
48
51
  const mergedResolveOptions = merge({ extensions: getResolveExtensions({
49
52
  sourceExtensions,
50
53
  assetExtensions,
51
54
  platform,
52
55
  preferNativePlatform
53
- }) }, rolldownResolve);
56
+ }) }, {
57
+ ...rolldownResolve,
58
+ alias: rolldownAlias
59
+ });
54
60
  const mergedTransformOptions = merge({
55
61
  cwd: config.root,
56
62
  target: "esnext",
@@ -72,6 +78,7 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
72
78
  reactCompiler: resolveReactCompilerTransformOptions(rolldownTransform.reactCompiler)
73
79
  });
74
80
  const entryPluginOptions = resolveEntryPluginOptions(config);
81
+ const importGlobPluginOptions = resolveImportGlobPluginOptions(config);
75
82
  const reactNativePluginOptions = await resolveReactNativePluginOptions(config, context, buildOptions);
76
83
  const babelPluginOptions = resolveBabelPluginOptions(config, context);
77
84
  const swcPluginOptions = resolveSwcPluginOptions(config, context);
@@ -95,6 +102,8 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
95
102
  },
96
103
  plugins: withTransformBoundary(context, [
97
104
  entryPlugin(entryPluginOptions),
105
+ importGlobPlugin(importGlobPluginOptions),
106
+ aliasPlugin(aliasPluginOptions),
98
107
  reactNativePlugin(reactNativePluginOptions),
99
108
  babelPlugin(babelPluginOptions),
100
109
  swcPlugin(swcPluginOptions),
@@ -137,7 +146,7 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
137
146
  outro: rolldownOutro,
138
147
  intro: async (chunk) => {
139
148
  return [
140
- ...getGlobalVariables(dev, context.buildType),
149
+ ...getGlobalVariables(dev),
141
150
  ...loadPolyfills(config),
142
151
  typeof rolldownIntro === "function" ? await rolldownIntro(chunk) : rolldownIntro
143
152
  ].filter(isNotNil).join("\n");
@@ -161,6 +170,24 @@ function resolveEntryPluginOptions(config) {
161
170
  preludePaths: config.serializer.prelude
162
171
  };
163
172
  }
173
+ function resolveImportGlobPluginOptions(config) {
174
+ return {
175
+ root: config.root,
176
+ sourcemap: config.mode === "development",
177
+ restoreQueryExtension: false
178
+ };
179
+ }
180
+ function resolveAliasPluginOptions(config) {
181
+ const { alias } = config.resolver;
182
+ if (Array.isArray(alias)) return {
183
+ rolldownAlias: void 0,
184
+ aliasPluginOptions: { entries: alias }
185
+ };
186
+ return {
187
+ rolldownAlias: alias,
188
+ aliasPluginOptions: { entries: [] }
189
+ };
190
+ }
164
191
  async function resolveReactNativePluginOptions(config, context, buildOptions) {
165
192
  return {
166
193
  context,
@@ -354,7 +381,9 @@ function getOverrideOptionsForDevServer(buildOptions) {
354
381
  */
355
382
  refresh: {
356
383
  refreshReg: "$RefreshReg$",
357
- refreshSig: "$RefreshSig$"
384
+ refreshSig: "$RefreshSig$",
385
+ include: DEFAULT_REACT_REFRESH_INCLUDE_PATTERNS,
386
+ exclude: DEFAULT_REACT_REFRESH_EXCLUDE_PATTERNS
358
387
  }
359
388
  } },
360
389
  experimental: { incrementalBuild: true },
@@ -1,6 +1,6 @@
1
1
  import { FileStorage } from "../storage/file-storage.js";
2
- import * as rolldown from "@rollipop/rolldown";
3
2
  import { DevEngine, DevOptions } from "@rollipop/rolldown/experimental";
3
+ import * as rolldown from "@rollipop/rolldown";
4
4
 
5
5
  //#region src/core/types.d.ts
6
6
  interface BuildOptions {
package/dist/index.d.ts CHANGED
@@ -4,9 +4,10 @@ import { BundleDetails, DevServer, DevServerContext, DevServerEvents, FastifyIns
4
4
  import { createDevServer } from "./server/create-dev-server.js";
5
5
  import { DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH } from "./server/constants.js";
6
6
  import { Plugin, PluginConfig } from "./core/plugins/types.js";
7
+ import { index_d_exports } from "./core/plugins/index.js";
7
8
  import { InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, setupInteractiveMode } from "./node/commands/start/setup-interactive-mode.js";
8
9
  import { createCommand, createReactNativeCliCommand } from "./node/cli-utils.js";
9
- import { AnalyzerConfig, BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, RollipopReactNativeFlowConfig, RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig } from "./config/types.js";
10
+ import { AliasConfig, AnalyzerConfig, BabelTransformConfig, CodegenConfig, Config, DevModeConfig, ExperimentalConfig, FlowConfig, HmrConfig, OptimizationConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolverConfig, RolldownConfig, RollipopReactNativeFlowConfig, RollipopReactNativeWorkletsConfig, SerializerConfig, SwcTransformConfig, TerminalConfig, TransformRule, TransformerConfig, WatcherConfig } from "./config/types.js";
10
11
  import { PluginFlattenConfig, mergeConfig } from "./config/merge-config.js";
11
12
  import { DefaultConfig, InternalConfig, ResolvedConfig, getDefaultConfig } from "./config/defaults.js";
12
13
  import { DefineConfigContext, DynamicUserConfig, UserConfig, defineConfig } from "./config/define-config.js";
@@ -15,12 +16,11 @@ import { resetCache } from "./utils/reset-cache.js";
15
16
  import { runBuild } from "./utils/run-build.js";
16
17
  import { runServer } from "./utils/run-server.js";
17
18
  import { Bundler } from "./core/bundler.js";
18
- import { index_d_exports } from "./core/plugins/index.js";
19
19
  import { assets_d_exports } from "./core/assets.js";
20
20
  import { LoadEnvOptions, loadEnv } from "./core/env.js";
21
21
  import { constants_d_exports } from "./constants.js";
22
22
  import { HMRClientLogLevel, HMRClientMessage, HMRContext, HMRCustomHandler, HMRCustomMessage, HMRServerError, HMRServerMessage } from "./types/hmr.js";
23
23
  import { cli_d_exports } from "./node/cli.js";
24
- import * as rolldown from "@rollipop/rolldown";
25
24
  import * as rolldownExperimental from "@rollipop/rolldown/experimental";
26
- export { type AnalyzerConfig, assets_d_exports as AssetUtils, type AsyncResult, type BabelTransformConfig, type BuildDiagnosticLog, type BuildOptions, type BuildType, type BundleDetails, Bundler, type BundlerContext, type BundlerState, type CodegenConfig, type Config, constants_d_exports as Constants, DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH, type DeepRequired, DefaultConfig, DefineConfigContext, type DevEngine, type DevEngineOptions, type DevModeConfig, type DevServer, type DevServerContext, type DevServerEvents, DynamicUserConfig, type ExperimentalConfig, type FastifyInstance, type FlowConfig, type FormattedError, type HMRClientLogLevel, type HMRClientMessage, type HMRContext, type HMRCustomHandler, type HMRCustomMessage, type HMRServerError, type HMRServerMessage, type HmrConfig, InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, InternalConfig, LoadConfigOptions, LoadEnvOptions, type MaybePromise, type MetroCompatibleClientLogEvent, type Middlewares, type NullValue, type OptimizationConfig, type PackageJson, type Plugin, type PluginConfig, PluginFlattenConfig, type PluginOption, type Polyfill, type PolyfillOptions, type PolyfillType, type PolyfillWithCode, type PolyfillWithPath, type ReactNativeConfig, type ReportableEvent, type Reporter, ResolvedConfig, type ResolverConfig, type RolldownConfig, type RollipopReactNativeFlowConfig, type RollipopReactNativeWorkletsConfig, type SerializerConfig, type ServerOptions, type SwcTransformConfig, type TerminalConfig, type TransformRule, type TransformerConfig, UserConfig, type WatcherConfig, cli_d_exports as cli, createCommand, createDevServer, createReactNativeCliCommand, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, loadEnv, mergeConfig, index_d_exports as plugins, resetCache, resolvePluginConfig, rolldown, rolldownExperimental, runBuild, runServer, setupInteractiveMode };
25
+ import * as rolldown from "@rollipop/rolldown";
26
+ export { type AliasConfig, type AnalyzerConfig, assets_d_exports as AssetUtils, type AsyncResult, type BabelTransformConfig, type BuildDiagnosticLog, type BuildOptions, type BuildType, type BundleDetails, Bundler, type BundlerContext, type BundlerState, type CodegenConfig, type Config, constants_d_exports as Constants, DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH, type DeepRequired, DefaultConfig, DefineConfigContext, type DevEngine, type DevEngineOptions, type DevModeConfig, type DevServer, type DevServerContext, type DevServerEvents, DynamicUserConfig, type ExperimentalConfig, type FastifyInstance, type FlowConfig, type FormattedError, type HMRClientLogLevel, type HMRClientMessage, type HMRContext, type HMRCustomHandler, type HMRCustomMessage, type HMRServerError, type HMRServerMessage, type HmrConfig, InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, InternalConfig, LoadConfigOptions, LoadEnvOptions, type MaybePromise, type MetroCompatibleClientLogEvent, type Middlewares, type NullValue, type OptimizationConfig, type PackageJson, type Plugin, type PluginConfig, PluginFlattenConfig, type PluginOption, type Polyfill, type PolyfillOptions, type PolyfillType, type PolyfillWithCode, type PolyfillWithPath, type ReactNativeConfig, type ReportableEvent, type Reporter, ResolvedConfig, type ResolverConfig, type RolldownConfig, type RollipopReactNativeFlowConfig, type RollipopReactNativeWorkletsConfig, type SerializerConfig, type ServerOptions, type SwcTransformConfig, type TerminalConfig, type TransformRule, type TransformerConfig, UserConfig, type WatcherConfig, cli_d_exports as cli, createCommand, createDevServer, createReactNativeCliCommand, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, loadEnv, mergeConfig, index_d_exports as plugins, resetCache, resolvePluginConfig, rolldown, rolldownExperimental, runBuild, runServer, setupInteractiveMode };
package/dist/index.js CHANGED
@@ -17,6 +17,6 @@ import { runServer } from "./utils/run-server.js";
17
17
  import { setupInteractiveMode } from "./node/commands/start/setup-interactive-mode.js";
18
18
  import { createCommand, createReactNativeCliCommand } from "./node/cli-utils.js";
19
19
  import { cli_exports } from "./node/cli.js";
20
- import * as rolldown from "@rollipop/rolldown";
21
20
  import * as rolldownExperimental from "@rollipop/rolldown/experimental";
21
+ import * as rolldown from "@rollipop/rolldown";
22
22
  export { assets_exports as AssetUtils, Bundler, constants_exports as Constants, DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH, cli_exports as cli, createCommand, createDevServer, createReactNativeCliCommand, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, loadEnv, mergeConfig, plugins_exports as plugins, resetCache, resolvePluginConfig, rolldown, rolldownExperimental, runBuild, runServer, setupInteractiveMode };
@@ -9,16 +9,13 @@ function getInitializeCorePath(basePath) {
9
9
  function getPolyfillScriptPaths(reactNativePath) {
10
10
  return __require(path.join(reactNativePath, "rn-get-polyfills"))();
11
11
  }
12
- function getGlobalVariables(dev, buildType) {
13
- const isDevServerMode = dev && buildType === "serve";
12
+ function getGlobalVariables(dev) {
14
13
  return [
15
14
  `var __BUNDLE_START_TIME__ = globalThis.nativePerformanceNow ? nativePerformanceNow() : Date.now();`,
16
15
  `var __DEV__ = ${asLiteral(dev)};`,
17
16
  `var process = globalThis.process || {};`,
18
17
  "process.env = process.env || {};",
19
- `process.env.NODE_ENV = process.env.NODE_ENV || ${asLiteral(dev ? "development" : "production")};`,
20
- isDevServerMode ? `var $RefreshReg$ = () => {};` : null,
21
- isDevServerMode ? `var $RefreshSig$ = () => (v) => v;` : null
18
+ `process.env.NODE_ENV = process.env.NODE_ENV || ${asLiteral(dev ? "development" : "production")};`
22
19
  ].filter(isNotNil);
23
20
  }
24
21
  //#endregion
@@ -15,7 +15,7 @@ const action = async function(options) {
15
15
  context: { command: "bundle" }
16
16
  });
17
17
  if (options.resetCache) {
18
- resetCache(cwd);
18
+ await resetCache();
19
19
  logger.info("The transform cache was reset");
20
20
  }
21
21
  if (options.entryFile) config.entry = path.resolve(cwd, options.entryFile);
@@ -7,15 +7,14 @@ import "../../../index.js";
7
7
  import { noop } from "es-toolkit";
8
8
  //#region src/node/commands/start/action.ts
9
9
  const action = async function(options) {
10
- const cwd = process.cwd();
11
10
  const config = await loadConfig({
12
- cwd,
11
+ cwd: process.cwd(),
13
12
  mode: "development",
14
13
  configFile: options.config,
15
14
  context: { command: "start" }
16
15
  });
17
16
  if (options.resetCache) {
18
- resetCache(cwd);
17
+ await resetCache();
19
18
  logger.info("The transform cache was reset");
20
19
  }
21
20
  if (options.clientLogs === false) config.reporter = { update: noop };
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.0.0-alpha.27";
2
+ var version = "1.0.0-alpha.28";
3
3
  //#endregion
4
4
  export { version };
@@ -9,7 +9,7 @@ import fp from "fastify-plugin";
9
9
  function createMcpServer(options) {
10
10
  const server = new McpServer({
11
11
  name: "rollipop",
12
- version: "1.0.0-alpha.27"
12
+ version: "1.0.0-alpha.28"
13
13
  }, { capabilities: { logging: {} } });
14
14
  registerTools(server, options);
15
15
  return server;
@@ -31,7 +31,7 @@ function registerTools(server, options) {
31
31
  description: "Clear the build cache.",
32
32
  inputSchema: emptyArgs,
33
33
  async handler() {
34
- resetCache(context.config.root);
34
+ await resetCache();
35
35
  context.eventBus.emit({ type: "cache_reset" });
36
36
  return textResult("Cache cleared successfully.");
37
37
  }
@@ -7,8 +7,8 @@ const actionsRest = fp((fastify, options) => {
7
7
  context.message.broadcast("reload");
8
8
  return { reloaded: true };
9
9
  });
10
- fastify.post("/reset-cache", () => {
11
- resetCache(context.config.root);
10
+ fastify.post("/reset-cache", async () => {
11
+ await resetCache();
12
12
  context.eventBus.emit({ type: "cache_reset" });
13
13
  return { reset: true };
14
14
  });
@@ -28,7 +28,7 @@ var FileStorage = class FileStorage {
28
28
  this.dataFilePath = path.join(FileStorage.getPath(basePath, { prepare: true }), DATA_FILENAME);
29
29
  if (fs.existsSync(this.dataFilePath)) {
30
30
  const loadedData = JSON.parse(fs.readFileSync(this.dataFilePath, "utf-8"));
31
- if ("version" in loadedData && loadedData.version === "1.0.0-alpha.27") this.data = loadedData;
31
+ if ("version" in loadedData && loadedData.version === "1.0.0-alpha.28") this.data = loadedData;
32
32
  else {
33
33
  this.data = createDefaultData();
34
34
  this.flush();
@@ -1,8 +1,7 @@
1
1
  //#region src/utils/reset-cache.d.ts
2
2
  /**
3
- * Remove the entire build cache directory for the given project root.
4
- * Backs the `reset_cache` MCP tool and the `--reset-cache` CLI flag.
3
+ * Clear the build cache.
5
4
  */
6
- declare function resetCache(projectRoot: string): void;
5
+ declare function resetCache(): Promise<void>;
7
6
  //#endregion
8
7
  export { resetCache };
@@ -1,25 +1,10 @@
1
- import { FileStorage } from "../storage/file-storage.js";
2
- import fs from "node:fs";
3
- import path from "node:path";
1
+ import * as rolldownExperimental from "@rollipop/rolldown/experimental";
4
2
  //#region src/utils/reset-cache.ts
5
3
  /**
6
- * Resolve the build cache directory for the given project root. The cache
7
- * itself is owned by rolldown's native implementation; we keep the path
8
- * here only because `resetCache` — and any tooling that wants to inspect
9
- * the on-disk layout — needs to know where to look.
4
+ * Clear the build cache.
10
5
  */
11
- function getCacheDirectory(projectRoot) {
12
- return path.join(FileStorage.getPath(projectRoot), "cache");
13
- }
14
- /**
15
- * Remove the entire build cache directory for the given project root.
16
- * Backs the `reset_cache` MCP tool and the `--reset-cache` CLI flag.
17
- */
18
- function resetCache(projectRoot) {
19
- fs.rmSync(getCacheDirectory(projectRoot), {
20
- recursive: true,
21
- force: true
22
- });
6
+ function resetCache() {
7
+ return rolldownExperimental.clearCache();
23
8
  }
24
9
  //#endregion
25
10
  export { resetCache };
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @see https://github.com/vitejs/vite/blob/3dcf7bd9418e02282cbfa0254ace59fe702c11bd/packages/vite/types/importGlob.d.ts
3
+ */
4
+
5
+ // make input suggestions work
6
+ type StringQueryType = `?${keyof KnownAsTypeMap}` | (string & {});
7
+ type BaseQueryType = StringQueryType | Record<string, string | number | boolean>;
8
+
9
+ export interface ImportGlobOptions<
10
+ Eager extends boolean,
11
+ AsType extends string,
12
+ QueryType extends BaseQueryType,
13
+ > {
14
+ /**
15
+ * Import type for the import url.
16
+ *
17
+ * @deprecated Use `query` instead, e.g. `as: 'url'` -> `query: '?url', import: 'default'`
18
+ */
19
+ as?: AsType;
20
+ /**
21
+ * Import as static or dynamic
22
+ *
23
+ * @default false
24
+ */
25
+ eager?: Eager;
26
+ /**
27
+ * Import only the specific named export. Set to `default` to import the default export.
28
+ */
29
+ import?: string;
30
+ /**
31
+ * Custom queries
32
+ */
33
+ query?: QueryType;
34
+ /**
35
+ * Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
36
+ *
37
+ * @default false
38
+ */
39
+ exhaustive?: boolean;
40
+ /**
41
+ * Base path to resolve relative paths.
42
+ */
43
+ base?: string;
44
+ /**
45
+ * Whether the glob pattern matching should be case-sensitive. Defaults to `true`.
46
+ */
47
+ caseSensitive?: boolean;
48
+ }
49
+
50
+ export type ImportGlobOptionsWithoutAs<
51
+ Eager extends boolean,
52
+ QueryType extends BaseQueryType,
53
+ > = Omit<ImportGlobOptions<Eager, string, QueryType>, 'as'> & {
54
+ as?: never;
55
+ };
56
+
57
+ export type GeneralImportGlobOptions = ImportGlobOptions<boolean, string, BaseQueryType>;
58
+
59
+ /**
60
+ * Declare Worker in case DOM is not added to the tsconfig lib causing
61
+ * Worker interface is not defined. For developers with DOM lib added,
62
+ * the Worker interface will be merged correctly.
63
+ */
64
+ declare global {
65
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
66
+ interface Worker {}
67
+ }
68
+
69
+ export interface KnownAsTypeMap {
70
+ raw: string;
71
+ url: string;
72
+ worker: Worker;
73
+ }
74
+
75
+ type KnownQueryTypeMap = {
76
+ [K in keyof KnownAsTypeMap as `?${K}`]: KnownAsTypeMap[K];
77
+ };
78
+
79
+ export interface ImportGlobFunction {
80
+ /**
81
+ * Import a list of files with a glob pattern.
82
+ *
83
+ * Overload 1A: No generic provided, infer the type from `eager` and `query`
84
+ */
85
+ <
86
+ Eager extends boolean,
87
+ Query extends BaseQueryType,
88
+ T = Query extends keyof KnownQueryTypeMap ? KnownQueryTypeMap[Query] : unknown,
89
+ >(
90
+ glob: string | string[],
91
+ options?: ImportGlobOptionsWithoutAs<Eager, Query>,
92
+ ): (Eager extends true ? true : false) extends true
93
+ ? Record<string, T>
94
+ : Record<string, () => Promise<T>>;
95
+ /**
96
+ * Import a list of files with a glob pattern.
97
+ *
98
+ * Overload 1B: No generic provided, infer the type from `eager` and `as`
99
+ * (deprecated, use `query` instead)
100
+ */
101
+ <
102
+ Eager extends boolean,
103
+ As extends string,
104
+ T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown,
105
+ >(
106
+ glob: string | string[],
107
+ options?: ImportGlobOptions<Eager, As, BaseQueryType>,
108
+ ): (Eager extends true ? true : false) extends true
109
+ ? Record<string, T>
110
+ : Record<string, () => Promise<T>>;
111
+ /**
112
+ * Import a list of files with a glob pattern.
113
+ *
114
+ * Overload 2: Module generic provided, infer the type from `eager: false`
115
+ */
116
+ <M>(
117
+ glob: string | string[],
118
+ options?: ImportGlobOptions<false, string, BaseQueryType>,
119
+ ): Record<string, () => Promise<M>>;
120
+ /**
121
+ * Import a list of files with a glob pattern.
122
+ *
123
+ * Overload 3: Module generic provided, infer the type from `eager: true`
124
+ */
125
+ <M>(
126
+ glob: string | string[],
127
+ options: ImportGlobOptions<true, string, BaseQueryType>,
128
+ ): Record<string, M>;
129
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollipop",
3
- "version": "1.0.0-alpha.27",
3
+ "version": "1.0.0-alpha.28",
4
4
  "stableVersion": "1.0.0-alpha.23",
5
5
  "homepage": "https://github.com/rollipop-dev/rollipop#readme",
6
6
  "bugs": {
@@ -16,6 +16,7 @@
16
16
  "bin": "./bin/index.js",
17
17
  "files": [
18
18
  "client.d.ts",
19
+ "import-glob.d.ts",
19
20
  "bin",
20
21
  "dist",
21
22
  "skills",
@@ -70,8 +71,8 @@
70
71
  "@react-native-community/cli-types": "20.1.3",
71
72
  "@react-native/babel-plugin-codegen": "0.86.0",
72
73
  "@react-native/dev-middleware": "0.86.0",
73
- "@rollipop/dashboard": "1.0.0-alpha.27",
74
- "@rollipop/rolldown": "1.0.20",
74
+ "@rollipop/dashboard": "1.0.0-alpha.28",
75
+ "@rollipop/rolldown": "1.0.21",
75
76
  "@swc/core": "1.15.41",
76
77
  "@swc/helpers": "0.5.23",
77
78
  "@types/ws": "8.18.1",