@granite-js/mpack 2.5.4 → 3.0.0

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @granite-js/mpack
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @granite-js/config@3.0.0
8
+ - @granite-js/plugin-core@3.0.0
9
+ - @granite-js/utils@3.0.0
10
+
11
+ ## 2.5.5
12
+
13
+ ### Patch Changes
14
+
15
+ - @granite-js/plugin-core@2.5.5
16
+ - @granite-js/utils@2.5.5
17
+
3
18
  ## 2.5.4
4
19
 
5
20
  ### Patch Changes
@@ -106,6 +121,27 @@
106
121
  - @granite-js/plugin-core@2.0.0
107
122
  - @granite-js/utils@2.0.0
108
123
 
124
+ ## 1.0.45
125
+
126
+ ### Patch Changes
127
+
128
+ - @granite-js/plugin-core@1.0.45
129
+ - @granite-js/utils@1.0.45
130
+
131
+ ## 1.0.44
132
+
133
+ ### Patch Changes
134
+
135
+ - @granite-js/plugin-core@1.0.44
136
+ - @granite-js/utils@1.0.44
137
+
138
+ ## 1.0.43
139
+
140
+ ### Patch Changes
141
+
142
+ - @granite-js/plugin-core@1.0.43
143
+ - @granite-js/utils@1.0.43
144
+
109
145
  ## 1.0.42
110
146
 
111
147
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @granite-js/mpack
2
2
 
3
- A bundler for Granite apps
3
+ Use `@granite-js/rollipop` for new Granite apps. This package is deprecated.
4
4
 
5
5
  ## License
6
6
 
