@granite-js/mpack 0.1.23-next.6 → 0.1.23
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 +4 -44
- package/dist/bundler/plugins/transformPlugin/steps/createFullyTransformStep.js +1 -1
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.d.ts +6 -0
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.js +91 -0
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.d.ts +2 -1
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.js +19 -5
- package/dist/bundler/plugins/transformPlugin/transformPlugin.js +5 -11
- package/dist/transformer/AsyncTransformPipeline.js +7 -24
- package/dist/transformer/TransformPipeline.d.ts +12 -17
- package/dist/transformer/TransformPipeline.js +2 -6
- package/package.json +10 -15
- package/src/lib.d.ts +0 -90
- package/dist/bundler/plugins/transformPlugin/steps/createFlowStripStep.d.ts +0 -2
- package/dist/bundler/plugins/transformPlugin/steps/createFlowStripStep.js +0 -62
- package/dist/bundler/plugins/transformPlugin/steps/createTransformCodegenStep.d.ts +0 -2
- package/dist/bundler/plugins/transformPlugin/steps/createTransformCodegenStep.js +0 -70
package/CHANGELOG.md
CHANGED
|
@@ -1,52 +1,12 @@
|
|
|
1
1
|
# @granite-js/mpack
|
|
2
2
|
|
|
3
|
-
## 0.1.23
|
|
3
|
+
## 0.1.23
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
- @granite-js/plugin-core@0.1.23-next.6
|
|
11
|
-
- @granite-js/utils@0.1.23-next.6
|
|
12
|
-
|
|
13
|
-
## 0.1.23-next.5
|
|
14
|
-
|
|
15
|
-
### Patch Changes
|
|
16
|
-
|
|
17
|
-
- temp
|
|
18
|
-
- Updated dependencies
|
|
19
|
-
- @granite-js/devtools-frontend@0.1.23-next.5
|
|
20
|
-
- @granite-js/plugin-core@0.1.23-next.5
|
|
21
|
-
- @granite-js/utils@0.1.23-next.5
|
|
22
|
-
|
|
23
|
-
## 0.1.23-next.4
|
|
24
|
-
|
|
25
|
-
### Patch Changes
|
|
26
|
-
|
|
27
|
-
- test
|
|
28
|
-
- Updated dependencies
|
|
29
|
-
- @granite-js/devtools-frontend@0.1.23-next.4
|
|
30
|
-
- @granite-js/plugin-core@0.1.23-next.4
|
|
31
|
-
- @granite-js/utils@0.1.23-next.4
|
|
32
|
-
|
|
33
|
-
## 0.1.23-next.3
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- test
|
|
38
|
-
- Updated dependencies
|
|
39
|
-
- @granite-js/devtools-frontend@0.1.23-next.3
|
|
40
|
-
- @granite-js/plugin-core@0.1.23-next.3
|
|
41
|
-
- @granite-js/utils@0.1.23-next.3
|
|
42
|
-
|
|
43
|
-
## 0.1.23-next.0
|
|
44
|
-
|
|
45
|
-
### Patch Changes
|
|
46
|
-
|
|
47
|
-
- @granite-js/devtools-frontend@0.1.23-next.0
|
|
48
|
-
- @granite-js/plugin-core@0.1.23-next.0
|
|
49
|
-
- @granite-js/utils@0.1.23-next.0
|
|
7
|
+
- @granite-js/devtools-frontend@0.1.23
|
|
8
|
+
- @granite-js/plugin-core@0.1.23
|
|
9
|
+
- @granite-js/utils@0.1.23
|
|
50
10
|
|
|
51
11
|
## 0.1.22
|
|
52
12
|
|
|
@@ -71,13 +71,13 @@ function createFullyTransformStep({
|
|
|
71
71
|
* @babel/preset-react 포함 필요
|
|
72
72
|
*/
|
|
73
73
|
[require.resolve("@babel/preset-react"), { runtime: "automatic" }],
|
|
74
|
-
[require.resolve("@react-native/babel-preset")],
|
|
75
74
|
...additionalBabelOptions?.presets ?? []
|
|
76
75
|
],
|
|
77
76
|
plugins: [
|
|
78
77
|
/**
|
|
79
78
|
* react-native에서 직접 export 하는 flow 파일 대응을 위해 strip types 추가 필요
|
|
80
79
|
*/
|
|
80
|
+
require.resolve("@babel/plugin-transform-flow-strip-types"),
|
|
81
81
|
[require.resolve("@babel/plugin-proposal-class-properties"), { loose: true }],
|
|
82
82
|
[require.resolve("@babel/plugin-proposal-private-property-in-object"), { loose: true }],
|
|
83
83
|
[require.resolve("@babel/plugin-proposal-private-methods"), { loose: true }],
|
|
@@ -0,0 +1,91 @@
|
|
|
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 createStripFlowStep_exports = {};
|
|
30
|
+
__export(createStripFlowStep_exports, {
|
|
31
|
+
createStripFlowStep: () => createStripFlowStep
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(createStripFlowStep_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var babel = __toESM(require("@babel/core"));
|
|
36
|
+
var sucrase = __toESM(require("sucrase"));
|
|
37
|
+
var import_defineStepName = require("../../../../utils/defineStepName");
|
|
38
|
+
function createStripFlowStep(config) {
|
|
39
|
+
const stripImportTypeofStatements = (code) => {
|
|
40
|
+
return code.split("\n").filter((line) => !line.startsWith("import typeof ")).join("\n");
|
|
41
|
+
};
|
|
42
|
+
const stripFlowStep = async function stripFlow(code, args) {
|
|
43
|
+
const shouldTransform = args.path.endsWith(".js");
|
|
44
|
+
if (!shouldTransform) {
|
|
45
|
+
return { code };
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const result = sucrase.transform(code, {
|
|
49
|
+
transforms: ["flow", "jsx"],
|
|
50
|
+
jsxRuntime: "preserve",
|
|
51
|
+
disableESTransforms: true
|
|
52
|
+
});
|
|
53
|
+
return { code: stripImportTypeofStatements(result.code) };
|
|
54
|
+
} catch {
|
|
55
|
+
const result = await babel.transformAsync(code, {
|
|
56
|
+
configFile: false,
|
|
57
|
+
minified: false,
|
|
58
|
+
compact: false,
|
|
59
|
+
babelrc: false,
|
|
60
|
+
envName: config.dev ? "development" : "production",
|
|
61
|
+
caller: {
|
|
62
|
+
name: "mpack-strip-flow-plugin",
|
|
63
|
+
supportsStaticESM: true
|
|
64
|
+
},
|
|
65
|
+
presets: [
|
|
66
|
+
/**
|
|
67
|
+
* flow 구문과 jsx 구문이 함께 존재하는 경우가 있기에 preset-react 사용
|
|
68
|
+
*/
|
|
69
|
+
[require.resolve("@babel/preset-react"), { runtime: "automatic" }]
|
|
70
|
+
],
|
|
71
|
+
plugins: [
|
|
72
|
+
/**
|
|
73
|
+
* flow 구문 변환을 위해 flow-strip-types 사용
|
|
74
|
+
*/
|
|
75
|
+
require.resolve("@babel/plugin-transform-flow-strip-types")
|
|
76
|
+
],
|
|
77
|
+
filename: import_path.default.basename(args.path)
|
|
78
|
+
});
|
|
79
|
+
if (result?.code != null) {
|
|
80
|
+
return { code: result.code };
|
|
81
|
+
}
|
|
82
|
+
throw new Error("babel transform result is null");
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
(0, import_defineStepName.defineStepName)(stripFlowStep, "strip-flow");
|
|
86
|
+
return stripFlowStep;
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
createStripFlowStep
|
|
91
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { BuildConfig } from '@granite-js/plugin-core';
|
|
2
2
|
import { AsyncTransformStep } from '../../../../transformer/TransformPipeline';
|
|
3
|
-
|
|
3
|
+
interface TransformToHermesSyntaxStepConfig {
|
|
4
4
|
dev: boolean;
|
|
5
5
|
additionalSwcOptions?: BuildConfig['swc'];
|
|
6
6
|
}
|
|
7
7
|
export declare function createTransformToHermesSyntaxStep({ dev, additionalSwcOptions, }: TransformToHermesSyntaxStepConfig): AsyncTransformStep;
|
|
8
|
+
export {};
|
|
@@ -36,6 +36,17 @@ var swc = __toESM(require("@swc/core"));
|
|
|
36
36
|
var import_es_toolkit = require("es-toolkit");
|
|
37
37
|
var import_defineStepName = require("../../../../utils/defineStepName");
|
|
38
38
|
var import_swc = require("../../shared/swc");
|
|
39
|
+
function getParserConfig(filepath) {
|
|
40
|
+
return /\.tsx?$/.test(filepath) ? {
|
|
41
|
+
syntax: "typescript",
|
|
42
|
+
tsx: true,
|
|
43
|
+
dynamicImport: true
|
|
44
|
+
} : {
|
|
45
|
+
syntax: "ecmascript",
|
|
46
|
+
jsx: true,
|
|
47
|
+
exportDefaultFrom: true
|
|
48
|
+
};
|
|
49
|
+
}
|
|
39
50
|
function createTransformToHermesSyntaxStep({
|
|
40
51
|
dev,
|
|
41
52
|
additionalSwcOptions = {}
|
|
@@ -47,11 +58,7 @@ function createTransformToHermesSyntaxStep({
|
|
|
47
58
|
isModule: true,
|
|
48
59
|
jsc: {
|
|
49
60
|
...import_swc.swcHelperOptimizationRules.jsc,
|
|
50
|
-
parser:
|
|
51
|
-
syntax: "typescript",
|
|
52
|
-
tsx: true,
|
|
53
|
-
dynamicImport: true
|
|
54
|
-
},
|
|
61
|
+
parser: getParserConfig(args.path),
|
|
55
62
|
target: "es5",
|
|
56
63
|
keepClassNames: true,
|
|
57
64
|
transform: {
|
|
@@ -62,6 +69,13 @@ function createTransformToHermesSyntaxStep({
|
|
|
62
69
|
},
|
|
63
70
|
experimental: { plugins },
|
|
64
71
|
loose: false,
|
|
72
|
+
/**
|
|
73
|
+
* 타입정의가 없지만 실제로는 동작하는 것이 스펙
|
|
74
|
+
*
|
|
75
|
+
* @see {@link https://github.com/swc-project/swc/blob/v1.4.10/crates/swc_ecma_transforms_base/src/assumptions.rs#L11}
|
|
76
|
+
*/
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
78
|
+
// @ts-ignore
|
|
65
79
|
assumptions: {
|
|
66
80
|
setPublicClassFields: true,
|
|
67
81
|
privateFieldsAsProperties: true
|
|
@@ -35,9 +35,8 @@ var import_assert = __toESM(require("assert"));
|
|
|
35
35
|
var fs = __toESM(require("fs/promises"));
|
|
36
36
|
var preludeScript = __toESM(require("./helpers/preludeScript"));
|
|
37
37
|
var import_createCacheSteps = require("./steps/createCacheSteps");
|
|
38
|
-
var import_createFlowStripStep = require("./steps/createFlowStripStep");
|
|
39
38
|
var import_createFullyTransformStep = require("./steps/createFullyTransformStep");
|
|
40
|
-
var
|
|
39
|
+
var import_createStripFlowStep = require("./steps/createStripFlowStep");
|
|
41
40
|
var import_createTransformToHermesSyntaxStep = require("./steps/createTransformToHermesSyntaxStep");
|
|
42
41
|
var import_performance = require("../../../performance");
|
|
43
42
|
var import_transformer = require("../../../transformer");
|
|
@@ -61,15 +60,10 @@ function transformPlugin({ context, ...options }) {
|
|
|
61
60
|
code = await options.transformAsync(args.path, code);
|
|
62
61
|
}
|
|
63
62
|
return { code };
|
|
64
|
-
}).addStep({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}).addStep({
|
|
69
|
-
if: ({ path }) => /(?:^|[\\/])(?:Native\w+|(\w+)NativeComponent)\.[jt]sx?$/.test(path),
|
|
70
|
-
then: (0, import_createTransformCodegenStep.createTransformCodegenStep)(),
|
|
71
|
-
else: (0, import_createFlowStripStep.createFlowStripStep)()
|
|
72
|
-
}).addStep((0, import_createTransformToHermesSyntaxStep.createTransformToHermesSyntaxStep)({ dev, additionalSwcOptions: swc })).afterStep(cacheSteps.afterTransform);
|
|
63
|
+
}).addStep((0, import_createFullyTransformStep.createFullyTransformStep)({ dev, additionalBabelOptions: babel }), {
|
|
64
|
+
conditions: babel?.conditions,
|
|
65
|
+
skipOtherSteps: true
|
|
66
|
+
}).addStep((0, import_createStripFlowStep.createStripFlowStep)({ dev })).addStep((0, import_createTransformToHermesSyntaxStep.createTransformToHermesSyntaxStep)({ dev, additionalSwcOptions: swc })).afterStep(cacheSteps.afterTransform);
|
|
73
67
|
preludeScript.registerEntryPointMarker(build);
|
|
74
68
|
preludeScript.registerPreludeScriptResolver(build);
|
|
75
69
|
build.onLoad({ filter: sourceRegExp }, async (args) => {
|
|
@@ -33,36 +33,19 @@ class AsyncTransformPipeline extends import_TransformPipeline.TransformPipeline
|
|
|
33
33
|
return this._afterStep ? this._afterStep(code2, args2, context2) : Promise.resolve({ code: code2, done: true });
|
|
34
34
|
};
|
|
35
35
|
let result = await before(code, args, context);
|
|
36
|
-
for await (const
|
|
36
|
+
for await (const [step, config] of this.steps) {
|
|
37
37
|
if (result.done) {
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
|
-
if (
|
|
40
|
+
if (config?.conditions == null || Array.isArray(config?.conditions) && config.conditions.some((condition) => condition(result.code, args.path))) {
|
|
41
41
|
let trace;
|
|
42
|
-
if (typeof
|
|
43
|
-
trace = import_performance.Performance.trace(`step-${
|
|
42
|
+
if (typeof step.name === "string") {
|
|
43
|
+
trace = import_performance.Performance.trace(`step-${step.name}`, { detail: { file: args.path } });
|
|
44
44
|
}
|
|
45
|
-
result = await
|
|
45
|
+
result = await step(result.code, args, context);
|
|
46
46
|
trace?.stop();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (condition.if({ path: args.path, code: result.code })) {
|
|
50
|
-
let trace;
|
|
51
|
-
if (typeof condition.then.name === "string") {
|
|
52
|
-
trace = import_performance.Performance.trace(`step-${condition.then.name}`, { detail: { file: args.path } });
|
|
53
|
-
}
|
|
54
|
-
result = await condition.then(result.code, args, context);
|
|
55
|
-
trace?.stop();
|
|
56
|
-
if (condition.stopAfter) {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
} else if (condition.else) {
|
|
60
|
-
let trace;
|
|
61
|
-
if (typeof condition.else.name === "string") {
|
|
62
|
-
trace = import_performance.Performance.trace(`step-${condition.else.name}`, { detail: { file: args.path } });
|
|
63
|
-
}
|
|
64
|
-
result = await condition.else(result.code, args, context);
|
|
65
|
-
trace?.stop();
|
|
47
|
+
if (config?.skipOtherSteps) {
|
|
48
|
+
break;
|
|
66
49
|
}
|
|
67
50
|
}
|
|
68
51
|
}
|
|
@@ -13,29 +13,24 @@ interface TransformStep<TransformResult> {
|
|
|
13
13
|
(code: string, args: TransformStepArgs, context: TransformStepContext): TransformResult;
|
|
14
14
|
name?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
export type StepInput = AsyncTransformStep | ConditionalStep;
|
|
27
|
-
interface StepEntry {
|
|
28
|
-
type: 'normal' | 'conditional';
|
|
29
|
-
step?: AsyncTransformStep;
|
|
30
|
-
condition?: ConditionalStep;
|
|
16
|
+
interface TransformStepConfig {
|
|
17
|
+
/**
|
|
18
|
+
* step 을 실행하기 위한 조건 (기본값: 항상 실행)
|
|
19
|
+
*/
|
|
20
|
+
conditions?: Array<(code: string, path: string) => boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* 현재 step 이 실행된 경우 done 처리 여부 (기본값: false)
|
|
23
|
+
*/
|
|
24
|
+
skipOtherSteps?: boolean;
|
|
31
25
|
}
|
|
26
|
+
export type AsyncTransformStep = TransformStep<Promise<TransformStepResult>>;
|
|
32
27
|
export declare abstract class TransformPipeline<Step extends TransformStep<unknown>> {
|
|
33
28
|
protected _beforeStep?: Step;
|
|
34
29
|
protected _afterStep?: Step;
|
|
35
|
-
protected steps:
|
|
30
|
+
protected steps: Array<[Step, TransformStepConfig | null]>;
|
|
36
31
|
beforeStep(step: Step): this;
|
|
37
32
|
afterStep(step: Step): this;
|
|
38
|
-
addStep(step:
|
|
33
|
+
addStep(step: Step, config?: TransformStepConfig): this;
|
|
39
34
|
getStepContext(args: TransformStepArgs): Promise<TransformStepContext>;
|
|
40
35
|
abstract transform(code: string, args: TransformStepArgs): ReturnType<Step>;
|
|
41
36
|
}
|
|
@@ -46,12 +46,8 @@ class TransformPipeline {
|
|
|
46
46
|
this._afterStep = step;
|
|
47
47
|
return this;
|
|
48
48
|
}
|
|
49
|
-
addStep(step) {
|
|
50
|
-
|
|
51
|
-
this.steps.push({ type: "normal", step });
|
|
52
|
-
} else {
|
|
53
|
-
this.steps.push({ type: "conditional", condition: step });
|
|
54
|
-
}
|
|
49
|
+
addStep(step, config) {
|
|
50
|
+
this.steps.push([step, config ?? null]);
|
|
55
51
|
return this;
|
|
56
52
|
}
|
|
57
53
|
async getStepContext(args) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/mpack",
|
|
3
|
-
"version": "0.1.23
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "A bundler for Granite apps",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"eslint": "9.7.0",
|
|
63
63
|
"execa": "^5.0.0",
|
|
64
64
|
"fast-glob": "^3.3.2",
|
|
65
|
+
"flow-remove-types": "^2.251.1",
|
|
65
66
|
"prettier-2": "npm:prettier@^2",
|
|
66
67
|
"ts-prune": "^0.10.3",
|
|
67
68
|
"typescript": "5.8.3",
|
|
@@ -75,33 +76,29 @@
|
|
|
75
76
|
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
76
77
|
"@babel/plugin-proposal-private-methods": "7.18.6",
|
|
77
78
|
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
|
|
78
|
-
"@babel/plugin-
|
|
79
|
-
"@babel/plugin-transform-flow-strip-types": "npm:7.27.1",
|
|
79
|
+
"@babel/plugin-transform-flow-strip-types": "7.23.3",
|
|
80
80
|
"@babel/preset-env": "7.23.3",
|
|
81
81
|
"@babel/preset-react": "7.23.3",
|
|
82
|
-
"@babel/preset-typescript": "7.
|
|
82
|
+
"@babel/preset-typescript": "7.23.3",
|
|
83
83
|
"@babel/template": "^7.0.0",
|
|
84
84
|
"@babel/traverse": "^7.14.0",
|
|
85
85
|
"@babel/types": "^7.0.0",
|
|
86
86
|
"@fastify/static": "7.0.1",
|
|
87
|
-
"@granite-js/devtools-frontend": "0.1.23
|
|
88
|
-
"@granite-js/plugin-core": "0.1.23
|
|
89
|
-
"@granite-js/utils": "0.1.23
|
|
87
|
+
"@granite-js/devtools-frontend": "0.1.23",
|
|
88
|
+
"@granite-js/plugin-core": "0.1.23",
|
|
89
|
+
"@granite-js/utils": "0.1.23",
|
|
90
90
|
"@inquirer/prompts": "^7.2.3",
|
|
91
91
|
"@react-native-community/cli-plugin-metro": "11.3.7",
|
|
92
92
|
"@react-native-community/cli-server-api": "11.3.7",
|
|
93
93
|
"@react-native-community/cli-tools": "11.3.7",
|
|
94
|
-
"@react-native/babel-plugin-codegen": "npm:0.81.3",
|
|
95
|
-
"@react-native/babel-preset": "npm:0.81.3",
|
|
96
94
|
"@react-native/dev-middleware": "0.73.8",
|
|
97
95
|
"@shopify/semaphore": "^3.1.0",
|
|
98
|
-
"@swc/core": "
|
|
99
|
-
"@swc/helpers": "
|
|
96
|
+
"@swc/core": "1.5.24",
|
|
97
|
+
"@swc/helpers": "0.5.13",
|
|
100
98
|
"absolute-path": "^0.0.0",
|
|
101
99
|
"accepts": "^1.3.7",
|
|
102
100
|
"assert": "2.1.0",
|
|
103
101
|
"async": "^3.2.2",
|
|
104
|
-
"babel-plugin-syntax-hermes-parser": "^0.31.0",
|
|
105
102
|
"babel-preset-fbjs": "^3.4.0",
|
|
106
103
|
"browserify-zlib": "0.2.0",
|
|
107
104
|
"buffer": "6.0.3",
|
|
@@ -119,11 +116,10 @@
|
|
|
119
116
|
"events": "3.3.0",
|
|
120
117
|
"fastify": "4.14.0",
|
|
121
118
|
"fastify-plugin": "4.5.1",
|
|
122
|
-
"flow-remove-types": "^2.279.0",
|
|
123
119
|
"frogress-bar": "^0.1.0",
|
|
124
120
|
"fs-extra": "^1.0.0",
|
|
125
121
|
"graceful-fs": "^4.2.4",
|
|
126
|
-
"hermes-parser": "0.
|
|
122
|
+
"hermes-parser": "0.8.0",
|
|
127
123
|
"https-browserify": "1.0.0",
|
|
128
124
|
"image-size": "^0.6.0",
|
|
129
125
|
"invariant": "^2.2.4",
|
|
@@ -147,7 +143,6 @@
|
|
|
147
143
|
"mime-types": "^2.1.27",
|
|
148
144
|
"node-fetch": "^2.2.0",
|
|
149
145
|
"nullthrows": "^1.1.1",
|
|
150
|
-
"oxc-transform": "^0.82.1",
|
|
151
146
|
"path-browserify": "1.0.1",
|
|
152
147
|
"react-native-devtools-standalone": "^0.4.1",
|
|
153
148
|
"rimraf": "^2.5.4",
|
package/src/lib.d.ts
CHANGED
|
@@ -59,93 +59,3 @@ declare module 'metro-react-native-babel-transformer' {
|
|
|
59
59
|
|
|
60
60
|
export default babelTransformer;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
declare module 'flow-remove-types' {
|
|
64
|
-
declare const removeTypes: (
|
|
65
|
-
code: string,
|
|
66
|
-
options: {
|
|
67
|
-
all?: boolean;
|
|
68
|
-
ignoreUninitializedFields?: boolean;
|
|
69
|
-
pretty?: boolean;
|
|
70
|
-
removeEmptyImports?: boolean;
|
|
71
|
-
}
|
|
72
|
-
) => {
|
|
73
|
-
toString(): string;
|
|
74
|
-
generateMap(): {
|
|
75
|
-
version: number;
|
|
76
|
-
sources: string[];
|
|
77
|
-
names: string[];
|
|
78
|
-
mappings: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
export = removeTypes;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
declare module 'hermes-parser' {
|
|
85
|
-
export type ParserOptions = {
|
|
86
|
-
allowReturnOutsideFunction?: boolean;
|
|
87
|
-
babel?: boolean;
|
|
88
|
-
flow?: 'all' | 'detect';
|
|
89
|
-
enableExperimentalComponentSyntax?: boolean;
|
|
90
|
-
enableExperimentalFlowMatchSyntax?: boolean;
|
|
91
|
-
reactRuntimeTarget?: '18' | '19';
|
|
92
|
-
sourceFilename?: string;
|
|
93
|
-
sourceType?: 'module' | 'script' | 'unambiguous';
|
|
94
|
-
tokens?: boolean;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const ParserOptionsKeys: ReadonlySet<keyof ParserOptions>;
|
|
98
|
-
|
|
99
|
-
export type HermesPosition = {
|
|
100
|
-
/** >= 1 */
|
|
101
|
-
line: number;
|
|
102
|
-
/** >= 0 */
|
|
103
|
-
column: number;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export type HermesSourceLocation = {
|
|
107
|
-
start?: HermesPosition;
|
|
108
|
-
end?: HermesPosition;
|
|
109
|
-
rangeStart?: number;
|
|
110
|
-
rangeEnd?: number;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export type HermesNode = {
|
|
114
|
-
type: string;
|
|
115
|
-
[key: string]: any;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export type HermesToken = {
|
|
119
|
-
type:
|
|
120
|
-
| 'Boolean'
|
|
121
|
-
| 'Identifier'
|
|
122
|
-
| 'Keyword'
|
|
123
|
-
| 'Null'
|
|
124
|
-
| 'Numeric'
|
|
125
|
-
| 'BigInt'
|
|
126
|
-
| 'Punctuator'
|
|
127
|
-
| 'String'
|
|
128
|
-
| 'RegularExpression'
|
|
129
|
-
| 'Template'
|
|
130
|
-
| 'JSXText';
|
|
131
|
-
loc: HermesSourceLocation;
|
|
132
|
-
value?: string | null;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export type HermesComment = {
|
|
136
|
-
type: 'CommentLine' | 'CommentBlock' | 'InterpreterDirective';
|
|
137
|
-
loc: HermesSourceLocation;
|
|
138
|
-
value?: string | null;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export type HermesProgram = {
|
|
142
|
-
type: 'Program';
|
|
143
|
-
loc: HermesSourceLocation;
|
|
144
|
-
body: Array<HermesNode | null>;
|
|
145
|
-
comments: Array<HermesComment>;
|
|
146
|
-
tokens?: Array<HermesToken>;
|
|
147
|
-
interpreter?: HermesComment | null;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export function parse(code: string, options?: ParserOptions): HermesProgram;
|
|
151
|
-
}
|
|
@@ -1,62 +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 createFlowStripStep_exports = {};
|
|
30
|
-
__export(createFlowStripStep_exports, {
|
|
31
|
-
createFlowStripStep: () => createFlowStripStep
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(createFlowStripStep_exports);
|
|
34
|
-
var import_generator = require("@babel/generator");
|
|
35
|
-
var import_flow_remove_types = __toESM(require("flow-remove-types"));
|
|
36
|
-
var HermesParser = __toESM(require("hermes-parser"));
|
|
37
|
-
var import_defineStepName = require("../../../../utils/defineStepName");
|
|
38
|
-
function createFlowStripStep() {
|
|
39
|
-
const flowStripStep = async function flowStrip(code, args) {
|
|
40
|
-
const shouldTransform = args.path.endsWith(".js") || args.path.endsWith(".jsx");
|
|
41
|
-
if (!shouldTransform) {
|
|
42
|
-
return { code };
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
const transformedCode = (0, import_flow_remove_types.default)(code, {});
|
|
46
|
-
const parsedAst = HermesParser.parse(transformedCode.toString(), {
|
|
47
|
-
flow: "all",
|
|
48
|
-
babel: true
|
|
49
|
-
});
|
|
50
|
-
const transformedResult = (0, import_generator.generate)(parsedAst);
|
|
51
|
-
return { code: transformedResult?.code ?? code };
|
|
52
|
-
} catch {
|
|
53
|
-
return { code };
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
(0, import_defineStepName.defineStepName)(flowStripStep, "flow-strip");
|
|
57
|
-
return flowStripStep;
|
|
58
|
-
}
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
createFlowStripStep
|
|
62
|
-
});
|
|
@@ -1,70 +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 createTransformCodegenStep_exports = {};
|
|
30
|
-
__export(createTransformCodegenStep_exports, {
|
|
31
|
-
createTransformCodegenStep: () => createTransformCodegenStep
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(createTransformCodegenStep_exports);
|
|
34
|
-
var import_core = require("@babel/core");
|
|
35
|
-
var import_defineStepName = require("../../../../utils/defineStepName");
|
|
36
|
-
function createTransformCodegenStep() {
|
|
37
|
-
const codegenStep = async function codegen(code, args) {
|
|
38
|
-
const transformedResult = await (0, import_core.transformAsync)(code, {
|
|
39
|
-
test: /(?:^|[\\/])(?:Native\w+|(\w+)NativeComponent)\.[jt]sx?$/,
|
|
40
|
-
filename: args.path,
|
|
41
|
-
minified: false,
|
|
42
|
-
compact: false,
|
|
43
|
-
babelrc: false,
|
|
44
|
-
configFile: false,
|
|
45
|
-
plugins: [
|
|
46
|
-
require.resolve("babel-plugin-syntax-hermes-parser"),
|
|
47
|
-
require.resolve("@babel/plugin-transform-flow-strip-types"),
|
|
48
|
-
[require.resolve("@babel/plugin-syntax-typescript"), false],
|
|
49
|
-
require.resolve("@react-native/babel-plugin-codegen")
|
|
50
|
-
],
|
|
51
|
-
overrides: [
|
|
52
|
-
{
|
|
53
|
-
test: /\.ts$/,
|
|
54
|
-
plugins: [[require.resolve("@babel/plugin-syntax-typescript"), { isTSX: false, allowNamespaces: true }]]
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
test: /\.tsx$/,
|
|
58
|
-
plugins: [[require.resolve("@babel/plugin-syntax-typescript"), { isTSX: true, allowNamespaces: true }]]
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
return { code: transformedResult?.code ?? code };
|
|
63
|
-
};
|
|
64
|
-
(0, import_defineStepName.defineStepName)(codegenStep, "transform-codegen");
|
|
65
|
-
return codegenStep;
|
|
66
|
-
}
|
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
-
0 && (module.exports = {
|
|
69
|
-
createTransformCodegenStep
|
|
70
|
-
});
|