@granite-js/mpack 0.1.15 → 0.1.17
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 +21 -0
- package/dist/bundler/Bundler.d.ts +1 -0
- package/dist/bundler/Bundler.js +14 -0
- package/dist/metro/build.js +2 -1
- package/dist/operations/build.js +6 -2
- package/dist/operations/experimental/serve.js +3 -2
- package/dist/operations/serve.js +4 -1
- package/dist/server/DevServer.js +0 -2
- package/dist/shared/PersistentStorage.d.ts +3 -5
- package/dist/shared/PersistentStorage.js +9 -6
- package/dist/utils/getId.js +14 -1
- package/dist/utils/printErrors.d.ts +1 -0
- package/dist/utils/printErrors.js +32 -0
- package/dist/utils/printServerUrl.d.ts +4 -0
- package/dist/utils/printServerUrl.js +30 -0
- package/dist/utils/progressBar.d.ts +1 -0
- package/dist/utils/progressBar.js +5 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @granite-js/mpack
|
|
2
2
|
|
|
3
|
+
## 0.1.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 07d4020: fix getId generation
|
|
8
|
+
- 9c415df: supports dynamic plugin config
|
|
9
|
+
- dfd1a1e: improve uncaught exception
|
|
10
|
+
- Updated dependencies [9c415df]
|
|
11
|
+
- @granite-js/plugin-core@0.1.17
|
|
12
|
+
- @granite-js/devtools-frontend@0.1.17
|
|
13
|
+
- @granite-js/utils@0.1.17
|
|
14
|
+
|
|
15
|
+
## 0.1.16
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- db8727a: Show dev server URL on startup
|
|
20
|
+
- @granite-js/devtools-frontend@0.1.16
|
|
21
|
+
- @granite-js/plugin-core@0.1.16
|
|
22
|
+
- @granite-js/utils@0.1.16
|
|
23
|
+
|
|
3
24
|
## 0.1.15
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/bundler/Bundler.js
CHANGED
|
@@ -41,9 +41,11 @@ var import_logger = require("../logger");
|
|
|
41
41
|
var import_getId = require("../utils/getId");
|
|
42
42
|
var import_promise = require("../utils/promise");
|
|
43
43
|
var import_presets = require("./internal/presets");
|
|
44
|
+
var import_progressBar = require("../utils/progressBar");
|
|
44
45
|
class Bundler {
|
|
45
46
|
constructor(config) {
|
|
46
47
|
this.config = config;
|
|
48
|
+
this.setupUncaughtExceptionHandler();
|
|
47
49
|
const id = (0, import_getId.getId)(config);
|
|
48
50
|
this.id = id;
|
|
49
51
|
this.pluginDriver = new import_PluginDriver.PluginDriver(id);
|
|
@@ -83,6 +85,18 @@ class Bundler {
|
|
|
83
85
|
this.pluginDriver.addPlugin(plugin);
|
|
84
86
|
return this;
|
|
85
87
|
}
|
|
88
|
+
setupUncaughtExceptionHandler() {
|
|
89
|
+
if (process.hasUncaughtExceptionCaptureCallback()) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
process.setUncaughtExceptionCaptureCallback((error) => {
|
|
93
|
+
(0, import_progressBar.cleanup)();
|
|
94
|
+
import_logger.logger.error(`Uncaught exception occurred
|
|
95
|
+
|
|
96
|
+
${error.stack ?? error.message}`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
86
100
|
getBaseBuildOptions() {
|
|
87
101
|
const { rootDir, metafile, buildConfig } = this.config;
|
|
88
102
|
const { platform, entry, outfile = "bundle.js", esbuild: esbuild2 = {} } = buildConfig;
|
package/dist/metro/build.js
CHANGED
|
@@ -67,7 +67,8 @@ async function buildAll(optionsList, { config, concurrency = 2 }) {
|
|
|
67
67
|
return buildResults;
|
|
68
68
|
}
|
|
69
69
|
async function buildImpl(config, { platform, outfile, minify = false, dev = true }) {
|
|
70
|
-
const
|
|
70
|
+
const resolvedConfig = await (0, import_plugin_core.resolveConfig)(config);
|
|
71
|
+
const metroConfig = await (0, import_getMetroConfig.getMetroConfig)({ rootPath: config.cwd }, resolvedConfig?.metro ?? {});
|
|
71
72
|
const outfileName = outfile == null ? (0, import_getDefaultOutfileName.getDefaultOutfileName)(config.entryFile, platform) : outfile;
|
|
72
73
|
const outfilePath = import_path.default.join(config.outdir, outfileName);
|
|
73
74
|
await import_src.default.runBuild(metroConfig, {
|
package/dist/operations/build.js
CHANGED
|
@@ -40,6 +40,7 @@ var import_bundler = require("../bundler");
|
|
|
40
40
|
var import_performance = require("../performance");
|
|
41
41
|
var import_buildResult = require("../utils/buildResult");
|
|
42
42
|
var import_getDefaultOutfileName = require("../utils/getDefaultOutfileName");
|
|
43
|
+
var import_printErrors = require("../utils/printErrors");
|
|
43
44
|
var import_promise = require("../utils/promise");
|
|
44
45
|
var import_writeBundle = require("../utils/writeBundle");
|
|
45
46
|
async function build({ config, plugins = [], ...options }) {
|
|
@@ -64,7 +65,9 @@ async function buildAll(optionsList, { config, plugins = [], concurrency = 2 })
|
|
|
64
65
|
}
|
|
65
66
|
})
|
|
66
67
|
);
|
|
67
|
-
|
|
68
|
+
const errors = taskResults.filter(import_promise.isRejected);
|
|
69
|
+
if (errors.length) {
|
|
70
|
+
(0, import_printErrors.printErrors)(errors);
|
|
68
71
|
throw new Error("Build failed");
|
|
69
72
|
}
|
|
70
73
|
const buildResults = taskResults.filter(import_promise.isFulfilled).map((result) => result.value);
|
|
@@ -72,6 +75,7 @@ async function buildAll(optionsList, { config, plugins = [], concurrency = 2 })
|
|
|
72
75
|
return buildResults;
|
|
73
76
|
}
|
|
74
77
|
async function buildImpl(config, plugins, { platform, outfile, cache = true, dev = true, metafile = false }) {
|
|
78
|
+
const { metro: _metroConfig, devServer: _devServerConfig, ...buildConfig } = await (0, import_plugin_core.resolveConfig)(config);
|
|
75
79
|
const outfileName = outfile == null ? (0, import_getDefaultOutfileName.getDefaultOutfileName)(config.entryFile, platform) : outfile;
|
|
76
80
|
const outfilePath = path.resolve(config.outdir, outfileName);
|
|
77
81
|
const bundler = new import_bundler.Bundler({
|
|
@@ -83,7 +87,7 @@ async function buildImpl(config, plugins, { platform, outfile, cache = true, dev
|
|
|
83
87
|
platform,
|
|
84
88
|
entry: config.entryFile,
|
|
85
89
|
outfile: outfilePath,
|
|
86
|
-
...
|
|
90
|
+
...buildConfig
|
|
87
91
|
}
|
|
88
92
|
});
|
|
89
93
|
for (const plugin of plugins) {
|
|
@@ -50,9 +50,10 @@ async function EXPERIMENTAL__server({
|
|
|
50
50
|
const driver = (0, import_plugin_core.createPluginHooksDriver)(config);
|
|
51
51
|
await driver.devServer.pre({ host, port });
|
|
52
52
|
const rootDir = config.cwd;
|
|
53
|
+
const { metro: _, devServer, ...buildConfig } = await (0, import_plugin_core.resolveConfig)(config) ?? {};
|
|
53
54
|
const server = new import_DevServer.DevServer({
|
|
54
|
-
buildConfig: { entry: config.entryFile, ...
|
|
55
|
-
middlewares:
|
|
55
|
+
buildConfig: { entry: config.entryFile, ...buildConfig },
|
|
56
|
+
middlewares: devServer?.middlewares ?? [],
|
|
56
57
|
host,
|
|
57
58
|
port,
|
|
58
59
|
rootDir
|
package/dist/operations/serve.js
CHANGED
|
@@ -39,6 +39,7 @@ var import_createDebuggerMiddleware = require("./createDebuggerMiddleware");
|
|
|
39
39
|
var import_constants = require("../constants");
|
|
40
40
|
var import_getMetroConfig = require("../metro/getMetroConfig");
|
|
41
41
|
var import_printLogo = require("../utils/printLogo");
|
|
42
|
+
var import_printServerUrl = require("../utils/printServerUrl");
|
|
42
43
|
var import_vendors = require("../vendors");
|
|
43
44
|
const debug = (0, import_debug.default)("cli:start");
|
|
44
45
|
const { Metro, TerminalReporter } = (0, import_vendors.getModule)("metro");
|
|
@@ -70,6 +71,7 @@ async function runServer({
|
|
|
70
71
|
case "initialize_done":
|
|
71
72
|
enableStdinWatchMode();
|
|
72
73
|
await driver.devServer.post({ host, port });
|
|
74
|
+
(0, import_printServerUrl.printServerUrl)({ host, port });
|
|
73
75
|
await onServerReady?.();
|
|
74
76
|
break;
|
|
75
77
|
default:
|
|
@@ -77,7 +79,8 @@ async function runServer({
|
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
};
|
|
80
|
-
const
|
|
82
|
+
const resolvedConfig = await (0, import_plugin_core.resolveConfig)(config);
|
|
83
|
+
const { middlewares = [], ...additionalMetroConfig } = resolvedConfig?.metro ?? {};
|
|
81
84
|
const baseConfig = await (0, import_getMetroConfig.getMetroConfig)({ rootPath: config.cwd }, additionalMetroConfig);
|
|
82
85
|
const metroConfig = mergeConfig(baseConfig, {
|
|
83
86
|
server: { port },
|
package/dist/server/DevServer.js
CHANGED
|
@@ -43,7 +43,6 @@ var import_wss = require("./wss");
|
|
|
43
43
|
var import_constants = require("../constants");
|
|
44
44
|
var import_logger = require("../logger");
|
|
45
45
|
var import_statusPlugin = require("../plugins/statusPlugin");
|
|
46
|
-
var import_PersistentStorage = require("../shared/PersistentStorage");
|
|
47
46
|
var import_isDebugMode = require("../utils/isDebugMode");
|
|
48
47
|
var import_progressBar = require("../utils/progressBar");
|
|
49
48
|
var import_dev_middleware = require("../vendors/@react-native/dev-middleware");
|
|
@@ -73,7 +72,6 @@ class DevServer {
|
|
|
73
72
|
async initialize() {
|
|
74
73
|
import_logger.logger.trace("DevServer.initialize");
|
|
75
74
|
const { rootDir, buildConfig } = this.devServerOptions;
|
|
76
|
-
await import_PersistentStorage.persistentStorage.loadData();
|
|
77
75
|
this.context = await this.createDevServerContext(rootDir, buildConfig);
|
|
78
76
|
}
|
|
79
77
|
listen() {
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { INTERNAL__Id } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* 파일 시스템에 저장되는 데이터 (캐싱된 메타 데이터)
|
|
4
|
-
*/
|
|
5
2
|
interface PersistentData {
|
|
6
3
|
[id: INTERNAL__Id]: {
|
|
7
4
|
/**
|
|
8
|
-
*
|
|
5
|
+
* Resolved module count (used for progress bar progress calculation)
|
|
9
6
|
*/
|
|
10
7
|
totalModuleCount: number;
|
|
11
8
|
};
|
|
12
9
|
}
|
|
13
10
|
declare class PersistentStorage {
|
|
14
11
|
private data;
|
|
12
|
+
constructor();
|
|
15
13
|
getData(): PersistentData;
|
|
16
14
|
setData(newData: Partial<PersistentData>): void;
|
|
17
|
-
loadData():
|
|
15
|
+
loadData(): void;
|
|
18
16
|
saveData(): Promise<void>;
|
|
19
17
|
}
|
|
20
18
|
export declare const persistentStorage: PersistentStorage;
|
|
@@ -31,32 +31,35 @@ __export(PersistentStorage_exports, {
|
|
|
31
31
|
persistentStorage: () => persistentStorage
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(PersistentStorage_exports);
|
|
34
|
-
var fs = __toESM(require("fs
|
|
34
|
+
var fs = __toESM(require("fs"));
|
|
35
35
|
var path = __toESM(require("path"));
|
|
36
36
|
var import_es_toolkit = require("es-toolkit");
|
|
37
37
|
var import_constants = require("../constants");
|
|
38
38
|
class PersistentStorage {
|
|
39
39
|
data = {};
|
|
40
|
+
constructor() {
|
|
41
|
+
this.loadData();
|
|
42
|
+
}
|
|
40
43
|
getData() {
|
|
41
44
|
return this.data;
|
|
42
45
|
}
|
|
43
46
|
setData(newData) {
|
|
44
47
|
this.data = (0, import_es_toolkit.toMerged)(this.data, newData);
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
loadData() {
|
|
47
50
|
try {
|
|
48
|
-
|
|
51
|
+
fs.accessSync(import_constants.MPACK_DATA_DIR, fs.constants.R_OK | fs.constants.W_OK);
|
|
49
52
|
} catch {
|
|
50
|
-
|
|
53
|
+
fs.mkdirSync(import_constants.MPACK_DATA_DIR, { recursive: true });
|
|
51
54
|
}
|
|
52
55
|
try {
|
|
53
|
-
this.data = JSON.parse(
|
|
56
|
+
this.data = JSON.parse(fs.readFileSync(path.join(import_constants.MPACK_DATA_DIR, ".mpack"), "utf-8"));
|
|
54
57
|
} catch {
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
async saveData() {
|
|
58
61
|
try {
|
|
59
|
-
await fs.writeFile(path.join(import_constants.MPACK_DATA_DIR, ".mpack"), JSON.stringify(this.data, null, 2), "utf-8");
|
|
62
|
+
await fs.promises.writeFile(path.join(import_constants.MPACK_DATA_DIR, ".mpack"), JSON.stringify(this.data, null, 2), "utf-8");
|
|
60
63
|
} catch {
|
|
61
64
|
}
|
|
62
65
|
}
|
package/dist/utils/getId.js
CHANGED
|
@@ -25,7 +25,20 @@ var import_md5 = require("./md5");
|
|
|
25
25
|
var import_constants = require("../constants");
|
|
26
26
|
function getId(bundleConfig) {
|
|
27
27
|
return (0, import_md5.md5)(
|
|
28
|
-
JSON.stringify([
|
|
28
|
+
JSON.stringify([
|
|
29
|
+
import_constants.VERSION,
|
|
30
|
+
bundleConfig.rootDir,
|
|
31
|
+
bundleConfig.dev,
|
|
32
|
+
bundleConfig.buildConfig.resolver,
|
|
33
|
+
bundleConfig.buildConfig.transformer,
|
|
34
|
+
bundleConfig.buildConfig.platform,
|
|
35
|
+
bundleConfig.buildConfig.babel,
|
|
36
|
+
bundleConfig.buildConfig.swc,
|
|
37
|
+
bundleConfig.buildConfig.esbuild?.loader,
|
|
38
|
+
bundleConfig.buildConfig.esbuild?.resolveExtensions,
|
|
39
|
+
bundleConfig.buildConfig.esbuild?.mainFields,
|
|
40
|
+
bundleConfig.buildConfig.esbuild?.conditions
|
|
41
|
+
])
|
|
29
42
|
);
|
|
30
43
|
}
|
|
31
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printErrors(errors: PromiseRejectedResult[]): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 printErrors_exports = {};
|
|
20
|
+
__export(printErrors_exports, {
|
|
21
|
+
printErrors: () => printErrors
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(printErrors_exports);
|
|
24
|
+
function printErrors(errors) {
|
|
25
|
+
for (const error of errors) {
|
|
26
|
+
console.error(error.reason);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
printErrors
|
|
32
|
+
});
|
|
@@ -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 printServerUrl_exports = {};
|
|
20
|
+
__export(printServerUrl_exports, {
|
|
21
|
+
printServerUrl: () => printServerUrl
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(printServerUrl_exports);
|
|
24
|
+
function printServerUrl({ host, port }) {
|
|
25
|
+
console.log(`Development server is running at http://${host}:${port}`);
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
printServerUrl
|
|
30
|
+
});
|
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var progressBar_exports = {};
|
|
30
30
|
__export(progressBar_exports, {
|
|
31
|
+
cleanup: () => cleanup,
|
|
31
32
|
createProgressBar: () => createProgressBar
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(progressBar_exports);
|
|
@@ -91,7 +92,11 @@ function createProgressBar(label) {
|
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
94
|
}
|
|
95
|
+
function cleanup() {
|
|
96
|
+
Frogress.removeAll();
|
|
97
|
+
}
|
|
94
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
99
|
0 && (module.exports = {
|
|
100
|
+
cleanup,
|
|
96
101
|
createProgressBar
|
|
97
102
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/mpack",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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.
|
|
87
|
-
"@granite-js/plugin-core": "0.1.
|
|
88
|
-
"@granite-js/utils": "0.1.
|
|
86
|
+
"@granite-js/devtools-frontend": "0.1.17",
|
|
87
|
+
"@granite-js/plugin-core": "0.1.17",
|
|
88
|
+
"@granite-js/utils": "0.1.17",
|
|
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",
|