rollipop 1.0.0-alpha.21 → 1.0.0-alpha.23
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/CHANGELOG.md +19 -0
- package/dist/{chunk-DEq-mXcV.js → _virtual/_rolldown/runtime.js} +1 -1
- package/dist/commands.d.ts +2 -4
- package/dist/commands.js +10 -3957
- package/dist/common/code.js +21 -0
- package/dist/common/constants.js +5 -0
- package/dist/common/env.js +33 -0
- package/dist/common/logger.d.ts +34 -0
- package/dist/common/logger.js +82 -0
- package/dist/common/logo.js +54 -0
- package/dist/common/progress-bar.js +167 -0
- package/dist/common/transformer.js +13 -0
- package/dist/common/types.d.ts +10 -0
- package/dist/config/compose-override.js +18 -0
- package/dist/config/defaults.d.ts +74 -0
- package/dist/config/defaults.js +74 -0
- package/dist/config/define-config.d.ts +13 -0
- package/dist/config/define-config.js +6 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.js +5 -0
- package/dist/config/load-config.d.ts +19 -0
- package/dist/config/load-config.js +73 -0
- package/dist/config/merge-config.d.ts +12 -0
- package/dist/config/merge-config.js +20 -0
- package/dist/config/types.d.ts +452 -0
- package/dist/constants.d.ts +35 -0
- package/dist/constants.js +146 -0
- package/dist/core/assets.d.ts +91 -0
- package/dist/core/assets.js +244 -0
- package/dist/core/bundler.d.ts +15 -0
- package/dist/core/bundler.js +80 -0
- package/dist/core/env.d.ts +11 -0
- package/dist/core/env.js +36 -0
- package/dist/core/fs/data.js +9 -0
- package/dist/core/fs/storage.d.ts +15 -0
- package/dist/core/fs/storage.js +31 -0
- package/dist/core/plugins/babel-plugin.d.ts +22 -0
- package/dist/core/plugins/babel-plugin.js +74 -0
- package/dist/core/plugins/context.d.ts +10 -0
- package/dist/core/plugins/context.js +24 -0
- package/dist/core/plugins/dev-server-plugin.d.ts +13 -0
- package/dist/core/plugins/dev-server-plugin.js +27 -0
- package/dist/core/plugins/index.d.ts +13 -0
- package/dist/core/plugins/index.js +18 -0
- package/dist/core/plugins/prelude-plugin.d.ts +10 -0
- package/dist/core/plugins/prelude-plugin.js +23 -0
- package/dist/core/plugins/react-native-plugin.d.ts +36 -0
- package/dist/core/plugins/react-native-plugin.js +81 -0
- package/dist/core/plugins/reporter-plugin.d.ts +11 -0
- package/dist/core/plugins/reporter-plugin.js +87 -0
- package/dist/core/plugins/shared/filters.js +5 -0
- package/dist/core/plugins/swc-plugin.d.ts +26 -0
- package/dist/core/plugins/swc-plugin.js +108 -0
- package/dist/core/plugins/types.d.ts +18 -0
- package/dist/core/plugins/utils/source.js +10 -0
- package/dist/core/plugins/utils/transform-utils.js +56 -0
- package/dist/core/rolldown.js +313 -0
- package/dist/core/settings.js +19 -0
- package/dist/core/types.d.ts +83 -0
- package/dist/filter.d.ts +1 -0
- package/dist/filter.js +2 -0
- package/dist/hmr-runtime.iife.js +5 -5
- package/dist/index.d.ts +24 -1221
- package/dist/index.js +19 -4029
- package/dist/internal/react-native.js +24 -0
- package/dist/logger.js +5 -0
- package/dist/node/cli-utils.d.ts +10 -0
- package/dist/node/cli-utils.js +28 -0
- package/dist/node/cli.d.ts +6 -0
- package/dist/node/cli.js +23 -0
- package/dist/node/commands/agent/action.js +91 -0
- package/dist/node/commands/agent/command.js +10 -0
- package/dist/node/commands/agent/index.js +2 -0
- package/dist/node/commands/bundle/action.js +33 -0
- package/dist/node/commands/bundle/command.js +96 -0
- package/dist/node/commands/bundle/index.js +2 -0
- package/dist/node/commands/start/action.js +37 -0
- package/dist/node/commands/start/command.js +93 -0
- package/dist/node/commands/start/debugger.js +79 -0
- package/dist/node/commands/start/index.js +2 -0
- package/dist/node/commands/start/setup-interactive-mode.d.ts +20 -0
- package/dist/node/commands/start/setup-interactive-mode.js +107 -0
- package/dist/node/constants.js +4 -0
- package/dist/node/logger.js +5 -0
- package/dist/node/types.d.ts +23 -0
- package/dist/node/utils.js +23 -0
- package/dist/package.js +4 -0
- package/dist/runtime.js +1 -1
- package/dist/server/bundle.d.ts +12 -0
- package/dist/server/bundle.js +55 -0
- package/dist/server/bundler-pool.d.ts +51 -0
- package/dist/server/bundler-pool.js +197 -0
- package/dist/server/common/schema.js +19 -0
- package/dist/server/constants.d.ts +6 -0
- package/dist/server/constants.js +6 -0
- package/dist/server/create-dev-server.d.ts +6 -0
- package/dist/server/create-dev-server.js +185 -0
- package/dist/server/error.js +9 -0
- package/dist/server/events/event-bus.d.ts +12 -0
- package/dist/server/events/event-bus.js +16 -0
- package/dist/server/events/types.d.ts +37 -0
- package/dist/server/events/types.js +6 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +3 -0
- package/dist/server/logger.js +33 -0
- package/dist/server/mcp/context.js +14 -0
- package/dist/server/mcp/server.js +86 -0
- package/dist/server/mcp/tools/app-log-diagnostics.js +37 -0
- package/dist/server/mcp/tools/build-diagnostics.js +97 -0
- package/dist/server/mcp/tools/build-info.js +33 -0
- package/dist/server/mcp/tools/device-diagnostics.js +52 -0
- package/dist/server/mcp/tools/index.js +277 -0
- package/dist/server/middlewares/request-logger.js +15 -0
- package/dist/server/middlewares/serve-assets.js +49 -0
- package/dist/server/middlewares/serve-bundle.js +72 -0
- package/dist/server/middlewares/sse.js +34 -0
- package/dist/server/middlewares/symbolicate.js +71 -0
- package/dist/server/sse/adapter.js +74 -0
- package/dist/server/sse/event-bus.js +26 -0
- package/dist/server/symbolicate.js +93 -0
- package/dist/server/types.d.ts +125 -0
- package/dist/server/wss/hmr-server.js +209 -0
- package/dist/server/wss/server.d.ts +9 -0
- package/dist/server/wss/server.js +70 -0
- package/dist/{runtime.d.cts → types/hmr.d.ts} +1 -12
- package/dist/types.d.ts +78 -0
- package/dist/utils/babel.js +11 -0
- package/dist/utils/build-options.js +17 -0
- package/dist/utils/bundle.js +6 -0
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.js +32 -0
- package/dist/utils/dev-server.js +51 -0
- package/dist/utils/env.js +7 -0
- package/dist/utils/errors.js +9 -0
- package/dist/utils/hash.js +8 -0
- package/dist/utils/id.js +28 -0
- package/dist/utils/node-resolve.js +42 -0
- package/dist/utils/promise.js +15 -0
- package/dist/utils/reporters.js +120 -0
- package/dist/utils/reset-cache.d.ts +8 -0
- package/dist/utils/reset-cache.js +25 -0
- package/dist/utils/response.js +91 -0
- package/dist/utils/run-build.d.ts +8 -0
- package/dist/utils/run-build.js +7 -0
- package/dist/utils/run-server.d.ts +6 -0
- package/dist/utils/run-server.js +20 -0
- package/dist/utils/runtime-target.js +9 -0
- package/dist/utils/serialize.js +10 -0
- package/dist/utils/server.js +6 -0
- package/dist/utils/storage.js +6 -0
- package/dist/utils/string.js +6 -0
- package/dist/utils/swc.js +10 -0
- package/dist/utils/terminal.js +86 -0
- package/dist/utils/url.js +23 -0
- package/package.json +56 -68
- package/dist/commands.cjs +0 -4008
- package/dist/commands.d.cts +0 -5
- package/dist/pluginutils.d.ts +0 -1
- package/dist/pluginutils.js +0 -2
- package/dist/runtime.cjs +0 -34
- /package/dist/{chunk-DXpK5_cz.js → chunk-DJV587Yu.js} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { id, include } from "@rollipop/rolldown/filter";
|
|
2
|
+
//#region src/core/plugins/utils/transform-utils.ts
|
|
3
|
+
const TRANSFORM_FLAGS_KEY = Symbol("transform-flags");
|
|
4
|
+
const REVISION_KEY = Symbol("revision");
|
|
5
|
+
function setFlag(context, id, flag, options) {
|
|
6
|
+
const revision = context.state.revision;
|
|
7
|
+
const moduleInfo = this.getModuleInfo(id);
|
|
8
|
+
if (moduleInfo) {
|
|
9
|
+
const meta = moduleInfo.meta;
|
|
10
|
+
if (options?.override) meta[TRANSFORM_FLAGS_KEY] = flag;
|
|
11
|
+
else if (isCurrentRevision(moduleInfo.meta, revision)) moduleInfo.meta[TRANSFORM_FLAGS_KEY] |= flag;
|
|
12
|
+
else meta[TRANSFORM_FLAGS_KEY] = flag;
|
|
13
|
+
meta[REVISION_KEY] = revision;
|
|
14
|
+
return moduleInfo.meta;
|
|
15
|
+
} else return {
|
|
16
|
+
[TRANSFORM_FLAGS_KEY]: flag,
|
|
17
|
+
[REVISION_KEY]: revision
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function hasFlag(meta) {
|
|
21
|
+
return TRANSFORM_FLAGS_KEY in meta;
|
|
22
|
+
}
|
|
23
|
+
function getFlag(context, id) {
|
|
24
|
+
return getFlagFromModuleInfo(context, this.getModuleInfo(id));
|
|
25
|
+
}
|
|
26
|
+
function getFlagFromModuleInfo(context, moduleInfo) {
|
|
27
|
+
if (moduleInfo && isCurrentRevision(moduleInfo.meta, context.state.revision)) return moduleInfo.meta[TRANSFORM_FLAGS_KEY];
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
function isCurrentRevision(meta, revision) {
|
|
31
|
+
return hasFlag(meta) && meta[REVISION_KEY] === revision;
|
|
32
|
+
}
|
|
33
|
+
function withTransformBoundary(context, plugins) {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
name: "rollipop:build-initializer",
|
|
37
|
+
buildStart() {
|
|
38
|
+
context.state.revision += 1;
|
|
39
|
+
context.state.latestBuildStartTime = Date.now();
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "rollipop:transform-skip-json",
|
|
44
|
+
transform: {
|
|
45
|
+
order: "pre",
|
|
46
|
+
filter: [include(id(/\.json$/))],
|
|
47
|
+
handler(_code, id) {
|
|
48
|
+
return { meta: setFlag.call(this, context, id, 128) };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
plugins
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { getFlag, setFlag, withTransformBoundary };
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { isDebugEnabled } from "../common/env.js";
|
|
2
|
+
import { getGlobalVariables } from "../internal/react-native.js";
|
|
3
|
+
import { resolveFrom, resolvePackageJson } from "../utils/node-resolve.js";
|
|
4
|
+
import { CompatStatusReporter, ProgressBarStatusReporter, mergeReporters } from "../utils/reporters.js";
|
|
5
|
+
import { printPluginLog } from "./plugins/context.js";
|
|
6
|
+
import { applyOverrideRolldownOptions } from "../config/compose-override.js";
|
|
7
|
+
import { asLiteral, iife, nodeEnvironment } from "../common/code.js";
|
|
8
|
+
import { resolveHmrConfig } from "../utils/config.js";
|
|
9
|
+
import { defineEnvFromObject } from "../utils/env.js";
|
|
10
|
+
import { resolveRuntimeTarget } from "../utils/runtime-target.js";
|
|
11
|
+
import { getBaseUrl } from "../utils/server.js";
|
|
12
|
+
import { getBuildTotalModules } from "../utils/storage.js";
|
|
13
|
+
import { loadEnv } from "./env.js";
|
|
14
|
+
import { withTransformBoundary } from "./plugins/utils/transform-utils.js";
|
|
15
|
+
import { reactNativePlugin } from "./plugins/react-native-plugin.js";
|
|
16
|
+
import { preludePlugin } from "./plugins/prelude-plugin.js";
|
|
17
|
+
import { babelPlugin } from "./plugins/babel-plugin.js";
|
|
18
|
+
import { swcPlugin } from "./plugins/swc-plugin.js";
|
|
19
|
+
import { reporterPlugin } from "./plugins/reporter-plugin.js";
|
|
20
|
+
import { devServerPlugin } from "./plugins/dev-server-plugin.js";
|
|
21
|
+
import "./plugins/index.js";
|
|
22
|
+
import fs from "node:fs";
|
|
23
|
+
import path from "node:path";
|
|
24
|
+
import { invariant, isNotNil, merge } from "es-toolkit";
|
|
25
|
+
//#region src/core/rolldown.ts
|
|
26
|
+
async function resolveRolldownOptions(context, config, buildOptions, devEngineOptions) {
|
|
27
|
+
const cachedOptions = resolveRolldownOptions.cache.get(context.id);
|
|
28
|
+
if (cachedOptions != null) return cachedOptions;
|
|
29
|
+
const { platform, dev, cache } = buildOptions;
|
|
30
|
+
const isDevServerMode = dev && context.buildType === "serve";
|
|
31
|
+
invariant(isDevServerMode ? devEngineOptions != null : true, "devEngineOptions is required in dev server mode");
|
|
32
|
+
const env = loadEnv(config);
|
|
33
|
+
const builtInEnv = {
|
|
34
|
+
MODE: config.mode,
|
|
35
|
+
...isDevServerMode ? { BASE_URL: getBaseUrl(devEngineOptions.host, devEngineOptions.port, devEngineOptions.https) } : null
|
|
36
|
+
};
|
|
37
|
+
const hmrConfig = resolveHmrConfig(config);
|
|
38
|
+
const hmrEnabled = hmrConfig != null;
|
|
39
|
+
const { sourceExtensions, assetExtensions, preferNativePlatform, external: rolldownExternal, ...rolldownResolve } = config.resolver;
|
|
40
|
+
const { polyfills, banner: rolldownBanner, footer: rolldownFooter, postBanner: rolldownPostBanner, postFooter: rolldownPostFooter, intro: rolldownIntro, outro: rolldownOutro, shimMissingExports: rolldownShimMissingExports } = config.serializer;
|
|
41
|
+
const { flow: _flow, babel: _babel, swc: _swc, ...rolldownTransform } = config.transformer;
|
|
42
|
+
const { treeshake: rolldownTreeshake, minify: rolldownMinify, lazyBarrel: rolldownLazyBarrel, ...rolldownOptimization } = config.optimization;
|
|
43
|
+
const { globalIdentifiers: rolldownGlobalIdentifiers } = config.reactNative;
|
|
44
|
+
const { sourcemap: rolldownSourcemap, sourcemapBaseUrl: rolldownSourcemapBaseUrl, sourcemapDebugIds: rolldownSourcemapDebugIds, sourcemapIgnoreList: rolldownSourcemapIgnoreList, sourcemapPathTransform: rolldownSourcemapPathTransform } = config;
|
|
45
|
+
const userPlugins = config.plugins;
|
|
46
|
+
const mergedResolveOptions = merge({ extensions: getResolveExtensions({
|
|
47
|
+
sourceExtensions,
|
|
48
|
+
assetExtensions,
|
|
49
|
+
platform,
|
|
50
|
+
preferNativePlatform
|
|
51
|
+
}) }, rolldownResolve);
|
|
52
|
+
const mergedTransformOptions = merge({
|
|
53
|
+
cwd: config.root,
|
|
54
|
+
target: "esnext",
|
|
55
|
+
jsx: {
|
|
56
|
+
runtime: "automatic",
|
|
57
|
+
development: dev
|
|
58
|
+
},
|
|
59
|
+
define: {
|
|
60
|
+
__DEV__: asLiteral(dev),
|
|
61
|
+
"process.env.NODE_ENV": asLiteral(nodeEnvironment(dev)),
|
|
62
|
+
"process.env.DEBUG_ROLLIPOP": asLiteral(isDebugEnabled()),
|
|
63
|
+
...hmrEnabled ? null : { "import.meta.hot": "{}" },
|
|
64
|
+
...defineEnvFromObject(env),
|
|
65
|
+
...defineEnvFromObject(builtInEnv)
|
|
66
|
+
},
|
|
67
|
+
helpers: { mode: "Runtime" }
|
|
68
|
+
}, rolldownTransform);
|
|
69
|
+
const preludePluginOptions = resolvePreludePluginOptions(config);
|
|
70
|
+
const reactNativePluginOptions = await resolveReactNativePluginOptions(config, context, buildOptions);
|
|
71
|
+
const babelPluginOptions = resolveBabelPluginOptions(config, context);
|
|
72
|
+
const swcPluginOptions = resolveSwcPluginOptions(config, context);
|
|
73
|
+
const devServerPluginOptions = resolveDevServerPluginOptions(config, hmrConfig);
|
|
74
|
+
const reporterPluginOptions = resolveReporterPluginOptions(config, context, buildOptions);
|
|
75
|
+
const finalOptions = await applyDangerouslyOverrideOptionsFinalizer(config, {
|
|
76
|
+
platform: "neutral",
|
|
77
|
+
cwd: config.root,
|
|
78
|
+
input: config.entry,
|
|
79
|
+
tsconfig: config.tsconfig,
|
|
80
|
+
resolve: mergedResolveOptions,
|
|
81
|
+
transform: mergedTransformOptions,
|
|
82
|
+
treeshake: rolldownTreeshake,
|
|
83
|
+
external: rolldownExternal,
|
|
84
|
+
shimMissingExports: rolldownShimMissingExports,
|
|
85
|
+
optimization: rolldownOptimization,
|
|
86
|
+
experimental: {
|
|
87
|
+
lazyBarrel: rolldownLazyBarrel,
|
|
88
|
+
...isDevServerMode ? { devMode: hmrConfig ? { implement: hmrConfig.runtimeImplement } : false } : null
|
|
89
|
+
},
|
|
90
|
+
plugins: withTransformBoundary(context, [
|
|
91
|
+
preludePlugin(preludePluginOptions),
|
|
92
|
+
reactNativePlugin(reactNativePluginOptions),
|
|
93
|
+
babelPlugin(babelPluginOptions),
|
|
94
|
+
swcPlugin(swcPluginOptions),
|
|
95
|
+
devServerPlugin(devServerPluginOptions),
|
|
96
|
+
reporterPlugin(reporterPluginOptions),
|
|
97
|
+
userPlugins
|
|
98
|
+
]),
|
|
99
|
+
checks: {
|
|
100
|
+
/**
|
|
101
|
+
* Disable eval check because react-native uses `eval` to execute code.
|
|
102
|
+
*/
|
|
103
|
+
eval: false,
|
|
104
|
+
pluginTimings: isDebugEnabled()
|
|
105
|
+
},
|
|
106
|
+
logLevel: isDebugEnabled() ? "debug" : "info",
|
|
107
|
+
onLog(level, log, defaultHandler) {
|
|
108
|
+
const diagnostic = toBuildDiagnosticLog(log);
|
|
109
|
+
if (level === "warn") config.reporter?.update({
|
|
110
|
+
type: "build_error",
|
|
111
|
+
level,
|
|
112
|
+
log: diagnostic
|
|
113
|
+
});
|
|
114
|
+
else if (isPluginLog(log)) config.reporter?.update({
|
|
115
|
+
type: "build_log",
|
|
116
|
+
level,
|
|
117
|
+
log: diagnostic
|
|
118
|
+
});
|
|
119
|
+
if (log.code?.startsWith("PLUGIN_")) printPluginLog(level, log, log.plugin);
|
|
120
|
+
else defaultHandler(level, log);
|
|
121
|
+
},
|
|
122
|
+
id: context.id
|
|
123
|
+
}, {
|
|
124
|
+
format: "esm",
|
|
125
|
+
file: buildOptions.outfile,
|
|
126
|
+
banner: rolldownBanner,
|
|
127
|
+
footer: rolldownFooter,
|
|
128
|
+
postFooter: rolldownPostFooter,
|
|
129
|
+
postBanner: rolldownPostBanner,
|
|
130
|
+
outro: rolldownOutro,
|
|
131
|
+
intro: async (chunk) => {
|
|
132
|
+
return [
|
|
133
|
+
...getGlobalVariables(dev, context.buildType),
|
|
134
|
+
...loadPolyfills(polyfills),
|
|
135
|
+
typeof rolldownIntro === "function" ? await rolldownIntro(chunk) : rolldownIntro
|
|
136
|
+
].filter(isNotNil).join("\n");
|
|
137
|
+
},
|
|
138
|
+
minify: buildOptions.minify ?? rolldownMinify,
|
|
139
|
+
sourcemap: buildOptions.sourcemap ?? rolldownSourcemap,
|
|
140
|
+
sourcemapBaseUrl: rolldownSourcemapBaseUrl,
|
|
141
|
+
sourcemapDebugIds: rolldownSourcemapDebugIds,
|
|
142
|
+
sourcemapIgnoreList: rolldownSourcemapIgnoreList,
|
|
143
|
+
sourcemapPathTransform: rolldownSourcemapPathTransform ?? createProjectRootSourcemapPathTransform(config.root),
|
|
144
|
+
codeSplitting: false,
|
|
145
|
+
strictExecutionOrder: true,
|
|
146
|
+
globalIdentifiers: rolldownGlobalIdentifiers,
|
|
147
|
+
persistentCache: cache
|
|
148
|
+
});
|
|
149
|
+
resolveRolldownOptions.cache.set(context.id, finalOptions);
|
|
150
|
+
return finalOptions;
|
|
151
|
+
}
|
|
152
|
+
resolveRolldownOptions.cache = /* @__PURE__ */ new Map();
|
|
153
|
+
function resolvePreludePluginOptions(config) {
|
|
154
|
+
return {
|
|
155
|
+
entryPath: config.entry,
|
|
156
|
+
modulePaths: config.serializer.prelude
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
async function resolveReactNativePluginOptions(config, context, buildOptions) {
|
|
160
|
+
return {
|
|
161
|
+
context,
|
|
162
|
+
projectRoot: config.root,
|
|
163
|
+
platform: buildOptions.platform,
|
|
164
|
+
preferNativePlatform: config.resolver.preferNativePlatform,
|
|
165
|
+
buildType: context.buildType,
|
|
166
|
+
assetsDir: buildOptions.assetsDir,
|
|
167
|
+
assetExtensions: config.resolver.assetExtensions,
|
|
168
|
+
assetRegistryPath: await resolveAssetRegistryPath(config),
|
|
169
|
+
flowFilter: config.transformer.flow?.filter ?? [],
|
|
170
|
+
codegenFilter: config.reactNative.codegen?.filter ?? [],
|
|
171
|
+
builtinPluginConfig: resolveReactNativeBuiltinPluginConfig(config)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
async function resolveAssetRegistryPath(config) {
|
|
175
|
+
const { assetRegistryPath } = config.reactNative;
|
|
176
|
+
const path = typeof assetRegistryPath === "function" ? await assetRegistryPath(config.root) : assetRegistryPath;
|
|
177
|
+
return resolveFrom(config.root, path);
|
|
178
|
+
}
|
|
179
|
+
function resolveReactNativeBuiltinPluginConfig(config) {
|
|
180
|
+
if (!config.experimental?.nativeTransformPipeline) return null;
|
|
181
|
+
return {
|
|
182
|
+
envName: config.mode,
|
|
183
|
+
runtimeTarget: resolveRuntimeTarget(config.runtimeTarget),
|
|
184
|
+
flow: config.experimental.flow,
|
|
185
|
+
worklets: resolveWorkletsConfig(config)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function resolveWorkletsConfig(config) {
|
|
189
|
+
const { worklets } = config.experimental ?? {};
|
|
190
|
+
if (worklets == null) return;
|
|
191
|
+
return merge({
|
|
192
|
+
isRelease: config.mode === "production",
|
|
193
|
+
pluginVersion: resolvePackageJson(config.root, "react-native-worklets")?.version
|
|
194
|
+
}, worklets);
|
|
195
|
+
}
|
|
196
|
+
function resolveBabelPluginOptions(config, context) {
|
|
197
|
+
return {
|
|
198
|
+
context,
|
|
199
|
+
useNativeTransformPipeline: config.experimental?.nativeTransformPipeline,
|
|
200
|
+
transformConfig: config.transformer.babel
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function resolveSwcPluginOptions(config, context) {
|
|
204
|
+
return {
|
|
205
|
+
context,
|
|
206
|
+
useNativeTransformPipeline: config.experimental?.nativeTransformPipeline,
|
|
207
|
+
runtimeTarget: config.runtimeTarget,
|
|
208
|
+
transformConfig: config.transformer.swc
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function resolveDevServerPluginOptions(config, hmrConfig) {
|
|
212
|
+
return {
|
|
213
|
+
cwd: config.root,
|
|
214
|
+
hmrClientPath: config.reactNative.hmrClientPath,
|
|
215
|
+
hmrConfig
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function resolveReporterPluginOptions(config, context, buildOptions) {
|
|
219
|
+
const statusReporter = createStatusReporter(config, context, buildOptions);
|
|
220
|
+
return {
|
|
221
|
+
initialTotalModules: getBuildTotalModules(context.storage, context.id),
|
|
222
|
+
reporter: mergeReporters([statusReporter, config.reporter].filter(isNotNil))
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function createStatusReporter(config, context, buildOptions) {
|
|
226
|
+
switch (config.terminal.status) {
|
|
227
|
+
case "compat": return new CompatStatusReporter();
|
|
228
|
+
case "progress": return new ProgressBarStatusReporter(config.root, context.id, `[${buildOptions.platform}, ${buildOptions.dev ? "dev" : "prod"}]`, getBuildTotalModules(context.storage, context.id));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function getResolveExtensions({ platform, sourceExtensions, assetExtensions, preferNativePlatform }) {
|
|
232
|
+
const supportedExtensions = [...sourceExtensions, ...assetExtensions];
|
|
233
|
+
return [...[platform, preferNativePlatform ? "native" : null].filter(isNotNil).map((platform) => {
|
|
234
|
+
return supportedExtensions.map((extension) => `.${platform}.${extension}`);
|
|
235
|
+
}), ...supportedExtensions.map((extension) => `.${extension}`)].flat();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Default sourcemap path transform.
|
|
239
|
+
*
|
|
240
|
+
* Rolldown emits `sources` relative to the bundle output's directory, which
|
|
241
|
+
* yields paths like `../App.tsx` when the bundle lives under e.g. `dist/`.
|
|
242
|
+
* RN tooling (symbolication, devtools) expects project-root-relative paths,
|
|
243
|
+
* so this rewrites each entry to be relative to `projectRoot`.
|
|
244
|
+
*/
|
|
245
|
+
function createProjectRootSourcemapPathTransform(projectRoot) {
|
|
246
|
+
return (source, sourcemapPath) => {
|
|
247
|
+
const absolute = path.resolve(path.dirname(sourcemapPath), source);
|
|
248
|
+
return path.relative(projectRoot, absolute);
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function loadPolyfills(polyfills) {
|
|
252
|
+
return polyfills.map((polyfill) => {
|
|
253
|
+
if (typeof polyfill === "string") return fs.readFileSync(polyfill, "utf-8");
|
|
254
|
+
const path = "path" in polyfill ? polyfill.path : void 0;
|
|
255
|
+
const content = "code" in polyfill ? polyfill.code : fs.readFileSync(polyfill.path, "utf-8");
|
|
256
|
+
return polyfill.type === "iife" ? iife(content, path) : content;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
async function applyDangerouslyOverrideOptionsFinalizer(config, inputOptions, outputOptions) {
|
|
260
|
+
const override = config.dangerously_overrideRolldownOptions;
|
|
261
|
+
if (override == null) return {
|
|
262
|
+
input: inputOptions,
|
|
263
|
+
output: outputOptions
|
|
264
|
+
};
|
|
265
|
+
return await applyOverrideRolldownOptions(override, {
|
|
266
|
+
input: inputOptions,
|
|
267
|
+
output: outputOptions
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function isPluginLog(log) {
|
|
271
|
+
return log.plugin != null || log.code?.startsWith("PLUGIN_") === true;
|
|
272
|
+
}
|
|
273
|
+
function toBuildDiagnosticLog(log) {
|
|
274
|
+
return {
|
|
275
|
+
code: log.code,
|
|
276
|
+
plugin: log.plugin,
|
|
277
|
+
message: log.message,
|
|
278
|
+
stack: log.stack,
|
|
279
|
+
id: log.id,
|
|
280
|
+
hook: log.hook,
|
|
281
|
+
frame: log.frame,
|
|
282
|
+
loc: log.loc,
|
|
283
|
+
meta: log.meta
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function getOverrideOptions() {
|
|
287
|
+
return {
|
|
288
|
+
input: { experimental: { nativeMagicString: true } },
|
|
289
|
+
output: {}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function getOverrideOptionsForDevServer(buildOptions) {
|
|
293
|
+
const overrideOptions = getOverrideOptions();
|
|
294
|
+
const input = {
|
|
295
|
+
transform: { jsx: { development: true } },
|
|
296
|
+
experimental: { incrementalBuild: true },
|
|
297
|
+
treeshake: false
|
|
298
|
+
};
|
|
299
|
+
const output = {
|
|
300
|
+
minify: buildOptions.minify ?? false,
|
|
301
|
+
sourcemap: buildOptions.sourcemap ?? true,
|
|
302
|
+
generatedCode: {
|
|
303
|
+
symbols: buildOptions.dev,
|
|
304
|
+
profilerNames: buildOptions.dev
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
return {
|
|
308
|
+
input: merge(overrideOptions.input, input),
|
|
309
|
+
output: merge(overrideOptions.output, output)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
export { getOverrideOptions, getOverrideOptionsForDevServer, resolveRolldownOptions };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getSharedDataPath } from "./fs/data.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { merge } from "es-toolkit";
|
|
5
|
+
//#region src/core/settings.ts
|
|
6
|
+
function getSettingsPath(basePath) {
|
|
7
|
+
return path.join(getSharedDataPath(basePath), "settings.json");
|
|
8
|
+
}
|
|
9
|
+
function loadSettings(basePath) {
|
|
10
|
+
const settingsPath = getSettingsPath(basePath);
|
|
11
|
+
if (!fs.existsSync(settingsPath)) return {};
|
|
12
|
+
return JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
|
|
13
|
+
}
|
|
14
|
+
function saveSettings(basePath, settings) {
|
|
15
|
+
const newSettings = merge(loadSettings(basePath), settings);
|
|
16
|
+
fs.writeFileSync(getSettingsPath(basePath), JSON.stringify(newSettings, null, 2));
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { loadSettings, saveSettings };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { FileStorage } from "./fs/storage.js";
|
|
2
|
+
import * as rolldown from "@rollipop/rolldown";
|
|
3
|
+
import { DevEngine, DevOptions } from "@rollipop/rolldown/experimental";
|
|
4
|
+
|
|
5
|
+
//#region src/core/types.d.ts
|
|
6
|
+
interface BuildOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The platform to build for.
|
|
9
|
+
*/
|
|
10
|
+
platform: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to build in development mode.
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `config.mode === 'development'`.
|
|
15
|
+
*/
|
|
16
|
+
dev?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to minify the bundle.
|
|
19
|
+
*
|
|
20
|
+
* This option is overridden by the `minify` option in the config.
|
|
21
|
+
*
|
|
22
|
+
* Defaults to `false`.
|
|
23
|
+
*/
|
|
24
|
+
minify?: rolldown.OutputOptions['minify'];
|
|
25
|
+
/**
|
|
26
|
+
* Enable or disable the cache.
|
|
27
|
+
*
|
|
28
|
+
* Defaults to `true`.
|
|
29
|
+
*/
|
|
30
|
+
cache?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The output file.
|
|
33
|
+
*/
|
|
34
|
+
outfile?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The sourcemap file.
|
|
37
|
+
*
|
|
38
|
+
* This option is overridden by the `sourcemap` option in the config.
|
|
39
|
+
*/
|
|
40
|
+
sourcemap?: rolldown.OutputOptions['sourcemap'];
|
|
41
|
+
/**
|
|
42
|
+
* The output file for the sourcemap.
|
|
43
|
+
*/
|
|
44
|
+
sourcemapOutfile?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The assets directory.
|
|
47
|
+
*/
|
|
48
|
+
assetsDir?: string;
|
|
49
|
+
}
|
|
50
|
+
type DevEngine$1 = DevEngine & {
|
|
51
|
+
getContext: () => BundlerContext;
|
|
52
|
+
};
|
|
53
|
+
type DevEngineOptions = Omit<DevOptions, 'watch'> & {
|
|
54
|
+
/**
|
|
55
|
+
* The host to run the dev server on.
|
|
56
|
+
*/
|
|
57
|
+
host: string;
|
|
58
|
+
/**
|
|
59
|
+
* The port to run the dev server on.
|
|
60
|
+
*/
|
|
61
|
+
port: number;
|
|
62
|
+
/**
|
|
63
|
+
* Whether to use HTTPS.
|
|
64
|
+
*
|
|
65
|
+
* Defaults to `false`.
|
|
66
|
+
*/
|
|
67
|
+
https?: boolean;
|
|
68
|
+
};
|
|
69
|
+
interface BundlerContext {
|
|
70
|
+
id: string;
|
|
71
|
+
root: string;
|
|
72
|
+
storage: FileStorage;
|
|
73
|
+
buildType: BuildType;
|
|
74
|
+
state: BundlerState;
|
|
75
|
+
}
|
|
76
|
+
interface BundlerState {
|
|
77
|
+
revision: number;
|
|
78
|
+
latestBuildStartTime: number;
|
|
79
|
+
}
|
|
80
|
+
type BuildType = 'build' | 'serve';
|
|
81
|
+
type AsyncResult<T> = T | Promise<T>;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { AsyncResult, BuildOptions, BuildType, BundlerContext, BundlerState, DevEngine$1 as DevEngine, DevEngineOptions };
|
package/dist/filter.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@rollipop/rolldown/filter";
|
package/dist/filter.js
ADDED
package/dist/hmr-runtime.iife.js
CHANGED
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
};
|
|
29
29
|
var __commonJS = function e(e, r) {
|
|
30
30
|
return function() {
|
|
31
|
-
return r || (0, e[__getOwnPropNames(e)[0]])((r = { exports: {} }).exports, r), r.exports;
|
|
31
|
+
return r || ((0, e[__getOwnPropNames(e)[0]])((r = { exports: {} }).exports, r), e = null), r.exports;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
var __commonJSMin = function e(e, r) {
|
|
35
35
|
return function() {
|
|
36
|
-
return r || e((r = { exports: {} }).exports, r), r.exports;
|
|
36
|
+
return r || (e((r = { exports: {} }).exports, r), e = null), r.exports;
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
var __exportAll = function e(e, r) {
|
|
@@ -270,7 +270,7 @@
|
|
|
270
270
|
}
|
|
271
271
|
var _globalThis, ___rolldown_runtime__;
|
|
272
272
|
var BaseDevRuntime = DevRuntime;
|
|
273
|
-
var ModuleHotContext =
|
|
273
|
+
var ModuleHotContext = /*#__PURE__*/ function() {
|
|
274
274
|
"use strict";
|
|
275
275
|
function e(t, r) {
|
|
276
276
|
_class_call_check(this, e);
|
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
]);
|
|
369
369
|
return e;
|
|
370
370
|
}();
|
|
371
|
-
var SocketHolder =
|
|
371
|
+
var SocketHolder = /*#__PURE__*/ function() {
|
|
372
372
|
"use strict";
|
|
373
373
|
function e() {
|
|
374
374
|
_class_call_check(this, e);
|
|
@@ -464,7 +464,7 @@
|
|
|
464
464
|
]);
|
|
465
465
|
return e;
|
|
466
466
|
}();
|
|
467
|
-
var ReactNativeDevRuntime =
|
|
467
|
+
var ReactNativeDevRuntime = /*#__PURE__*/ function(BaseDevRuntime1) {
|
|
468
468
|
"use strict";
|
|
469
469
|
_inherits(ReactNativeDevRuntime1, BaseDevRuntime1);
|
|
470
470
|
function ReactNativeDevRuntime1() {
|