@granite-js/mpack 0.1.8 → 0.1.9

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,15 @@
1
1
  # @granite-js/mpack
2
2
 
3
+ ## 0.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 935bb36: fix `BuildUtils` errors and incorrect plugin types
8
+ - Updated dependencies [935bb36]
9
+ - @granite-js/plugin-core@0.1.9
10
+ - @granite-js/devtools-frontend@0.1.9
11
+ - @granite-js/utils@0.1.9
12
+
3
13
  ## 0.1.8
4
14
 
5
15
  ### Patch Changes
@@ -36,6 +36,7 @@ var import_path = __toESM(require("path"));
36
36
  var import_plugin_core = require("@granite-js/plugin-core");
37
37
  var import_es_toolkit = require("es-toolkit");
38
38
  var import_getMetroConfig = require("./getMetroConfig");
39
+ var import_getDefaultOutfileName = require("../utils/getDefaultOutfileName");
39
40
  var import_src = __toESM(require("../vendors/metro/src"));
40
41
  async function build({ config, ...options }) {
41
42
  const driver = (0, import_plugin_core.createPluginHooksDriver)(config);
@@ -51,29 +52,32 @@ async function buildAll(optionsList, { config, concurrency = 2 }) {
51
52
  const semaphore = new import_es_toolkit.Semaphore(Math.min(concurrency, optionsList.length));
52
53
  const driver = (0, import_plugin_core.createPluginHooksDriver)(config);
53
54
  await driver.build.pre();
54
- for (const options of optionsList) {
55
- await semaphore.acquire();
56
- try {
57
- const buildResult = await buildImpl(config, options);
58
- buildResults.push(buildResult);
59
- } catch {
60
- semaphore.release();
61
- }
62
- }
55
+ await Promise.all(
56
+ optionsList.map(async (options) => {
57
+ await semaphore.acquire();
58
+ try {
59
+ const buildResult = await buildImpl(config, options);
60
+ buildResults.push(buildResult);
61
+ } catch {
62
+ semaphore.release();
63
+ }
64
+ })
65
+ );
63
66
  await driver.build.post({ buildResults });
64
67
  return buildResults;
65
68
  }
66
- async function buildImpl(config, { platform, outfile = `bundle.${platform}.js`, minify = false, dev = true }) {
69
+ async function buildImpl(config, { platform, outfile, minify = false, dev = true }) {
67
70
  const metroConfig = await (0, import_getMetroConfig.getMetroConfig)({ rootPath: config.cwd }, config.metro);
68
- const out = import_path.default.join(config.outdir, outfile);
71
+ const outfileName = outfile == null ? (0, import_getDefaultOutfileName.getDefaultOutfileName)(config.entryFile, platform) : outfile;
72
+ const outfilePath = import_path.default.join(config.outdir, outfileName);
69
73
  await import_src.default.runBuild(metroConfig, {
70
- entry: config.entryFile,
71
- out,
72
74
  platform,
75
+ entry: config.entryFile,
76
+ out: outfilePath,
73
77
  minify,
74
78
  dev
75
79
  });
76
- return buildResultShim(config, { outfile, platform, minify, dev });
80
+ return buildResultShim(config, { outfile: outfilePath, platform, minify, dev });
77
81
  }
78
82
  function buildResultShim(config, options) {
79
83
  const unsupportedField = new Proxy({}, {
@@ -38,6 +38,7 @@ var import_plugin_core = require("@granite-js/plugin-core");
38
38
  var import_es_toolkit = require("es-toolkit");
39
39
  var import_bundler = require("../bundler");
40
40
  var import_performance = require("../performance");
41
+ var import_getDefaultOutfileName = require("../utils/getDefaultOutfileName");
41
42
  var import_writeBundle = require("../utils/writeBundle");
42
43
  async function build({ config, plugins = [], ...options }) {
43
44
  const driver = (0, import_plugin_core.createPluginHooksDriver)(config);
@@ -65,8 +66,9 @@ async function buildAll(optionsList, { config, plugins = [], concurrency = 2 })
65
66
  await driver.build.post({ buildResults });
66
67
  return buildResults;
67
68
  }
68
- async function buildImpl(config, plugins, { platform, outfile = `bundle.${platform}.js`, cache = true, dev = true, metafile = false }) {
69
- const resolvedOutfile = path.join(config.outdir, outfile);
69
+ async function buildImpl(config, plugins, { platform, outfile, cache = true, dev = true, metafile = false }) {
70
+ const outfileName = outfile == null ? (0, import_getDefaultOutfileName.getDefaultOutfileName)(config.entryFile, platform) : outfile;
71
+ const outfilePath = path.resolve(config.outdir, outfileName);
70
72
  const bundler = new import_bundler.Bundler({
71
73
  rootDir: config.cwd,
72
74
  cache,
@@ -74,7 +76,8 @@ async function buildImpl(config, plugins, { platform, outfile = `bundle.${platfo
74
76
  metafile,
75
77
  buildConfig: {
76
78
  platform,
77
- outfile: resolvedOutfile,
79
+ entry: config.entryFile,
80
+ outfile: outfilePath,
78
81
  ...config.build
79
82
  }
80
83
  });
@@ -51,7 +51,7 @@ async function EXPERIMENTAL__server({
51
51
  await driver.devServer.pre({ host, port });
52
52
  const rootDir = config.cwd;
53
53
  const server = new import_DevServer.DevServer({
54
- buildConfig: config.build,
54
+ buildConfig: { entry: config.entryFile, ...config.build },
55
55
  middlewares: config.devServer?.middlewares ?? [],
56
56
  host,
57
57
  port,
@@ -0,0 +1 @@
1
+ export declare function getDefaultOutfileName(entryFile: string, platform: 'android' | 'ios'): string;
@@ -0,0 +1,44 @@
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 getDefaultOutfileName_exports = {};
30
+ __export(getDefaultOutfileName_exports, {
31
+ getDefaultOutfileName: () => getDefaultOutfileName
32
+ });
33
+ module.exports = __toCommonJS(getDefaultOutfileName_exports);
34
+ var import_path = __toESM(require("path"));
35
+ function getDefaultOutfileName(entryFile, platform) {
36
+ const basename = import_path.default.basename(entryFile);
37
+ const extname = import_path.default.extname(basename);
38
+ const name = basename.replace(extname, "");
39
+ return `${name}.${platform}.js`;
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ getDefaultOutfileName
44
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granite-js/mpack",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "A bundler for Granite apps",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -83,9 +83,9 @@
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.8",
87
- "@granite-js/plugin-core": "0.1.8",
88
- "@granite-js/utils": "0.1.8",
86
+ "@granite-js/devtools-frontend": "0.1.9",
87
+ "@granite-js/plugin-core": "0.1.9",
88
+ "@granite-js/utils": "0.1.9",
89
89
  "@inquirer/prompts": "^7.2.3",
90
90
  "@react-native-community/cli-plugin-metro": "11.3.7",
91
91
  "@react-native-community/cli-server-api": "11.3.7",
@@ -110,7 +110,7 @@
110
110
  "denodeify": "^1.2.1",
111
111
  "enhanced-resolve": "^5.17.1",
112
112
  "error-stack-parser": "^2.0.6",
113
- "es-toolkit": "^1.26.1",
113
+ "es-toolkit": "^1.39.8",
114
114
  "esbuild": "0.25.8",
115
115
  "events": "3.3.0",
116
116
  "fastify": "4.14.0",