@granite-js/mpack 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bundler/Bundler.js +5 -0
  3. package/dist/bundler/internal/presets.d.ts +18 -0
  4. package/dist/bundler/internal/presets.js +105 -0
  5. package/dist/constants/index.d.ts +1 -1
  6. package/dist/constants/index.js +3 -3
  7. package/dist/index.d.ts +0 -2
  8. package/dist/index.js +0 -6
  9. package/dist/metro/getMetroConfig.d.ts +4 -0
  10. package/dist/metro/getMetroConfig.js +1 -0
  11. package/dist/metro/runtime.js +1 -3
  12. package/dist/metro/types.d.ts +4 -0
  13. package/dist/operations/experimental/runServer.d.ts +1 -2
  14. package/dist/operations/experimental/runServer.js +0 -3
  15. package/dist/operations/runBundle.d.ts +1 -1
  16. package/dist/operations/runBundle.js +1 -15
  17. package/dist/operations/runServer.d.ts +2 -2
  18. package/dist/operations/runServer.js +5 -4
  19. package/dist/server/DevServer.d.ts +3 -0
  20. package/dist/server/DevServer.js +5 -5
  21. package/dist/server/helpers/createBundlerForDevServer.js +5 -19
  22. package/dist/server/helpers/mergeBundles.d.ts +3 -3
  23. package/dist/server/helpers/mergeBundles.js +10 -10
  24. package/dist/server/types.d.ts +0 -1
  25. package/dist/types/DevServerConfig.d.ts +0 -5
  26. package/dist/types/TaskConfig.d.ts +0 -5
  27. package/dist/types/index.d.ts +0 -2
  28. package/dist/types/index.js +1 -5
  29. package/dist/types/schemas/buildConfigSchema.d.ts +22 -59
  30. package/dist/types/schemas/buildConfigSchema.js +7 -16
  31. package/dist/types/schemas/devServerConfigSchema.js +0 -1
  32. package/dist/types/schemas/taskConfigSchema.js +0 -1
  33. package/dist/vendors/metro/src/lib/ReportableEvent.d.ts +152 -0
  34. package/dist/vendors/metro/src/lib/TerminalReporter.d.ts +2 -2
  35. package/dist/vendors/metro-transform-worker/src/index.js +0 -1
  36. package/package.json +3 -3
  37. package/dist/types/Preset.d.ts +0 -3
  38. package/dist/types/Preset.js +0 -16
  39. package/dist/types/PresetContext.d.ts +0 -2
  40. package/dist/types/PresetContext.js +0 -16
  41. package/dist/utils/loadConfig.d.ts +0 -2
  42. package/dist/utils/loadConfig.js +0 -37
  43. package/dist/utils/loadPresets.d.ts +0 -2
  44. package/dist/utils/loadPresets.js +0 -40
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @granite-js/mpack
2
2
 
3
+ ## 0.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 208c053: feat: add additionalConfig reporter spec
8
+ - @granite-js/devtools-frontend@0.1.7
9
+ - @granite-js/utils@0.1.7
10
+
3
11
  ## 0.1.6
4
12
 
5
13
  ### Patch Changes
@@ -40,6 +40,7 @@ var import_constants = require("../constants");
40
40
  var import_logger = require("../logger");
41
41
  var import_getId = require("../utils/getId");
42
42
  var import_promiseHandler = require("../utils/promiseHandler");
43
+ var import_presets = require("./internal/presets");
43
44
  class Bundler {
44
45
  constructor(config) {
45
46
  this.config = config;
@@ -48,6 +49,10 @@ class Bundler {
48
49
  this.pluginDriver = new import_PluginDriver.PluginDriver(id);
49
50
  this.config.buildConfig.entry = path.resolve(this.config.rootDir, this.config.buildConfig.entry);
50
51
  this.config.buildConfig.outfile = path.resolve(this.config.rootDir, this.config.buildConfig.outfile);
52
+ this.config.buildConfig = (0, import_presets.combineWithBaseBuildConfig)(this.config, {
53
+ rootDir: this.config.rootDir,
54
+ dev: this.config.dev
55
+ });
51
56
  import_logger.logger.debug("Bundler.constructor", { id, config });
52
57
  }
53
58
  id;
@@ -0,0 +1,18 @@
1
+ import { BuildConfig, BundlerConfig } from '../../types';
2
+ export declare function getReactNativeSetupScripts({ rootDir }: {
3
+ rootDir: string;
4
+ }): string[];
5
+ export declare function globalVariables({ dev }: {
6
+ dev: boolean;
7
+ }): string;
8
+ export declare function defineGlobalVariables({ dev }: {
9
+ dev: boolean;
10
+ }): {
11
+ window: string;
12
+ __DEV__: string;
13
+ 'process.env.NODE_ENV': string;
14
+ };
15
+ export declare function combineWithBaseBuildConfig(config: BundlerConfig, context: {
16
+ rootDir: string;
17
+ dev: boolean;
18
+ }): BuildConfig;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var presets_exports = {};
30
+ __export(presets_exports, {
31
+ combineWithBaseBuildConfig: () => combineWithBaseBuildConfig,
32
+ defineGlobalVariables: () => defineGlobalVariables,
33
+ getReactNativeSetupScripts: () => getReactNativeSetupScripts,
34
+ globalVariables: () => globalVariables
35
+ });
36
+ module.exports = __toCommonJS(presets_exports);
37
+ var import_path = __toESM(require("path"));
38
+ var import_mergeBuildConfigs = require("../../utils/mergeBuildConfigs");
39
+ function getReactNativeSetupScripts({ rootDir }) {
40
+ const reactNativePath = import_path.default.dirname(
41
+ require.resolve("react-native/package.json", {
42
+ paths: [rootDir]
43
+ })
44
+ );
45
+ return [
46
+ ...require(import_path.default.join(reactNativePath, "rn-get-polyfills"))(),
47
+ import_path.default.join(reactNativePath, "Libraries/Core/InitializeCore.js")
48
+ ];
49
+ }
50
+ function globalVariables({ dev }) {
51
+ return [
52
+ "var __BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now();",
53
+ `var __DEV__=${JSON.stringify(dev)};`,
54
+ `var global=typeof globalThis!=='undefined'?globalThis:typeof global!=='undefined'?global:typeof window!=='undefined'?window:this;`
55
+ ].join("\n");
56
+ }
57
+ function defineGlobalVariables({ dev }) {
58
+ return {
59
+ window: "global",
60
+ __DEV__: JSON.stringify(dev),
61
+ "process.env.NODE_ENV": JSON.stringify(dev ? "development" : "production")
62
+ };
63
+ }
64
+ function combineWithBaseBuildConfig(config, context) {
65
+ return (0, import_mergeBuildConfigs.mergeBuildConfigs)(
66
+ {
67
+ entry: config.buildConfig.entry,
68
+ outfile: config.buildConfig.outfile,
69
+ platform: config.buildConfig.platform,
70
+ esbuild: {
71
+ define: defineGlobalVariables({ dev: context.dev }),
72
+ prelude: getReactNativeSetupScripts({ rootDir: context.rootDir }),
73
+ banner: {
74
+ js: [
75
+ globalVariables({ dev: context.dev }),
76
+ "global.__granite = global.__granite || {};",
77
+ `global.__granite.app = { name: ${JSON.stringify(config.appName)}, scheme: ${JSON.stringify(config.scheme)} };`,
78
+ // symbol-asynciterator polyfill (ES5)
79
+ `(function(){if(typeof Symbol!=="undefined"&&!Symbol.asyncIterator){Symbol.asyncIterator=Symbol.for("@@asyncIterator")}})();`
80
+ ].join("\n")
81
+ }
82
+ },
83
+ babel: {
84
+ conditions: [
85
+ /**
86
+ * @TODO
87
+ * We're using a RegExp in Zod that's not supported by Hermes,
88
+ * so we're switching to Babel for transpilation since there's no compatible SWC config or plugin available.
89
+ *
90
+ * @see zod {@link https://github.com/colinhacks/zod/issues/2302}
91
+ */
92
+ (_code, path2) => path2.includes("node_modules/zod")
93
+ ]
94
+ }
95
+ },
96
+ config.buildConfig
97
+ );
98
+ }
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ combineWithBaseBuildConfig,
102
+ defineGlobalVariables,
103
+ getReactNativeSetupScripts,
104
+ globalVariables
105
+ });
@@ -17,4 +17,4 @@ export declare const DEBUGGER_FRONTEND_PATH = "/debugger-frontend";
17
17
  export declare const RESOLVER_MAIN_FIELDS: string[];