@@ -0,0 +1,11 @@
1
+ import type { BundlerAdapter } from '@granite-js/config';
2
+ import type { MpackConfig } from './config';
3
+ export interface MpackConfigFileOptions extends Partial<Record<keyof MpackConfig, never>> {
4
+ config?: string;
5
+ }
6
+ export interface MpackInlineOptions extends MpackConfig {
7
+ config?: never;
8
+ }
9
+ export type MpackOptions = MpackConfigFileOptions | MpackInlineOptions;
10
+ /** @deprecated Retained for backward compatibility. */
11
+ export declare function mpack(options?: MpackOptions): BundlerAdapter;
@@ -0,0 +1,147 @@
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 adapter_exports = {};
30
+ __export(adapter_exports, {
31
+ mpack: () => mpack
32
+ });
33
+ module.exports = __toCommonJS(adapter_exports);
34
+ var fs = __toESM(require("node:fs/promises"));
35
+ var import_cache = require("./cache");
36
+ var import_loadConfig = require("./loadConfig");
37
+ var import_build = require("./operations/build");
38
+ var import_serve = require("./operations/serve");
39
+ var import_plugins = require("./plugins");
40
+ var import_prepareConfig = require("./prepareConfig");
41
+ function mpack(options = {}) {
42
+ const hasInlineOptions = Object.keys(options).some((key) => key !== "config");
43
+ if (hasInlineOptions && options.config !== void 0) {
44
+ throw new Error("Mpack config file options cannot be combined with inline configuration.");
45
+ }
46
+ const inlineConfig = hasInlineOptions ? options : void 0;
47
+ const configFile = options.config;
48
+ const pendingMetroResets = /* @__PURE__ */ new WeakSet();
49
+ return {
50
+ name: "mpack",
51
+ async resetCache() {
52
+ await fs.rm(import_cache.Cache.BASE_CACHE_DIR, { recursive: true, force: true });
53
+ pendingMetroResets.add(this.getContext());
54
+ },
55
+ async runBuild(buildOption) {
56
+ const legacyBuildOption = buildOption;
57
+ const context = this.getContext();
58
+ const userConfig = inlineConfig ?? await (0, import_loadConfig.loadMpackConfig)(context, {
59
+ configFile,
60
+ command: "build",
61
+ dev: buildOption.dev
62
+ });
63
+ const config = await (0, import_prepareConfig.prepareConfig)(userConfig, context, {
64
+ outdir: buildOption.outdir,
65
+ outdirSuffix: buildOption.outdirSuffix,
66
+ extra: buildOption.extra,
67
+ legacyConfigs: legacyBuildOption.legacyConfigs
68
+ });
69
+ const result = await (0, import_build.build)({
70
+ config,
71
+ platform: buildOption.platform,
72
+ outfile: buildOption.outfile ?? `bundle.${buildOption.platform}.js`,
73
+ dev: buildOption.dev ?? false,
74
+ cache: buildOption.cache ?? true,
75
+ metafile: false,
76
+ plugins: [import_plugins.statusPlugin, ...userConfig.buildPlugins ?? []]
77
+ });
78
+ return {
79
+ bundle: { source: outputFile(result.bundle.source), sourcemap: outputFile(result.bundle.sourcemap) },
80
+ outfile: result.outfile,
81
+ sourcemapOutfile: result.sourcemapOutfile,
82
+ platform: result.platform,
83
+ extra: result.extra,
84
+ totalModuleCount: result.totalModuleCount,
85
+ duration: result.duration,
86
+ size: result.size
87
+ };
88
+ },
89
+ async runServer(serverOptions) {
90
+ const previousDevServer = process.env.MPACK_DEV_SERVER;
91
+ process.env.MPACK_DEV_SERVER = "true";
92
+ const restoreDevServer = () => {
93
+ if (previousDevServer == null) {
94
+ delete process.env.MPACK_DEV_SERVER;
95
+ } else {
96
+ process.env.MPACK_DEV_SERVER = previousDevServer;
97
+ }
98
+ };
99
+ const context = this.getContext();
100
+ try {
101
+ const userConfig = inlineConfig ?? await (0, import_loadConfig.loadMpackConfig)(context, { configFile, command: "serve" });
102
+ const config = await (0, import_prepareConfig.prepareConfig)(userConfig, context);
103
+ const server = await (0, import_serve.runServer)({
104
+ config,
105
+ host: serverOptions.host,
106
+ port: serverOptions.port,
107
+ interactive: serverOptions.interactive,
108
+ resetCache: pendingMetroResets.has(context)
109
+ });
110
+ pendingMetroResets.delete(context);
111
+ return {
112
+ close: () => new Promise((resolve, reject) => {
113
+ try {
114
+ server.close((error) => {
115
+ restoreDevServer();
116
+ if (error) {
117
+ reject(error);
118
+ } else {
119
+ resolve();
120
+ }
121
+ });
122
+ } catch (error) {
123
+ restoreDevServer();
124
+ reject(error);
125
+ }
126
+ })
127
+ };
128
+ } catch (error) {
129
+ restoreDevServer();
130
+ throw error;
131
+ }
132
+ }
133
+ };
134
+ }
135
+ function outputFile(file) {
136
+ return {
137
+ path: file.path,
138
+ contents: file.contents,
139
+ get text() {
140
+ return file.text;
141
+ }
142
+ };
143
+ }
144
+ // Annotate the CommonJS export names for ESM import in node:
145
+ 0 && (module.exports = {
146
+ mpack
147
+ });
@@ -1,4 +1,4 @@
1
- import { Plugin } from 'esbuild';
1
+ import type { Plugin } from 'esbuild';
2
2
  /**
3
3
  * 파일에 require.context('(.*)')라고 하는 글자가 있으면,
4
4
  * require('require-context:$1') 로 바꾼다.
@@ -55,10 +55,10 @@ function requireContextPlugin() {
55
55
  return {
56
56
  name: "require-context-plugin",
57
57
  setup(build) {
58
- build.onLoad({ filter: /require\.context\.tsx?$/ }, async (args) => {
58
+ build.onLoad({ filter: /require\.context(?:\.[^./\\]+)*\.[jt]sx?$/ }, async (args) => {
59
59
  const content = await import_fs.default.promises.readFile(args.path, "utf8");
60
60
  return {
61
- loader: args.path.endsWith(".tsx") ? "tsx" : "ts",
61
+ loader: import_path.default.extname(args.path).slice(1),
62
62
  contents: (0, import_scripts.toRequireContextExportScript)(content)
63
63
  };
64
64
  });
@@ -0,0 +1,16 @@
1
+ import type { GraniteContext } from '@granite-js/config';
2
+ import type { GraniteConfig as LegacyGraniteConfig } from '@granite-js/plugin-core';
3
+ import type { PluginFactory } from './types';
4
+ type LegacyMpackConfig = Pick<LegacyGraniteConfig, 'entryFile' | 'outdir' | 'build' | 'metro' | 'devServer' | 'reactNativePath'> & {
5
+ plugins?: LegacyGraniteConfig['plugins'];
6
+ };
7
+ export interface MpackConfig extends LegacyMpackConfig {
8
+ buildPlugins?: PluginFactory[];
9
+ }
10
+ export interface MpackConfigContext extends GraniteContext {
11
+ command: 'build' | 'serve';
12
+ mode: 'development' | 'production';
13
+ }
14
+ export type MpackUserConfig = MpackConfig | ((context: MpackConfigContext) => MpackConfig | Promise<MpackConfig>);
15
+ export declare function defineConfig(config: MpackUserConfig): MpackUserConfig;
16
+ export {};
package/dist/config.js ADDED
@@ -0,0 +1,30 @@
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 config_exports = {};
20
+ __export(config_exports, {
21
+ defineConfig: () => defineConfig
22
+ });
23
+ module.exports = __toCommonJS(config_exports);
24
+ function defineConfig(config) {
25
+ return config;
26
+ }
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ defineConfig
30
+ });
@@ -35,7 +35,6 @@ var import_plugin_core = require("@granite-js/plugin-core");
35
35
  var import_constants = require("../../constants");
36
36
  var import_attachKeyHandlers = __toESM(require("../../operations/attachKeyHandlers"));
37
37
  var import_keyReporter = require("../../operations/keyReporter");
38
- var import_printLogo = require("../../utils/printLogo");
39
38
  var import_printServerUrl = require("../../utils/printServerUrl");
40
39
  var import_DevServer = require("../server/DevServer");
41
40
  let keyHandlersAttached = false;
@@ -57,7 +56,6 @@ async function EXPERIMENTAL__server({
57
56
  port,
58
57
  rootDir
59
58
  });
60
- (0, import_printLogo.printLogo)();
61
59
  await server.initialize();
62
60
  await server.listen();
63
61
  await driver.devServer.post({ host, port });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { Bundler } from './bundler';
2
+ export { mpack, type MpackOptions, type MpackConfigFileOptions, type MpackInlineOptions } from './adapter';
3
+ export { defineConfig, type MpackConfig, type MpackConfigContext, type MpackUserConfig } from './config';
2
4
  export { BuildUtils, runServer } from './operations';
3
5
  export { EXPERIMENTAL__server, DevServer } from './experimental';
4
6
  export { getMetroConfig, MetroBuildUtils } from './metro';
package/dist/index.js CHANGED
@@ -28,11 +28,15 @@ __export(index_exports, {
28
28
  MetroBuildUtils: () => import_metro.MetroBuildUtils,
29
29
  SERVICE_BUNDLE_NAME: () => import_constants.SERVICE_BUNDLE_NAME,
30
30
  SHARED_BUNDLE_NAME: () => import_constants.SHARED_BUNDLE_NAME,
31
+ defineConfig: () => import_config.defineConfig,
31
32
  getMetroConfig: () => import_metro.getMetroConfig,
33
+ mpack: () => import_adapter.mpack,
32
34
  runServer: () => import_operations.runServer
33
35
  });
34
36
  module.exports = __toCommonJS(index_exports);
35
37
  var import_bundler = require("./bundler");
38
+ var import_adapter = require("./adapter");
39
+ var import_config = require("./config");
36
40
  var import_operations = require("./operations");
37
41
  var import_experimental = require("./experimental");
38
42
  var import_metro = require("./metro");
@@ -49,6 +53,8 @@ var import_constants = require("./constants");
49
53
  MetroBuildUtils,
50
54
  SERVICE_BUNDLE_NAME,
51
55
  SHARED_BUNDLE_NAME,
56
+ defineConfig,
52
57
  getMetroConfig,
58
+ mpack,
53
59
  runServer
54
60
  });
@@ -0,0 +1,7 @@
1
+ import type { GraniteContext } from '@granite-js/config';
2
+ import type { MpackConfig, MpackConfigContext } from './config';
3
+ export declare function loadMpackConfig(context: GraniteContext, options: {
4
+ configFile?: string;
5
+ command: MpackConfigContext['command'];
6
+ dev?: boolean;
7
+ }): Promise<MpackConfig>;
@@ -0,0 +1,61 @@
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 loadConfig_exports = {};
30
+ __export(loadConfig_exports, {
31
+ loadMpackConfig: () => loadMpackConfig
32
+ });
33
+ module.exports = __toCommonJS(loadConfig_exports);
34
+ var path = __toESM(require("node:path"));
35
+ var import_c12 = require("c12");
36
+ async function loadMpackConfig(context, options) {
37
+ const result = await (0, import_c12.loadConfig)({
38
+ name: "mpack",
39
+ cwd: context.cwd,
40
+ configFile: options.configFile == null ? void 0 : path.resolve(context.cwd, options.configFile),
41
+ configFileRequired: true,
42
+ rcFile: false,
43
+ envName: false,
44
+ extend: false,
45
+ context: {
46
+ ...context,
47
+ command: options.command,
48
+ mode: options.command === "serve" || options.dev ? "development" : "production"
49
+ }
50
+ });
51
+ if (result.configFile == null) {
52
+ throw new Error(
53
+ "Mpack config file not found. Create mpack.config.ts, pass mpack({ config }), or use inline options."
54
+ );
55
+ }
56
+ return result.config;
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ loadMpackConfig
61
+ });
@@ -4,6 +4,8 @@ interface RunServerConfig {
4
4
  host?: string;
5
5
  port?: number;
6
6
  onServerReady?: () => Promise<void> | void;
7
+ interactive?: boolean;
8
+ resetCache?: boolean;
7
9
  }
8
- export declare function runServer({ config, host, port, onServerReady, }: RunServerConfig): Promise<void>;
10
+ export declare function runServer({ config, host, port, onServerReady, interactive, resetCache, }: RunServerConfig): Promise<any>;
9
11
  export {};
@@ -39,7 +39,6 @@ var import_attachKeyHandlers = __toESM(require("./attachKeyHandlers"));
39
39
  var import_constants = require("../constants");
40
40
  var import_keyReporter = require("./keyReporter");
41
41
  var import_getMetroConfig = require("../metro/getMetroConfig");
42
- var import_printLogo = require("../utils/printLogo");
43
42
  var import_printServerUrl = require("../utils/printServerUrl");
44
43
  var import_vendors = require("../vendors");
45
44
  const debug = (0, import_debug.default)("cli:start");
@@ -50,7 +49,9 @@ async function runServer({
50
49
  config,
51
50
  host = import_constants.DEV_SERVER_DEFAULT_HOST,
52
51
  port = import_constants.DEV_SERVER_DEFAULT_PORT,
53
- onServerReady
52
+ onServerReady,
53
+ interactive = true,
54
+ resetCache
54
55
  }) {
55
56
  const devServerHostname = host === "0.0.0.0" ? "localhost" : host;
56
57
  const devServerUrl = new URL(`http://${devServerHostname}:${port}`).origin;
@@ -64,7 +65,8 @@ async function runServer({
64
65
  const { middlewares = [], inspectorProxy, ...additionalMetroConfig } = resolvedConfig?.metro ?? {};
65
66
  const baseConfig = await (0, import_getMetroConfig.getMetroConfig)({ rootPath: config.cwd }, additionalMetroConfig);
66
67
  const metroConfig = mergeConfig(baseConfig, {
67
- server: { port }
68
+ server: { port },
69
+ ...resetCache !== void 0 ? { resetCache } : {}
68
70
  });
69
71
  metroConfig.server.runInspectorProxy = false;
70
72
  const {
@@ -86,13 +88,10 @@ async function runServer({
86
88
  baseConfig.reporter.update(event);
87
89
  }
88
90
  switch (event.type) {
89
- case "initialize_started":
90
- (0, import_printLogo.printLogo)();
91
- break;
92
91
  case "initialize_done":
93
92
  await driver.devServer.post({ host, port });
94
93
  (0, import_printServerUrl.printServerUrl)({ host, port });
95
- if (!keyHandlersAttached) {
94
+ if (interactive && !keyHandlersAttached) {
96
95
  keyHandlersAttached = true;
97
96
  (0, import_attachKeyHandlers.default)({
98
97
  devServerUrl,
@@ -133,6 +132,7 @@ async function runServer({
133
132
  inspectorProxyDelegate: inspectorProxy?.delegate
134
133
  });
135
134
  serverInstance.keepAliveTimeout = 3e4;
135
+ return serverInstance;
136
136
  }
137
137
  // Annotate the CommonJS export names for ESM import in node:
138
138
  0 && (module.exports = {
@@ -0,0 +1,11 @@
1
+ import type { BundlerBuildOption, GraniteContext } from '@granite-js/config';
2
+ import { type PluginConfig } from '@granite-js/plugin-core';
3
+ import type { MpackConfig } from './config';
4
+ export type LegacyCompatibleBuildOption = BundlerBuildOption & {
5
+ legacyConfigs?: PluginConfig[];
6
+ };
7
+ type BuildOverrides = Pick<BundlerBuildOption, 'outdir' | 'outdirSuffix' | 'extra'> & {
8
+ legacyConfigs?: PluginConfig[];
9
+ };
10
+ export declare function prepareConfig(options: MpackConfig, context: GraniteContext, buildOption?: BuildOverrides): Promise<import("@granite-js/plugin-core").CompleteGraniteConfig>;
11
+ export {};
@@ -0,0 +1,57 @@
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 prepareConfig_exports = {};
30
+ __export(prepareConfig_exports, {
31
+ prepareConfig: () => prepareConfig
32
+ });
33
+ module.exports = __toCommonJS(prepareConfig_exports);
34
+ var path = __toESM(require("node:path"));
35
+ var import_plugin_core = require("@granite-js/plugin-core");
36
+ async function prepareConfig(options, context, buildOption) {
37
+ const config = await (0, import_plugin_core.defineConfig)({
38
+ ...options,
39
+ ...context,
40
+ plugins: options.plugins ?? []
41
+ });
42
+ if (buildOption?.outdir != null) {
43
+ config.outdir = path.resolve(context.cwd, buildOption.outdir);
44
+ }
45
+ if (buildOption?.outdirSuffix != null) {
46
+ config.outdir = path.join(config.outdir, buildOption.outdirSuffix);
47
+ }
48
+ config.pluginConfigs.push(...buildOption?.legacyConfigs ?? []);
49
+ if (buildOption?.extra != null) {
50
+ config.pluginConfigs.push({ extra: buildOption.extra });
51
+ }
52
+ return config;
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ prepareConfig
57
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granite-js/mpack",
3
- "version": "2.5.4",
3
+ "version": "3.0.0",
4
4
  "description": "A bundler for Granite apps",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,7 +26,11 @@
26
26
  "types": "./dist/vendors/index.d.ts",
27
27
  "default": "./dist/vendors/index.js"
28
28
  },
29
- "./package.json": "./package.json"
29
+ "./package.json": "./package.json",
30
+ "./config": {
31
+ "types": "./dist/config.d.ts",
32
+ "default": "./dist/config.js"
33
+ }
30
34
  },
31
35
  "files": [
32
36
  "dist",
@@ -40,7 +44,8 @@
40
44
  "build": "tsup && tsc -p tsconfig.build.json && node .scripts/copy-vendors-dts.mjs",
41
45
  "lint": "eslint .",
42
46
  "find-deadcode": "ts-prune",
43
- "test:no-parallel": "vitest --no-watch --no-file-parallelism --coverage"
47
+ "test:no-parallel": "vitest --no-watch --no-file-parallelism --coverage",
48
+ "test:unit": "vitest run --config vitest.unit.config.mts"
44
49
  },
45
50
  "devDependencies": {
46
51
  "@types/accepts": "^1",
@@ -92,8 +97,9 @@
92
97
  "@babel/traverse": "7.28.5",
93
98
  "@babel/types": "7.28.5",
94
99
  "@fastify/middie": "8.3.0",
95
- "@granite-js/plugin-core": "2.5.4",
96
- "@granite-js/utils": "2.5.4",
100
+ "@granite-js/config": "3.0.0",
101
+ "@granite-js/plugin-core": "3.0.0",
102
+ "@granite-js/utils": "3.0.0",
97
103
  "@react-native-community/cli-plugin-metro": "11.3.7",
98
104
  "@react-native-community/cli-server-api": "11.3.7",
99
105
  "@react-native-community/cli-tools": "11.3.7",
@@ -111,6 +117,7 @@
111
117
  "babel-preset-fbjs": "^3.4.0",
112
118
  "browserify-zlib": "0.2.0",
113
119
  "buffer": "6.0.3",
120
+ "c12": "3.3.4",
114
121
  "chalk": "^4",
115
122
  "ci-info": "^2.0.0",
116
123
  "connect": "^3.7.0",
@@ -1 +0,0 @@
1
- export declare function printLogo(): void;
@@ -1,56 +0,0 @@
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 printLogo_exports = {};
30
- __export(printLogo_exports, {
31
- printLogo: () => printLogo
32
- });
33
- module.exports = __toCommonJS(printLogo_exports);
34
- var import_chalk = __toESM(require("chalk"));
35
- const LOGO = [
36
- " \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557",
37
- "\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D",
38
- "\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 ",
39
- "\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D ",
40
- "\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557",
41
- " \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"
42
- ];
43
- const GREETING_MESSAGE = "Welcome to Granite";
44
- function printLogo() {
45
- const maxLength = LOGO.reduce((prev, line) => Math.max(line.length, prev), 0);
46
- console.log();
47
- console.log(LOGO.join("\n"));
48
- const padding = new Array(Math.floor(maxLength / 2 - GREETING_MESSAGE.length / 2)).fill(" ").join("");
49
- console.log(`
50
- ${padding}${import_chalk.default.blue(GREETING_MESSAGE)}
51
- `);
52
- }
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- printLogo
56
- });