@granite-js/mpack 0.1.19 → 0.1.21
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 +18 -0
- package/dist/operations/build.js +3 -0
- package/dist/testing/buildWithEsbuild.d.ts +3 -0
- package/dist/testing/evaluate.d.ts +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/initializeFixture.d.ts +14 -0
- package/dist/testing/tempDir.d.ts +2 -0
- package/dist/utils/writeBundle.d.ts +2 -0
- package/dist/utils/writeBundle.js +11 -2
- package/internal.d.ts +1 -0
- package/package.json +5 -4
- package/plugins.d.ts +1 -0
- package/src/lib.d.ts +61 -0
- package/src/vendors/metro/src/index.d.ts +8 -0
- package/src/vendors/metro/src/lib/ReportableEvent.d.ts +152 -0
- package/src/vendors/metro/src/lib/TerminalReporter.d.ts +18 -0
- package/src/vendors/metro-config/src/defaults/exclusionList.d.ts +3 -0
- package/src/vendors/metro-config/src/defaults/index.d.ts +5 -0
- package/src/vendors/metro-config/src/loadConfig.d.ts +4 -0
- package/src/vendors/metro-core/src/Terminal.d.ts +30 -0
- package/src/vendors/metro-inspector-proxy/src/InspectorProxy.d.ts +21 -0
- package/vendors.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @granite-js/mpack
|
|
2
2
|
|
|
3
|
+
## 0.1.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @granite-js/devtools-frontend@0.1.21
|
|
8
|
+
- @granite-js/plugin-core@0.1.21
|
|
9
|
+
- @granite-js/utils@0.1.21
|
|
10
|
+
|
|
11
|
+
## 0.1.20
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 1df5883: update package.json meta to supports any moduleResolutions
|
|
16
|
+
- a93bf1e: fix metafile generation
|
|
17
|
+
- @granite-js/devtools-frontend@0.1.20
|
|
18
|
+
- @granite-js/plugin-core@0.1.20
|
|
19
|
+
- @granite-js/utils@0.1.20
|
|
20
|
+
|
|
3
21
|
## 0.1.19
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/operations/build.js
CHANGED
|
@@ -96,6 +96,9 @@ async function buildImpl(config, plugins, { platform, outfile, cache = true, dev
|
|
|
96
96
|
const buildResult = await bundler.build();
|
|
97
97
|
if ((0, import_buildResult.isBuildSuccess)(buildResult)) {
|
|
98
98
|
await (0, import_writeBundle.writeBundle)(buildResult.outfile, buildResult.bundle);
|
|
99
|
+
if (buildResult.metafile != null) {
|
|
100
|
+
await (0, import_writeBundle.writeMetafile)(buildResult.outfile, buildResult.metafile);
|
|
101
|
+
}
|
|
99
102
|
const performanceSummary = import_performance.Performance.getSummary();
|
|
100
103
|
if (performanceSummary != null) {
|
|
101
104
|
(0, import_performance.printSummary)(performanceSummary);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function evaluate(code: string): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BuildConfig } from '@granite-js/plugin-core';
|
|
2
|
+
import execa from 'execa';
|
|
3
|
+
export type FixtureTestContext = Awaited<ReturnType<typeof initializeFixture>>;
|
|
4
|
+
export declare function initializeFixture(): Promise<{
|
|
5
|
+
dir: string;
|
|
6
|
+
$: (command: string, args?: string[], options?: execa.Options) => Promise<execa.ExecaReturnValue<string>>;
|
|
7
|
+
installDependencies: (...deps: string[]) => Promise<void>;
|
|
8
|
+
readFile: (relativePath: string) => Promise<string>;
|
|
9
|
+
writeFile: (relativePath: string, content: string) => Promise<void>;
|
|
10
|
+
loadFixtures: (basePath: string, fixtureName: string, placeholders?: Record<string, string>) => Promise<void>;
|
|
11
|
+
buildWithConfig: (config: BuildConfig, options?: execa.Options) => Promise<void>;
|
|
12
|
+
resolvePath: (p: string) => string;
|
|
13
|
+
cleanup: () => Promise<void>;
|
|
14
|
+
}>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { BundleData } from '@granite-js/plugin-core';
|
|
2
|
+
import type { Metafile } from 'esbuild';
|
|
2
3
|
export declare function writeBundle(outputPath: string, { source, sourcemap }: BundleData): Promise<void>;
|
|
4
|
+
export declare function writeMetafile(outputPath: string, metafile: Metafile): Promise<void>;
|
|
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var writeBundle_exports = {};
|
|
30
30
|
__export(writeBundle_exports, {
|
|
31
|
-
writeBundle: () => writeBundle
|
|
31
|
+
writeBundle: () => writeBundle,
|
|
32
|
+
writeMetafile: () => writeMetafile
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(writeBundle_exports);
|
|
34
35
|
var fs = __toESM(require("fs/promises"));
|
|
@@ -43,10 +44,18 @@ async function writeBundle(outputPath, { source, sourcemap }) {
|
|
|
43
44
|
fs.writeFile(path.join(baseDirectory, (0, import_getSourcemapName.getSourcemapName)(basename)), sourcemap.contents, "utf-8")
|
|
44
45
|
]);
|
|
45
46
|
}
|
|
47
|
+
async function writeMetafile(outputPath, metafile) {
|
|
48
|
+
const outputDir = path.dirname(outputPath);
|
|
49
|
+
const extname = path.extname(outputPath);
|
|
50
|
+
const destination = path.join(outputDir, `${path.basename(outputPath, extname)}-meta.json`);
|
|
51
|
+
await createDirectories(outputDir);
|
|
52
|
+
await fs.writeFile(destination, JSON.stringify(metafile, null, 2), "utf-8");
|
|
53
|
+
}
|
|
46
54
|
function createDirectories(directoryPath) {
|
|
47
55
|
return fs.mkdir(directoryPath, { recursive: true });
|
|
48
56
|
}
|
|
49
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
58
|
0 && (module.exports = {
|
|
51
|
-
writeBundle
|
|
59
|
+
writeBundle,
|
|
60
|
+
writeMetafile
|
|
52
61
|
});
|
package/internal.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/internal';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/mpack",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "A bundler for Granite apps",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
+
"*.d.ts",
|
|
24
25
|
"!**/testing",
|
|
25
26
|
"!**/__tests__"
|
|
26
27
|
],
|
|
@@ -83,9 +84,9 @@
|
|
|
83
84
|
"@babel/traverse": "^7.14.0",
|
|
84
85
|
"@babel/types": "^7.0.0",
|
|
85
86
|
"@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.
|
|
87
|
+
"@granite-js/devtools-frontend": "0.1.21",
|
|
88
|
+
"@granite-js/plugin-core": "0.1.21",
|
|
89
|
+
"@granite-js/utils": "0.1.21",
|
|
89
90
|
"@inquirer/prompts": "^7.2.3",
|
|
90
91
|
"@react-native-community/cli-plugin-metro": "11.3.7",
|
|
91
92
|
"@react-native-community/cli-server-api": "11.3.7",
|
package/plugins.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/plugins';
|
package/src/lib.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// metro@0.77.0 이전 버전에는 타입 정의 파일이 패키지에 포함되어있지 않아 임시로 타입 정의 파일을 추가합니다
|
|
2
|
+
|
|
3
|
+
declare module 'metro-core' {
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
* @format
|
|
11
|
+
* @oncall react_native
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as net from 'net';
|
|
15
|
+
import * as stream from 'stream';
|
|
16
|
+
|
|
17
|
+
export type UnderlyingStream = net.Socket | stream.Writable;
|
|
18
|
+
|
|
19
|
+
export class Terminal {
|
|
20
|
+
constructor(stream: UnderlyingStream);
|
|
21
|
+
/**
|
|
22
|
+
* Shows some text that is meant to be overriden later. Return the previous
|
|
23
|
+
* status that was shown and is no more. Calling `status()` with no argument
|
|
24
|
+
* removes the status altogether. The status is never shown in a
|
|
25
|
+
* non-interactive terminal: for example, if the output is redirected to a
|
|
26
|
+
* file, then we don't care too much about having a progress bar.
|
|
27
|
+
*/
|
|
28
|
+
status(format: string, ...args: unknown[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Similar to `console.log`, except it moves the status/progress text out of
|
|
31
|
+
* the way correctly. In non-interactive terminals this is the same as
|
|
32
|
+
* `console.log`.
|
|
33
|
+
*/
|
|
34
|
+
log(format: string, ...args: unknown[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Log the current status and start from scratch. This is useful if the last
|
|
37
|
+
* status was the last one of a series of updates.
|
|
38
|
+
*/
|
|
39
|
+
persistStatus(): void;
|
|
40
|
+
flush(): void;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare module 'metro-react-native-babel-transformer' {
|
|
45
|
+
const babelTransformer: {
|
|
46
|
+
transform: ({
|
|
47
|
+
filename,
|
|
48
|
+
options,
|
|
49
|
+
src,
|
|
50
|
+
plugins,
|
|
51
|
+
}: {
|
|
52
|
+
filename: string;
|
|
53
|
+
options: any;
|
|
54
|
+
src: string;
|
|
55
|
+
plugins: any[];
|
|
56
|
+
}) => { ast: any; metadata?: ant };
|
|
57
|
+
getCacheKey: () => string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default babelTransformer;
|
|
61
|
+
}
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReportableEvent } from "./ReportableEvent";
|
|
2
|
+
type Terminal = any;
|
|
3
|
+
type TerminalReportableEvent =
|
|
4
|
+
| ReportableEvent
|
|
5
|
+
| {
|
|
6
|
+
buildID: string;
|
|
7
|
+
type: 'bundle_transform_progressed_throttled';
|
|
8
|
+
transformedFileCount: number;
|
|
9
|
+
totalFileCount: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
declare class TerminalReporter {
|
|
13
|
+
readonly terminal: Terminal;
|
|
14
|
+
constructor(terminal: Terminal);
|
|
15
|
+
update(event: TerminalReportableEvent): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default TerminalReporter;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as net from 'net';
|
|
2
|
+
import type * as stream from 'stream';
|
|
3
|
+
|
|
4
|
+
type UnderlyingStream = net.Socket | stream.Writable;
|
|
5
|
+
|
|
6
|
+
declare class Terminal {
|
|
7
|
+
constructor(stream: UnderlyingStream);
|
|
8
|
+
/**
|
|
9
|
+
* Shows some text that is meant to be overriden later. Return the previous
|
|
10
|
+
* status that was shown and is no more. Calling `status()` with no argument
|
|
11
|
+
* removes the status altogether. The status is never shown in a
|
|
12
|
+
* non-interactive terminal: for example, if the output is redirected to a
|
|
13
|
+
* file, then we don't care too much about having a progress bar.
|
|
14
|
+
*/
|
|
15
|
+
status(format: string, ...args: unknown[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* Similar to `console.log`, except it moves the status/progress text out of
|
|
18
|
+
* the way correctly. In non-interactive terminals this is the same as
|
|
19
|
+
* `console.log`.
|
|
20
|
+
*/
|
|
21
|
+
log(format: string, ...args: unknown[]): void;
|
|
22
|
+
/**
|
|
23
|
+
* Log the current status and start from scratch. This is useful if the last
|
|
24
|
+
* status was the last one of a series of updates.
|
|
25
|
+
*/
|
|
26
|
+
persistStatus(): void;
|
|
27
|
+
flush(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default Terminal;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as ws from 'ws';
|
|
3
|
+
|
|
4
|
+
declare class Device {
|
|
5
|
+
getName(): string;
|
|
6
|
+
getPageList(): unknown[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare class InspectorProxy {
|
|
10
|
+
static devices: Map<number, Device>;
|
|
11
|
+
|
|
12
|
+
processRequest: (request: http.IncomingMessage, response: http.ServerResponse, next: (error?: Error) => void) => void;
|
|
13
|
+
createWebSocketListeners: (server: http.Server) => {
|
|
14
|
+
['/inspector/device']: ws.WebSocketServer;
|
|
15
|
+
['/inspector/debug']: ws.WebSocketServer;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
constructor(projectRoot: string);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default InspectorProxy;
|
package/vendors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/vendors';
|