18
18
  export declare const RESOLVER_EXPORTS_MAP_CONDITIONS: string[];
19
19
  export declare const INTERNAL_NAMESPACE_IDENTIFIER = "__mpackInternal";
20
- export declare const INTERNAL_EVALUATE_MAIN_BUNDLE_IDENTIFIER = "evaluateMainBundle";
20
+ export declare const INTERNAL_LOAD_REMOTE_IDENTIFIER = "loadRemote";
@@ -33,7 +33,7 @@ __export(constants_exports, {
33
33
  DEBUGGER_FRONTEND_PATH: () => DEBUGGER_FRONTEND_PATH,
34
34
  DEV_SERVER_DEFAULT_HOST: () => DEV_SERVER_DEFAULT_HOST,
35
35
  DEV_SERVER_DEFAULT_PORT: () => DEV_SERVER_DEFAULT_PORT,
36
- INTERNAL_EVALUATE_MAIN_BUNDLE_IDENTIFIER: () => INTERNAL_EVALUATE_MAIN_BUNDLE_IDENTIFIER,
36
+ INTERNAL_LOAD_REMOTE_IDENTIFIER: () => INTERNAL_LOAD_REMOTE_IDENTIFIER,
37
37
  INTERNAL_NAMESPACE_IDENTIFIER: () => INTERNAL_NAMESPACE_IDENTIFIER,
38
38
  MPACK_CACHE_DIR: () => MPACK_CACHE_DIR,
39
39
  MPACK_DATA_DIR: () => MPACK_DATA_DIR,
@@ -68,7 +68,7 @@ const DEBUGGER_FRONTEND_PATH = "/debugger-frontend";
68
68
  const RESOLVER_MAIN_FIELDS = ["react-native", "browser", "main"];
69
69
  const RESOLVER_EXPORTS_MAP_CONDITIONS = ["react-native"];
70
70
  const INTERNAL_NAMESPACE_IDENTIFIER = "__mpackInternal";
71
- const INTERNAL_EVALUATE_MAIN_BUNDLE_IDENTIFIER = "evaluateMainBundle";
71
+ const INTERNAL_LOAD_REMOTE_IDENTIFIER = "loadRemote";
72
72
  // Annotate the CommonJS export names for ESM import in node:
73
73
  0 && (module.exports = {
74
74
  ASSET_EXTENSIONS,
@@ -76,7 +76,7 @@ const INTERNAL_EVALUATE_MAIN_BUNDLE_IDENTIFIER = "evaluateMainBundle";
76
76
  DEBUGGER_FRONTEND_PATH,
77
77
  DEV_SERVER_DEFAULT_HOST,
78
78
  DEV_SERVER_DEFAULT_PORT,
79
- INTERNAL_EVALUATE_MAIN_BUNDLE_IDENTIFIER,
79
+ INTERNAL_LOAD_REMOTE_IDENTIFIER,
80
80
  INTERNAL_NAMESPACE_IDENTIFIER,
81
81
  MPACK_CACHE_DIR,
82
82
  MPACK_DATA_DIR,
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  export { Bundler } from './bundler';
2
2
  export { DevServer } from './server';
3
- export { loadConfig } from './utils/loadConfig';
4
- export { loadPresets } from './utils/loadPresets';
5
3
  export { getMetroConfig, runBuild as metroBuild, type MetroConfig } from './metro';
6
4
  export { DEV_SERVER_DEFAULT_HOST, DEV_SERVER_DEFAULT_PORT, SHARED_BUNDLE_NAME, SERVICE_BUNDLE_NAME, BUNDLE_NAME, } from './constants';
7
5
  export * from './operations';
package/dist/index.js CHANGED
@@ -27,15 +27,11 @@ __export(index_exports, {
27
27
  SERVICE_BUNDLE_NAME: () => import_constants.SERVICE_BUNDLE_NAME,
28
28
  SHARED_BUNDLE_NAME: () => import_constants.SHARED_BUNDLE_NAME,
29
29
  getMetroConfig: () => import_metro.getMetroConfig,
30
- loadConfig: () => import_loadConfig.loadConfig,
31
- loadPresets: () => import_loadPresets.loadPresets,
32
30
  metroBuild: () => import_metro.runBuild
33
31
  });
34
32
  module.exports = __toCommonJS(index_exports);
35
33
  var import_bundler = require("./bundler");
36
34
  var import_server = require("./server");
37
- var import_loadConfig = require("./utils/loadConfig");
38
- var import_loadPresets = require("./utils/loadPresets");
39
35
  var import_metro = require("./metro");
40
36
  var import_constants = require("./constants");
41
37
  __reExport(index_exports, require("./operations"), module.exports);
@@ -51,8 +47,6 @@ __reExport(index_exports, require("./types"), module.exports);
51
47
  SERVICE_BUNDLE_NAME,
52
48
  SHARED_BUNDLE_NAME,
53
49
  getMetroConfig,
54
- loadConfig,
55
- loadPresets,
56
50
  metroBuild,
57
51
  ...require("./operations"),
58
52
  ...require("./types/schemas"),
@@ -1,5 +1,6 @@
1
1
  import type * as babel from '@babel/core';
2
2
  import type { MetroConfig } from './types';
3
+ import type { ReportableEvent } from '../vendors/metro/src/lib/ReportableEvent';
3
4
  export interface GetMetroConfig {
4
5
  rootPath: string;
5
6
  appName: string;
@@ -8,5 +9,8 @@ export interface GetMetroConfig {
8
9
  export interface AdditionalMetroConfig extends MetroConfig {
9
10
  transformSync?: (id: string, code: string) => string;
10
11
  babelConfig?: babel.TransformOptions;
12
+ reporter?: {
13
+ update: (event: ReportableEvent) => void;
14
+ };
11
15
  }
12
16
  export declare function getMetroConfig({ rootPath, appName, scheme }: GetMetroConfig, additionalConfig?: AdditionalMetroConfig): Promise<any>;
@@ -119,6 +119,7 @@ async function getMetroConfig({ rootPath, appName, scheme }, additionalConfig) {
119
119
  server: {
120
120
  port: import_constants.DEV_SERVER_DEFAULT_PORT
121
121
  },
122
+ reporter: additionalConfig?.reporter,
122
123
  ...process.env.METRO_RESET_CACHE !== "false" ? { resetCache: true } : {}
123
124
  });
124
125
  }
@@ -42,11 +42,9 @@ async function writeEnvScript(rootPath, appName, scheme) {
42
42
  return { path: filePath };
43
43
  }
44
44
  function getEnvScript(appName, scheme) {
45
- const buildNumber = "00000000";
46
45
  const script = [
47
46
  "global.__granite = global.__granite || {};",
48
- `global.__granite.shared = { buildNumber: ${JSON.stringify(buildNumber)} };`,
49
- `global.__granite.app = { name: ${appName.startsWith("babel:") ? appName.slice(6) : JSON.stringify(appName)}, scheme: ${JSON.stringify(scheme)}, buildNumber: ${JSON.stringify(buildNumber)} };`
47
+ `global.__granite.app = { name: ${appName.startsWith("babel:") ? appName.slice(6) : JSON.stringify(appName)}, scheme: ${JSON.stringify(scheme)} };`
50
48
  ].join("\n");
51
49
  return script;
52
50
  }
@@ -1,3 +1,4 @@
1
+ import { ReportableEvent } from "../vendors/metro/src/lib/ReportableEvent";
1
2
  type Untyped = any;
2
3
  interface PackageJson {
3
4
  readonly name?: string;
@@ -84,5 +85,8 @@ export interface MetroConfig {
84
85
  readonly symbolicator?: any;
85
86
  readonly transformer?: any;
86
87
  readonly watcher?: any;
88
+ readonly reporter?: {
89
+ update: (event: ReportableEvent) => void;
90
+ };
87
91
  }
88
92
  export {};
@@ -6,11 +6,10 @@ interface RunServerArgs {
6
6
  devServerConfig: DevServerConfig;
7
7
  host?: string;
8
8
  port?: number;
9
- preloadBundle?: string;
10
9
  plugins?: DevServerPlugin[];
11
10
  onServerReady?: () => Promise<void> | void;
12
11
  }
13
- export declare function experimental_runServer({ appName, scheme, devServerConfig, host, port, plugins, preloadBundle, onServerReady, }: RunServerArgs): Promise<{
12
+ export declare function experimental_runServer({ appName, scheme, devServerConfig, host, port, plugins, onServerReady, }: RunServerArgs): Promise<{
14
13
  cleanup: () => Promise<void>;
15
14
  }>;
16
15
  export {};
@@ -47,7 +47,6 @@ async function experimental_runServer({
47
47
  host,
48
48
  port = import_constants.DEV_SERVER_DEFAULT_PORT,
49
49
  plugins,
50
- preloadBundle,
51
50
  onServerReady
52
51
  }) {
53
52
  const rootDir = process.cwd();
@@ -55,10 +54,8 @@ async function experimental_runServer({
55
54
  appName,
56
55
  scheme,
57
56
  build: devServerConfig.build,
58
- presets: devServerConfig.presets,
59
57
  host,
60
58
  port,
61
- preloadBundle,
62
59
  plugins,
63
60
  rootDir
64
61
  });
@@ -1,12 +1,12 @@
1
1
  import { BundlerConfig, Config, PluginFactory } from '../types';
2
2
  interface RunBundleOptions {
3
+ config: Config;
3
4
  rootDir: BundlerConfig['rootDir'];
4
5
  dev: BundlerConfig['dev'];
5
6
  cache: BundlerConfig['cache'];
6
7
  metafile: BundlerConfig['metafile'];
7
8
  plugins?: PluginFactory[];
8
9
  tag?: string;
9
- config?: Config;
10
10
  }
11
11
  export declare function runBundle(options: RunBundleOptions): Promise<import("..").BuildResult[]>;
12
12
  export {};
@@ -31,29 +31,15 @@ __export(runBundle_exports, {
31
31
  runBundle: () => runBundle
32
32
  });
33
33
  module.exports = __toCommonJS(runBundle_exports);
34
- var import_assert = __toESM(require("assert"));
35
34
  var fs = __toESM(require("fs/promises"));
36
35
  var path = __toESM(require("path"));
37
36
  var import_semaphore = require("@shopify/semaphore");
38
37
  var import_es_toolkit = require("es-toolkit");
39
- var import__ = require("..");
40
38
  var import_bundler = require("../bundler");
41
39
  var import_performance = require("../performance");
42
- var import_loadPresets = require("../utils/loadPresets");
43
40
  var import_writeBundle = require("../utils/writeBundle");
44
41
  async function runBundle(options) {
45
- const config = options.config ?? await (0, import__.loadConfig)({ rootDir: options.rootDir });
46
- (0, import_assert.default)(config, "\uAD6C\uC131 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
47
- config.tasks = await Promise.all(
48
- config.tasks.map(
49
- (task) => (0, import_loadPresets.loadPresets)(task, {
50
- appName: config.appName,
51
- scheme: config.scheme,
52
- rootDir: options.rootDir,
53
- dev: options.dev
54
- })
55
- )
56
- );
42
+ const config = options.config;
57
43
  const semaphore = new import_semaphore.Semaphore(config.concurrency ?? 4);
58
44
  const buildResults = await Promise.all(
59
45
  config.tasks.map(async ({ tag, build }) => {
@@ -2,14 +2,14 @@ import type { HandleFunction } from 'connect';
2
2
  import { Config } from '..';
3
3
  import { type AdditionalMetroConfig } from '../metro/getMetroConfig';
4
4
  interface RunServerConfig {
5
+ config: Config;
5
6
  host?: string;
6
7
  port?: number;
7
8
  middlewares?: HandleFunction[];
8
9
  enableEmbeddedReactDevTools?: boolean;
9
10
  onServerReady?: () => Promise<void> | void;
10
11
  cwd?: string;
11
- config?: Config;
12
12
  additionalConfig?: AdditionalMetroConfig;
13
13
  }
14
- export declare function runServer({ host, port, middlewares, enableEmbeddedReactDevTools, onServerReady, cwd, config: $config, additionalConfig, }: RunServerConfig): Promise<void>;
14
+ export declare function runServer({ config, host, port, middlewares, enableEmbeddedReactDevTools, onServerReady, cwd, additionalConfig, }: RunServerConfig): Promise<void>;
15
15
  export {};
@@ -37,7 +37,6 @@ var import_backend = require("react-native-devtools-standalone/backend");
37
37
  var import_createDebuggerMiddleware = require("./createDebuggerMiddleware");
38
38
  var import_constants = require("../constants");
39
39
  var import_getMetroConfig = require("../metro/getMetroConfig");
40
- var import_loadConfig = require("../utils/loadConfig");
41
40
  var import_printLogo = require("../utils/printLogo");
42
41
  var import_vendors = require("../vendors");
43
42
  const debug = (0, import_debug.default)("cli:start");
@@ -45,16 +44,15 @@ const { Metro, TerminalReporter } = (0, import_vendors.getModule)("metro");
45
44
  const { Terminal } = (0, import_vendors.getModule)("metro-core");
46
45
  const { mergeConfig } = (0, import_vendors.getModule)("metro-config");
47
46
  async function runServer({
47
+ config,
48
48
  host,
49
49
  port = import_constants.DEV_SERVER_DEFAULT_PORT,
50
50
  middlewares = [],
51
51
  enableEmbeddedReactDevTools = true,
52
52
  onServerReady,
53
53
  cwd = process.cwd(),
54
- config: $config,
55
54
  additionalConfig
56
55
  }) {
57
- const config = $config ?? await (0, import_loadConfig.loadConfig)({ rootDir: cwd });
58
56
  const ref = {};
59
57
  const terminal = new Terminal(process.stdout);
60
58
  const terminalReporter = new TerminalReporter(terminal);
@@ -63,6 +61,9 @@ async function runServer({
63
61
  debug("Reporter event", event);
64
62
  terminalReporter.update(event);
65
63
  ref.reportEvent?.(event);
64
+ if (baseConfig.reporter?.update) {
65
+ baseConfig.reporter.update(event);
66
+ }
66
67
  switch (event.type) {
67
68
  case "initialize_started":
68
69
  (0, import_printLogo.printLogo)();
@@ -77,7 +78,7 @@ async function runServer({
77
78
  }
78
79
  };
79
80
  const baseConfig = await (0, import_getMetroConfig.getMetroConfig)(
80
- { rootPath: cwd, appName: config?.appName ?? "", scheme: config?.scheme ?? "" },
81
+ { rootPath: cwd, appName: config.appName, scheme: config.scheme },
81
82
  additionalConfig
82
83
  );
83
84
  const metroConfig = mergeConfig(baseConfig, {
@@ -21,3 +21,6 @@ export declare class DevServer {
21
21
  private createDevServerContext;
22
22
  private getBundle;
23
23
  }
24
+ declare global {
25
+ var remoteBundles: Record<'android' | 'ios', string> | null;
26
+ }
@@ -32,7 +32,6 @@ __export(DevServer_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(DevServer_exports);
34
34
  var import_assert = __toESM(require("assert"));
35
- var fs = __toESM(require("fs/promises"));
36
35
  var import_fastify = __toESM(require("fastify"));
37
36
  var import_backend = require("react-native-devtools-standalone/backend");
38
37
  var import_DebuggerEventHandler = require("./debugger/DebuggerEventHandler");
@@ -196,12 +195,13 @@ class DevServer {
196
195
  const { bundler } = this.getContext()[platform];
197
196
  const { bundle } = await bundler.build({ withDispose: false });
198
197
  let targetBundle;
199
- if (this.devServerOptions.preloadBundle != null) {
200
- const sharedBundleContent = await fs.readFile(this.devServerOptions.preloadBundle, "utf-8");
198
+ if (globalThis.remoteBundles != null) {
199
+ const hostBundleContent = bundle.source.text;
200
+ const remoteBundleContent = globalThis.remoteBundles[platform];
201
201
  const mergedBundle = await (0, import_mergeBundles.mergeBundles)({
202
202
  platform,
203
- preloadedBundleContent: sharedBundleContent,
204
- mainBundle: bundle
203
+ hostBundleContent,
204
+ remoteBundleContent
205
205
  });
206
206
  targetBundle = mergedBundle;
207
207
  } else {
@@ -23,7 +23,6 @@ __export(createBundlerForDevServer_exports, {
23
23
  module.exports = __toCommonJS(createBundlerForDevServer_exports);
24
24
  var import_bundler = require("../../bundler");
25
25
  var import_getBundleName = require("../../utils/getBundleName");
26
- var import_loadPresets = require("../../utils/loadPresets");
27
26
  var import_constants = require("../constants");
28
27
  async function createDevServerForDevServer({
29
28
  rootDir,
@@ -35,23 +34,6 @@ async function createDevServerForDevServer({
35
34
  const tag = "dev-server";
36
35
  const dev = true;
37
36
  const bundleName = (0, import_getBundleName.getBundleName)(import_constants.DEV_SERVER_BUNDLE_NAME);
38
- const { build } = await (0, import_loadPresets.loadPresets)(
39
- {
40
- tag,
41
- presets: config.presets,
42
- build: {
43
- ...config.build,
44
- platform,
45
- outfile: bundleName
46
- }
47
- },
48
- {
49
- rootDir,
50
- appName,
51
- scheme,
52
- dev
53
- }
54
- );
55
37
  const bundler = new import_bundler.Bundler({
56
38
  tag,
57
39
  rootDir,
@@ -60,7 +42,11 @@ async function createDevServerForDevServer({
60
42
  dev,
61
43
  cache: true,
62
44
  metafile: false,
63
- buildConfig: build,
45
+ buildConfig: {
46
+ ...config.build,
47
+ platform,
48
+ outfile: bundleName
49
+ },
64
50
  services: {
65
51
  sentry: {
66
52
  enabled: false
@@ -1,7 +1,7 @@
1
1
  import { BundleData } from '../../bundler/types';
2
2
  import { Platform } from '../types';
3
- export declare function mergeBundles({ platform, preloadedBundleContent, mainBundle, }: {
3
+ export declare function mergeBundles({ platform, hostBundleContent, remoteBundleContent, }: {
4
4
  platform: Platform;
5
- preloadedBundleContent: string;
6
- mainBundle: BundleData;
5
+ hostBundleContent: string;
6
+ remoteBundleContent: string;
7
7
  }): Promise<BundleData>;
@@ -37,18 +37,18 @@ var import_getBundleName = require("../../utils/getBundleName");
37
37
  var import_getSourcemapName = require("../../utils/getSourcemapName");
38
38
  var import_constants2 = require("../constants");
39
39
  const INTERNAL_SOURCE = "mpack:internal";
40
- const IMPORT_SOURCE = "mpack:main-bundle";
40
+ const IMPORT_SOURCE = "mpack:remote";
41
41
  async function mergeBundles({
42
42
  platform,
43
- preloadedBundleContent,
44
- mainBundle
43
+ hostBundleContent,
44
+ remoteBundleContent
45
45
  }) {
46
46
  const bundleName = (0, import_getBundleName.getBundleName)(import_constants2.DEV_SERVER_BUNDLE_NAME);
47
47
  const sourcemapName = (0, import_getSourcemapName.getSourcemapName)(bundleName);
48
48
  const result = await esbuild.build({
49
49
  logLevel: "silent",
50
50
  stdin: {
51
- contents: [`require('${INTERNAL_SOURCE}');`, preloadedBundleContent].join("\n"),
51
+ contents: [`require('${INTERNAL_SOURCE}');`, hostBundleContent].join("\n"),
52
52
  loader: "js"
53
53
  },
54
54
  outfile: bundleName,
@@ -78,21 +78,21 @@ async function mergeBundles({
78
78
  },
79
79
  plugins: [
80
80
  {
81
- name: "main-bundle-loader",
81
+ name: "remote-bundle-loader",
82
82
  setup(build) {
83
83
  build.onResolve({ filter: new RegExp(`^${INTERNAL_SOURCE}$`) }, () => ({
84
84
  path: "dev-server-runtime",
85
85
  namespace: "DEV_SERVER_RUNTIME"
86
86
  }));
87
87
  build.onResolve({ filter: new RegExp(`^${IMPORT_SOURCE}$`) }, () => ({
88
- path: "main-bundle",
89
- namespace: "MAIN_BUNDLE"
88
+ path: "remote-bundle",
89
+ namespace: "REMOTE_BUNDLE"
90
90
  }));
91
91
  build.onLoad({ filter: /.*/, namespace: "DEV_SERVER_RUNTIME" }, () => ({
92
92
  contents: `
93
93
  (function(global) {
94
94
  global.${import_constants.INTERNAL_NAMESPACE_IDENTIFIER} = {};
95
- global.${import_constants.INTERNAL_NAMESPACE_IDENTIFIER}.${import_constants.INTERNAL_EVALUATE_MAIN_BUNDLE_IDENTIFIER} = function INTERNAL__evaluateMainBundle() {
95
+ global.${import_constants.INTERNAL_NAMESPACE_IDENTIFIER}.${import_constants.INTERNAL_LOAD_REMOTE_IDENTIFIER} = function INTERNAL__loadRemote() {
96
96
  require('${IMPORT_SOURCE}');
97
97
  return Promise.resolve();
98
98
  }
@@ -108,8 +108,8 @@ async function mergeBundles({
108
108
  `,
109
109
  loader: "js"
110
110
  }));
111
- build.onLoad({ filter: /.*/, namespace: "MAIN_BUNDLE" }, () => ({
112
- contents: mainBundle.source.text,
111
+ build.onLoad({ filter: /.*/, namespace: "REMOTE_BUNDLE" }, () => ({
112
+ contents: remoteBundleContent,
113
113
  loader: "js"
114
114
  }));
115
115
  }
@@ -7,7 +7,6 @@ export interface DevServerOptions extends DevServerConfig {
7
7
  rootDir: string;
8
8
  appName: string;
9
9
  scheme: string;
10
- preloadBundle?: string;
11
10
  host?: string;
12
11
  port?: number;
13
12
  plugins?: DevServerPlugin[];
@@ -1,9 +1,4 @@
1
1
  import type { BuildConfig } from './BuildConfig';
2
- import type { Preset } from './Preset';
3
2
  export interface DevServerConfig {
4
- /**
5
- * 사전 구성된 프리셋
6
- */
7
- presets?: Preset[];
8
3
  build: Omit<BuildConfig, 'platform' | 'outfile'>;
9
4
  }
@@ -1,5 +1,4 @@
1
1
  import type { BuildConfig } from './BuildConfig';
2
- import type { Preset } from './Preset';
3
2
  export type INTERNAL__Id = string & {
4
3
  __id: true;
5
4
  };
@@ -8,9 +7,5 @@ export interface TaskConfig {
8
7
  * 작업 식별자
9
8
  */
10
9
  tag: string;
11
- /**
12
- * Mpack 내에 사전 구성된 프리셋
13
- */
14
- presets?: Preset[];
15
10
  build: BuildConfig;
16
11
  }
@@ -3,7 +3,5 @@ export * from './BundlerConfig';
3
3
  export * from './Config';
4
4
  export * from './DevServerConfig';
5
5
  export * from './Plugin';
6
- export * from './PresetContext';
7
6
  export * from './ServicesConfig';
8
7
  export * from './TaskConfig';
9
- export * from './Preset';
@@ -20,10 +20,8 @@ __reExport(types_exports, require("./BundlerConfig"), module.exports);
20
20
  __reExport(types_exports, require("./Config"), module.exports);
21
21
  __reExport(types_exports, require("./DevServerConfig"), module.exports);
22
22
  __reExport(types_exports, require("./Plugin"), module.exports);
23
- __reExport(types_exports, require("./PresetContext"), module.exports);
24
23
  __reExport(types_exports, require("./ServicesConfig"), module.exports);
25
24
  __reExport(types_exports, require("./TaskConfig"), module.exports);
26
- __reExport(types_exports, require("./Preset"), module.exports);
27
25
  // Annotate the CommonJS export names for ESM import in node:
28
26
  0 && (module.exports = {
29
27
  ...require("./BuildConfig"),
@@ -31,8 +29,6 @@ __reExport(types_exports, require("./Preset"), module.exports);
31
29
  ...require("./Config"),
32
30
  ...require("./DevServerConfig"),
33
31
  ...require("./Plugin"),
34
- ...require("./PresetContext"),
35
32
  ...require("./ServicesConfig"),
36
- ...require("./TaskConfig"),
37
- ...require("./Preset")
33
+ ...require("./TaskConfig")
38
34
  });
@@ -1,5 +1,6 @@
1
1
  import type * as esbuild from 'esbuild';
2
2
  import z from 'zod';
3
+ import type { AliasConfig, ProtocolConfig } from '../BuildConfig';
3
4
  export declare const esbuildConfigSchema: z.ZodType<esbuild.BuildOptions & {
4
5
  /**
5
6
  * Entry point 최상단에 주입할 스크립트 경로
@@ -50,54 +51,29 @@ export declare const swcConfigSchema: z.ZodObject<{
50
51
  }, {
51
52
  plugins?: any[] | undefined;
52
53
  }>;
54
+ export declare const resolverConfigSchema: z.ZodObject<{
55
+ alias: z.ZodOptional<z.ZodArray<z.ZodType<AliasConfig, z.ZodTypeDef, AliasConfig>, "many">>;
56
+ protocols: z.ZodOptional<z.ZodType<ProtocolConfig, z.ZodTypeDef, ProtocolConfig>>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ alias?: AliasConfig[] | undefined;
59
+ protocols?: ProtocolConfig | undefined;
60
+ }, {
61
+ alias?: AliasConfig[] | undefined;
62
+ protocols?: ProtocolConfig | undefined;
63
+ }>;
53
64
  export declare const buildConfigSchema: z.ZodObject<{
54
65
  platform: z.ZodEnum<["ios", "android"]>;
55
66
  entry: z.ZodString;
56
67
  outfile: z.ZodString;
57
68
  resolver: z.ZodOptional<z.ZodObject<{
58
- alias: z.ZodOptional<z.ZodArray<z.ZodObject<{
59
- from: z.ZodString;
60
- to: z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodType<string, z.ZodTypeDef, string>, z.ZodPromise<z.ZodType<string, z.ZodTypeDef, string>>]>>]>;
61
- exact: z.ZodOptional<z.ZodBoolean>;
62
- }, "strip", z.ZodTypeAny, {
63
- from: string;
64
- to: string | ((...args: unknown[]) => string | Promise<string>);
65
- exact?: boolean | undefined;
66
- }, {
67
- from: string;
68
- to: string | ((...args: unknown[]) => string | Promise<string>);
69
- exact?: boolean | undefined;
70
- }>, "many">>;
71
- protocols: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
72
- resolve: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodPromise<z.ZodType<any, z.ZodTypeDef, any>>]>>>;
73
- load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodPromise<z.ZodType<any, z.ZodTypeDef, any>>]>>;
74
- }, "strip", z.ZodTypeAny, {
75
- load: (...args: unknown[]) => any;
76
- resolve?: ((...args: unknown[]) => any) | undefined;
77
- }, {
78
- load: (...args: unknown[]) => any;
79
- resolve?: ((...args: unknown[]) => any) | undefined;
80
- }>>>;
69
+ alias: z.ZodOptional<z.ZodArray<z.ZodType<AliasConfig, z.ZodTypeDef, AliasConfig>, "many">>;
70
+ protocols: z.ZodOptional<z.ZodType<ProtocolConfig, z.ZodTypeDef, ProtocolConfig>>;
81
71
  }, "strip", z.ZodTypeAny, {
82
- alias?: {
83
- from: string;
84
- to: string | ((...args: unknown[]) => string | Promise<string>);
85
- exact?: boolean | undefined;
86
- }[] | undefined;
87
- protocols?: Record<string, {
88
- load: (...args: unknown[]) => any;
89
- resolve?: ((...args: unknown[]) => any) | undefined;
90
- }> | undefined;
72
+ alias?: AliasConfig[] | undefined;
73
+ protocols?: ProtocolConfig | undefined;
91
74
  }, {
92
- alias?: {
93
- from: string;
94
- to: string | ((...args: unknown[]) => string | Promise<string>);
95
- exact?: boolean | undefined;
96
- }[] | undefined;
97
- protocols?: Record<string, {
98
- load: (...args: unknown[]) => any;
99
- resolve?: ((...args: unknown[]) => any) | undefined;
100
- }> | undefined;
75
+ alias?: AliasConfig[] | undefined;
76
+ protocols?: ProtocolConfig | undefined;
101
77
  }>>;
102
78
  esbuild: z.ZodOptional<z.ZodType<esbuild.BuildOptions & {
103
79
  /**
@@ -155,15 +131,8 @@ export declare const buildConfigSchema: z.ZodObject<{
155
131
  outfile: string;
156
132
  entry: string;
157
133
  resolver?: {
158
- alias?: {
159
- from: string;
160
- to: string | ((...args: unknown[]) => string | Promise<string>);
161
- exact?: boolean | undefined;
162
- }[] | undefined;
163
- protocols?: Record<string, {
164
- load: (...args: unknown[]) => any;
165
- resolve?: ((...args: unknown[]) => any) | undefined;
166
- }> | undefined;
134
+ alias?: AliasConfig[] | undefined;
135
+ protocols?: ProtocolConfig | undefined;
167
136
  } | undefined;
168
137
  esbuild?: (esbuild.BuildOptions & {
169
138
  /**
@@ -194,15 +163,8 @@ export declare const buildConfigSchema: z.ZodObject<{
194
163
  outfile: string;
195
164
  entry: string;
196
165
  resolver?: {
197
- alias?: {
198
- from: string;
199
- to: string | ((...args: unknown[]) => string | Promise<string>);
200
- exact?: boolean | undefined;
201
- }[] | undefined;
202
- protocols?: Record<string, {
203
- load: (...args: unknown[]) => any;
204
- resolve?: ((...args: unknown[]) => any) | undefined;
205
- }> | undefined;
166
+ alias?: AliasConfig[] | undefined;
167
+ protocols?: ProtocolConfig | undefined;
206
168
  } | undefined;
207
169
  esbuild?: (esbuild.BuildOptions & {
208
170
  /**
@@ -232,4 +194,5 @@ export declare const buildConfigSchema: z.ZodObject<{
232
194
  export type EsbuildConfig = z.infer<typeof esbuildConfigSchema>;
233
195
  export type BabelConfig = z.infer<typeof babelConfigSchema>;
234
196
  export type SwcConfig = z.infer<typeof swcConfigSchema>;
197
+ export type ResolverConfig = z.infer<typeof resolverConfigSchema>;
235
198
  export type RawBuildConfig = z.infer<typeof buildConfigSchema>;
@@ -31,11 +31,11 @@ __export(buildConfigSchema_exports, {
31
31
  babelConfigSchema: () => babelConfigSchema,
32
32
  buildConfigSchema: () => buildConfigSchema,
33
33
  esbuildConfigSchema: () => esbuildConfigSchema,
34
+ resolverConfigSchema: () => resolverConfigSchema,
34
35
  swcConfigSchema: () => swcConfigSchema
35
36
  });
36
37
  module.exports = __toCommonJS(buildConfigSchema_exports);
37
38
  var import_zod = __toESM(require("zod"));
38
- const callableSchema = (returnType) => import_zod.default.function().returns(import_zod.default.union([returnType, import_zod.default.promise(returnType)]));
39
39
  const esbuildConfigSchema = import_zod.default.custom();
40
40
  const babelConfigSchema = import_zod.default.object({
41
41
  configFile: import_zod.default.string().optional(),
@@ -46,25 +46,15 @@ const babelConfigSchema = import_zod.default.object({
46
46
  const swcConfigSchema = import_zod.default.object({
47
47
  plugins: import_zod.default.array(import_zod.default.any()).optional()
48
48
  });
49
+ const resolverConfigSchema = import_zod.default.object({
50
+ alias: import_zod.default.array(import_zod.default.custom()).optional(),
51
+ protocols: import_zod.default.custom().optional()
52
+ });
49
53
  const buildConfigSchema = import_zod.default.object({
50
54
  platform: import_zod.default.enum(["ios", "android"]),
51
55
  entry: import_zod.default.string(),
52
56
  outfile: import_zod.default.string(),
53
- resolver: import_zod.default.object({
54
- alias: import_zod.default.array(
55
- import_zod.default.object({
56
- from: import_zod.default.string(),
57
- to: import_zod.default.union([import_zod.default.string(), callableSchema(import_zod.default.string())]),
58
- exact: import_zod.default.boolean().optional()
59
- })
60
- ).optional(),
61
- protocols: import_zod.default.record(
62
- import_zod.default.object({
63
- resolve: callableSchema(import_zod.default.any()).optional(),
64
- load: callableSchema(import_zod.default.any())
65
- })
66
- ).optional()
67
- }).optional(),
57
+ resolver: resolverConfigSchema.optional(),
68
58
  esbuild: esbuildConfigSchema.optional(),
69
59
  babel: babelConfigSchema.optional(),
70
60
  swc: swcConfigSchema.optional(),
@@ -75,5 +65,6 @@ const buildConfigSchema = import_zod.default.object({
75
65
  babelConfigSchema,
76
66
  buildConfigSchema,
77
67
  esbuildConfigSchema,
68
+ resolverConfigSchema,
78
69
  swcConfigSchema
79
70
  });
@@ -34,7 +34,6 @@ module.exports = __toCommonJS(devServerConfigSchema_exports);
34
34
  var import_zod = __toESM(require("zod"));
35
35
  var import_buildConfigSchema = require("./buildConfigSchema");
36
36
  const devServerConfigSchema = import_zod.default.object({
37
- presets: import_zod.default.array(import_zod.default.any()).optional(),
38
37
  build: import_buildConfigSchema.buildConfigSchema.omit({ platform: true, outfile: true })
39
38
  });
40
39
  // Annotate the CommonJS export names for ESM import in node:
@@ -35,7 +35,6 @@ var import_zod = __toESM(require("zod"));
35
35
  var import_buildConfigSchema = require("./buildConfigSchema");
36
36
  const taskConfigSchema = import_zod.default.object({
37
37
  tag: import_zod.default.string(),
38
- presets: import_zod.default.array(import_zod.default.any()).optional(),
39
38
  extra: import_zod.default.any().optional(),
40
39
  build: import_buildConfigSchema.buildConfigSchema
41
40
  });
@@ -0,0 +1,152 @@
1
+ interface BundleDetails {
2
+ bundleType: string;
3
+ dev: boolean;
4
+ entryFile: string;
5
+ minify: boolean;
6
+ platform?: string;
7
+ runtimeBytecodeVersion?: number;
8
+ }
9
+
10
+ type WatcherStatus =
11
+ | {
12
+ type: 'watchman_slow_command';
13
+ timeElapsed: number;
14
+ command: 'watch-project' | 'query';
15
+ }
16
+ | {
17
+ type: 'watchman_slow_command_complete';
18
+ timeElapsed: number;
19
+ command: 'watch-project' | 'query';
20
+ }
21
+ | {
22
+ type: 'watchman_warning';
23
+ warning: unknown;
24
+ command: 'watch-project' | 'query';
25
+ };
26
+
27
+ type HealthCheckResult =
28
+ | {type: 'error'; timeout: number; error: Error; watcher: string | null}
29
+ | {
30
+ type: 'success';
31
+ timeout: number;
32
+ timeElapsed: number;
33
+ watcher: string | null;
34
+ }
35
+ | {
36
+ type: 'timeout';
37
+ timeout: number;
38
+ watcher: string | null;
39
+ pauseReason: string | null;
40
+ };
41
+
42
+ export type ReportableEvent =
43
+ | {
44
+ port: number;
45
+ hasReducedPerformance: boolean;
46
+ type: 'initialize_started';
47
+ }
48
+ | {
49
+ type: 'initialize_failed';
50
+ port: number;
51
+ error: Error;
52
+ }
53
+ | {
54
+ type: 'initialize_done';
55
+ port: number;
56
+ }
57
+ | {
58
+ buildID: string;
59
+ type: 'bundle_build_done';
60
+ }
61
+ | {
62
+ buildID: string;
63
+ type: 'bundle_build_failed';
64
+ }
65
+ | {
66
+ type: 'bundle_save_log';
67
+ message: string;
68
+ }
69
+ | {
70
+ buildID: string;
71
+ bundleDetails: BundleDetails;
72
+ isPrefetch?: boolean;
73
+ type: 'bundle_build_started';
74
+ }
75
+ | {
76
+ error: Error;
77
+ type: 'bundling_error';
78
+ }
79
+ | {
80
+ type: 'dep_graph_loading';
81
+ hasReducedPerformance: boolean;
82
+ }
83
+ | {type: 'dep_graph_loaded'}
84
+ | {
85
+ buildID: string;
86
+ type: 'bundle_transform_progressed';
87
+ transformedFileCount: number;
88
+ totalFileCount: number;
89
+ }
90
+ | {
91
+ type: 'cache_read_error';
92
+ error: Error;
93
+ }
94
+ | {
95
+ type: 'cache_write_error';
96
+ error: Error;
97
+ }
98
+ | {type: 'transform_cache_reset'}
99
+ | {
100
+ type: 'worker_stdout_chunk';
101
+ chunk: string;
102
+ }
103
+ | {
104
+ type: 'worker_stderr_chunk';
105
+ chunk: string;
106
+ }
107
+ | {
108
+ type: 'hmr_client_error';
109
+ error: Error;
110
+ }
111
+ | {
112
+ type: 'client_log';
113
+ level:
114
+ | 'trace'
115
+ | 'info'
116
+ | 'warn'
117
+ | 'log'
118
+ | 'group'
119
+ | 'groupCollapsed'
120
+ | 'groupEnd'
121
+ | 'debug';
122
+ data: Array<unknown>;
123
+ mode: 'BRIDGE' | 'NOBRIDGE';
124
+ }
125
+ | {
126
+ type: 'resolver_warning';
127
+ message: string;
128
+ }
129
+ | {
130
+ type: 'server_listening';
131
+ port: number;
132
+ address: string;
133
+ family: string;
134
+ }
135
+ | {
136
+ type: 'transformer_load_started';
137
+ }
138
+ | {
139
+ type: 'transformer_load_done';
140
+ }
141
+ | {
142
+ type: 'transformer_load_failed';
143
+ error: Error;
144
+ }
145
+ | {
146
+ type: 'watcher_health_check_result';
147
+ result: HealthCheckResult;
148
+ }
149
+ | {
150
+ type: 'watcher_status';
151
+ status: WatcherStatus;
152
+ };
@@ -1,5 +1,5 @@
1
+ import type { ReportableEvent } from "./ReportableEvent";
1
2
  type Terminal = any;
2
- type ReportableEvent = any;
3
3
  type TerminalReportableEvent =
4
4
  | ReportableEvent
5
5
  | {
@@ -15,4 +15,4 @@ declare class TerminalReporter {
15
15
  update(event: TerminalReportableEvent): void;
16
16
  }
17
17
 
18
- export default TerminalReporter;
18
+ export default TerminalReporter;
@@ -359,7 +359,6 @@ function getBabelTransformArgs(file, { options, config, projectRoot }) {
359
359
  // MARK: - GRANITE
360
360
  ...additionalBabelConfig,
361
361
  plugins: additionalBabelConfig?.plugins ?? [],
362
- filename: file.filename,
363
362
  src: file.code
364
363
  };
365
364
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granite-js/mpack",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "A bundler for Granite apps",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -83,8 +83,8 @@
83
83
  "@babel/traverse": "^7.14.0",
84
84
  "@babel/types": "^7.0.0",
85
85
  "@fastify/static": "7.0.1",
86
- "@granite-js/devtools-frontend": "0.1.6",
87
- "@granite-js/utils": "0.1.6",
86
+ "@granite-js/devtools-frontend": "0.1.7",
87
+ "@granite-js/utils": "0.1.7",
88
88
  "@inquirer/prompts": "^7.2.3",
89
89
  "@react-native-community/cli-plugin-metro": "11.3.7",
90
90
  "@react-native-community/cli-server-api": "11.3.7",
@@ -1,3 +0,0 @@
1
- import { BuildConfig } from './BuildConfig';
2
- import type { PresetContext } from './PresetContext';
3
- export type Preset = (context: PresetContext) => Promise<Partial<BuildConfig>> | Partial<BuildConfig>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var Preset_exports = {};
16
- module.exports = __toCommonJS(Preset_exports);
@@ -1,2 +0,0 @@
1
- import type { BundlerConfig } from './BundlerConfig';
2
- export type PresetContext = Pick<BundlerConfig, 'rootDir' | 'appName' | 'scheme' | 'dev'>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var PresetContext_exports = {};
16
- module.exports = __toCommonJS(PresetContext_exports);
@@ -1,2 +0,0 @@
1
- import type { BundlerConfig } from '../types';
2
- export declare function loadConfig({ rootDir }: Pick<BundlerConfig, 'rootDir'>): Promise<import("..").Config | null>;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var loadConfig_exports = {};
20
- __export(loadConfig_exports, {
21
- loadConfig: () => loadConfig
22
- });
23
- module.exports = __toCommonJS(loadConfig_exports);
24
- var import_cosmiconfig = require("cosmiconfig");
25
- var import_schemas = require("../types/schemas");
26
- async function loadConfig({ rootDir }) {
27
- const explorer = await (0, import_cosmiconfig.cosmiconfig)("mpack");
28
- const result = await explorer.search(rootDir);
29
- if (result == null) {
30
- return null;
31
- }
32
- return import_schemas.configSchema.parse(result.config);
33
- }
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- loadConfig
37
- });
@@ -1,2 +0,0 @@
1
- import type { PresetContext, TaskConfig } from '../types';
2
- export declare function loadPresets(task: TaskConfig, context: PresetContext): Promise<TaskConfig>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var loadPresets_exports = {};
20
- __export(loadPresets_exports, {
21
- loadPresets: () => loadPresets
22
- });
23
- module.exports = __toCommonJS(loadPresets_exports);
24
- var import_es_toolkit = require("es-toolkit");
25
- var import_mergeBuildConfigs = require("./mergeBuildConfigs");
26
- async function loadPresets(task, context) {
27
- let buildConfig = task.build;
28
- if (Array.isArray(task.presets) && task.presets.length > 0) {
29
- const [baseConfig, ...configs] = [
30
- ...await Promise.all(task.presets.map(async (preset) => Promise.resolve(preset(context)))),
31
- task.build
32
- ].filter(import_es_toolkit.isNotNil);
33
- buildConfig = (0, import_mergeBuildConfigs.mergeBuildConfigs)({ ...buildConfig, ...baseConfig }, ...configs);
34
- }
35
- return { ...(0, import_es_toolkit.omit)(task, ["presets"]), build: buildConfig };
36
- }
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- loadPresets
40
- });