@ttsc/metro 0.16.3 → 0.16.6
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/LICENSE +21 -21
- package/lib/core/options.d.ts +3 -3
- package/lib/core/options.js +3 -3
- package/lib/core/options.mjs +3 -3
- package/lib/core/upstream.d.ts +1 -1
- package/lib/core/upstream.js +1 -1
- package/lib/core/upstream.mjs +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +7 -6
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +7 -6
- package/lib/index.mjs.map +1 -1
- package/lib/transformer.d.ts +2 -2
- package/lib/transformer.js +4 -4
- package/lib/transformer.mjs +4 -4
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Jeongho Nam
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jeongho Nam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/lib/core/options.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export interface ResolvedTtscMetroOptions {
|
|
|
57
57
|
* Metro forks its transform workers (jest-worker) from the process that loaded
|
|
58
58
|
* `metro.config.js`, so a variable set on `process.env` before Metro boots is
|
|
59
59
|
* inherited by every worker. This is the only channel `withTtsc`'s arguments
|
|
60
|
-
* can reach the transformer through
|
|
60
|
+
* can reach the transformer through: the worker never sees the `withTtsc`
|
|
61
61
|
* call.
|
|
62
62
|
*/
|
|
63
63
|
export declare const ENV_KEY = "TTSC_METRO_OPTIONS";
|
|
@@ -71,7 +71,7 @@ export declare function serializeOptions(options: TtscMetroOptions): string;
|
|
|
71
71
|
*
|
|
72
72
|
* Reads {@link ENV_KEY}; when it is unset or malformed the adapter falls back to
|
|
73
73
|
* defaults, which means "auto-discover `tsconfig.json` and read its configured
|
|
74
|
-
* plugins"
|
|
75
|
-
*
|
|
74
|
+
* plugins", the standard ttsc behaviour, and the right thing for a project that
|
|
75
|
+
* called `withTtsc(config)` with no explicit options.
|
|
76
76
|
*/
|
|
77
77
|
export declare function resolveOptionsFromEnv(): ResolvedTtscMetroOptions;
|
package/lib/core/options.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Metro forks its transform workers (jest-worker) from the process that loaded
|
|
8
8
|
* `metro.config.js`, so a variable set on `process.env` before Metro boots is
|
|
9
9
|
* inherited by every worker. This is the only channel `withTtsc`'s arguments
|
|
10
|
-
* can reach the transformer through
|
|
10
|
+
* can reach the transformer through: the worker never sees the `withTtsc`
|
|
11
11
|
* call.
|
|
12
12
|
*/
|
|
13
13
|
const ENV_KEY = "TTSC_METRO_OPTIONS";
|
|
@@ -23,8 +23,8 @@ function serializeOptions(options) {
|
|
|
23
23
|
*
|
|
24
24
|
* Reads {@link ENV_KEY}; when it is unset or malformed the adapter falls back to
|
|
25
25
|
* defaults, which means "auto-discover `tsconfig.json` and read its configured
|
|
26
|
-
* plugins"
|
|
27
|
-
*
|
|
26
|
+
* plugins", the standard ttsc behaviour, and the right thing for a project that
|
|
27
|
+
* called `withTtsc(config)` with no explicit options.
|
|
28
28
|
*/
|
|
29
29
|
function resolveOptionsFromEnv() {
|
|
30
30
|
const raw = process.env[ENV_KEY];
|
package/lib/core/options.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Metro forks its transform workers (jest-worker) from the process that loaded
|
|
6
6
|
* `metro.config.js`, so a variable set on `process.env` before Metro boots is
|
|
7
7
|
* inherited by every worker. This is the only channel `withTtsc`'s arguments
|
|
8
|
-
* can reach the transformer through
|
|
8
|
+
* can reach the transformer through: the worker never sees the `withTtsc`
|
|
9
9
|
* call.
|
|
10
10
|
*/
|
|
11
11
|
const ENV_KEY = "TTSC_METRO_OPTIONS";
|
|
@@ -21,8 +21,8 @@ function serializeOptions(options) {
|
|
|
21
21
|
*
|
|
22
22
|
* Reads {@link ENV_KEY}; when it is unset or malformed the adapter falls back to
|
|
23
23
|
* defaults, which means "auto-discover `tsconfig.json` and read its configured
|
|
24
|
-
* plugins"
|
|
25
|
-
*
|
|
24
|
+
* plugins", the standard ttsc behaviour, and the right thing for a project that
|
|
25
|
+
* called `withTtsc(config)` with no explicit options.
|
|
26
26
|
*/
|
|
27
27
|
function resolveOptionsFromEnv() {
|
|
28
28
|
const raw = process.env[ENV_KEY];
|
package/lib/core/upstream.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const UPSTREAM_CANDIDATES: readonly ["@expo/metro-config/babel-tr
|
|
|
34
34
|
*
|
|
35
35
|
* These are declared as optional peers and resolved at runtime against the
|
|
36
36
|
* consumer project, so the adapter carries no Metro/Expo dependency itself.
|
|
37
|
-
* Resolution is not memoised
|
|
37
|
+
* Resolution is not memoised: Node's own module cache already makes the
|
|
38
38
|
* repeated `require` a cheap lookup, and keeping no module-level state lets a
|
|
39
39
|
* changed `upstreamTransformer` always take effect.
|
|
40
40
|
*
|
package/lib/core/upstream.js
CHANGED
|
@@ -24,7 +24,7 @@ const UPSTREAM_CANDIDATES = [
|
|
|
24
24
|
*
|
|
25
25
|
* These are declared as optional peers and resolved at runtime against the
|
|
26
26
|
* consumer project, so the adapter carries no Metro/Expo dependency itself.
|
|
27
|
-
* Resolution is not memoised
|
|
27
|
+
* Resolution is not memoised: Node's own module cache already makes the
|
|
28
28
|
* repeated `require` a cheap lookup, and keeping no module-level state lets a
|
|
29
29
|
* changed `upstreamTransformer` always take effect.
|
|
30
30
|
*
|
package/lib/core/upstream.mjs
CHANGED
|
@@ -21,7 +21,7 @@ const UPSTREAM_CANDIDATES = [
|
|
|
21
21
|
*
|
|
22
22
|
* These are declared as optional peers and resolved at runtime against the
|
|
23
23
|
* consumer project, so the adapter carries no Metro/Expo dependency itself.
|
|
24
|
-
* Resolution is not memoised
|
|
24
|
+
* Resolution is not memoised: Node's own module cache already makes the
|
|
25
25
|
* repeated `require` a cheap lookup, and keeping no module-level state lets a
|
|
26
26
|
* changed `upstreamTransformer` always take effect.
|
|
27
27
|
*
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TtscMetroOptions } from "./core/options";
|
|
2
2
|
export type { ResolvedTtscMetroOptions, TtscMetroOptions, } from "./core/options";
|
|
3
3
|
/**
|
|
4
|
-
* Minimal structural type for a Metro config object
|
|
4
|
+
* Minimal structural type for a Metro config object, avoids a hard dependency
|
|
5
5
|
* on Metro's types while letting {@link withTtsc} preserve the caller's exact
|
|
6
6
|
* config type.
|
|
7
7
|
*/
|
|
@@ -18,11 +18,11 @@ interface MetroConfigLike {
|
|
|
18
18
|
* Sets `transformer.babelTransformerPath` to this package's transformer and
|
|
19
19
|
* publishes the resolved options to Metro's worker processes via the
|
|
20
20
|
* {@link ENV_KEY} environment variable (the workers never see this call, so env
|
|
21
|
-
* is the transport
|
|
21
|
+
* is the transport, see `core/options.ts`). Compatible with Expo's
|
|
22
22
|
* `getDefaultConfig()` and bare React Native alike.
|
|
23
23
|
*
|
|
24
24
|
* With no `options`, the transformer auto-discovers `tsconfig.json` and runs
|
|
25
|
-
* the plugins configured there
|
|
26
|
-
*
|
|
25
|
+
* the plugins configured there: the standard ttsc model. Pass `options` only to
|
|
26
|
+
* override the project path, plugin list, or include/exclude filters.
|
|
27
27
|
*/
|
|
28
28
|
export declare function withTtsc<T extends MetroConfigLike>(config: T, options?: TtscMetroOptions): T;
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var options = require('./core/options.js');
|
|
|
6
6
|
|
|
7
7
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
8
|
/**
|
|
9
|
-
* `@ttsc/metro
|
|
9
|
+
* `@ttsc/metro`: Metro (React Native / Expo) adapter for ttsc plugins.
|
|
10
10
|
*
|
|
11
11
|
* Metro bundles with Babel, which strips TypeScript types and never runs ttsc
|
|
12
12
|
* plugins, so neither the `ttsc` CLI nor `@ttsc/unplugin` can reach an RN/Expo
|
|
@@ -15,13 +15,14 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
15
15
|
* project's existing Expo/React-Native Babel transformer.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
|
-
* Expo
|
|
18
|
+
* Expo project
|
|
19
|
+
* ```js
|
|
19
20
|
* // metro.config.js
|
|
20
21
|
* const { getDefaultConfig } = require("expo/metro-config");
|
|
21
22
|
* const { withTtsc } = require("@ttsc/metro");
|
|
22
23
|
*
|
|
23
24
|
* module.exports = withTtsc(getDefaultConfig(__dirname));
|
|
24
|
-
*
|
|
25
|
+
* ```
|
|
25
26
|
*
|
|
26
27
|
* @example
|
|
27
28
|
* Bare React Native
|
|
@@ -39,12 +40,12 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
39
40
|
* Sets `transformer.babelTransformerPath` to this package's transformer and
|
|
40
41
|
* publishes the resolved options to Metro's worker processes via the
|
|
41
42
|
* {@link ENV_KEY} environment variable (the workers never see this call, so env
|
|
42
|
-
* is the transport
|
|
43
|
+
* is the transport, see `core/options.ts`). Compatible with Expo's
|
|
43
44
|
* `getDefaultConfig()` and bare React Native alike.
|
|
44
45
|
*
|
|
45
46
|
* With no `options`, the transformer auto-discovers `tsconfig.json` and runs
|
|
46
|
-
* the plugins configured there
|
|
47
|
-
*
|
|
47
|
+
* the plugins configured there: the standard ttsc model. Pass `options` only to
|
|
48
|
+
* override the project path, plugin list, or include/exclude filters.
|
|
48
49
|
*/
|
|
49
50
|
function withTtsc(config, options$1 = {}) {
|
|
50
51
|
process.env[options.ENV_KEY] = options.serializeOptions(options$1);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":["options","ENV_KEY","serializeOptions","join","dirname","fileURLToPath"],"mappings":";;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":["options","ENV_KEY","serializeOptions","join","dirname","fileURLToPath"],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AAyBH;;;;;;;;;;;;AAYG;SACa,QAAQ,CACtB,MAAS,EACTA,YAA4B,EAAE,EAAA;IAE9B,OAAO,CAAC,GAAG,CAACC,eAAO,CAAC,GAAGC,wBAAgB,CAACF,SAAO,CAAC;IAChD,OAAO;AACL,QAAA,GAAG,MAAM;AACT,QAAA,WAAW,EAAE;YACX,GAAG,MAAM,CAAC,WAAW;YACrB,oBAAoB,EAAE,qBAAqB,EAAE;AAC9C,SAAA;KACG;AACR;AAEA;;;;;;;;AAQG;AACH,SAAS,qBAAqB,GAAA;AAC5B,IAAA,OAAOG,SAAI,CAACC,YAAO,CAACC,sBAAa,CAAC,0PAAe,CAAC,CAAC,EAAE,gBAAgB,CAAC;AACxE;;;;"}
|
package/lib/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
import { ENV_KEY, serializeOptions } from './core/options.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* `@ttsc/metro
|
|
6
|
+
* `@ttsc/metro`: Metro (React Native / Expo) adapter for ttsc plugins.
|
|
7
7
|
*
|
|
8
8
|
* Metro bundles with Babel, which strips TypeScript types and never runs ttsc
|
|
9
9
|
* plugins, so neither the `ttsc` CLI nor `@ttsc/unplugin` can reach an RN/Expo
|
|
@@ -12,13 +12,14 @@ import { ENV_KEY, serializeOptions } from './core/options.mjs';
|
|
|
12
12
|
* project's existing Expo/React-Native Babel transformer.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* Expo
|
|
15
|
+
* Expo project
|
|
16
|
+
* ```js
|
|
16
17
|
* // metro.config.js
|
|
17
18
|
* const { getDefaultConfig } = require("expo/metro-config");
|
|
18
19
|
* const { withTtsc } = require("@ttsc/metro");
|
|
19
20
|
*
|
|
20
21
|
* module.exports = withTtsc(getDefaultConfig(__dirname));
|
|
21
|
-
*
|
|
22
|
+
* ```
|
|
22
23
|
*
|
|
23
24
|
* @example
|
|
24
25
|
* Bare React Native
|
|
@@ -36,12 +37,12 @@ import { ENV_KEY, serializeOptions } from './core/options.mjs';
|
|
|
36
37
|
* Sets `transformer.babelTransformerPath` to this package's transformer and
|
|
37
38
|
* publishes the resolved options to Metro's worker processes via the
|
|
38
39
|
* {@link ENV_KEY} environment variable (the workers never see this call, so env
|
|
39
|
-
* is the transport
|
|
40
|
+
* is the transport, see `core/options.ts`). Compatible with Expo's
|
|
40
41
|
* `getDefaultConfig()` and bare React Native alike.
|
|
41
42
|
*
|
|
42
43
|
* With no `options`, the transformer auto-discovers `tsconfig.json` and runs
|
|
43
|
-
* the plugins configured there
|
|
44
|
-
*
|
|
44
|
+
* the plugins configured there: the standard ttsc model. Pass `options` only to
|
|
45
|
+
* override the project path, plugin list, or include/exclude filters.
|
|
45
46
|
*/
|
|
46
47
|
function withTtsc(config, options = {}) {
|
|
47
48
|
process.env[ENV_KEY] = serializeOptions(options);
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AAyBH;;;;;;;;;;;;AAYG;SACa,QAAQ,CACtB,MAAS,EACT,UAA4B,EAAE,EAAA;IAE9B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAChD,OAAO;AACL,QAAA,GAAG,MAAM;AACT,QAAA,WAAW,EAAE;YACX,GAAG,MAAM,CAAC,WAAW;YACrB,oBAAoB,EAAE,qBAAqB,EAAE;AAC9C,SAAA;KACG;AACR;AAEA;;;;;;;;AAQG;AACH,SAAS,qBAAqB,GAAA;AAC5B,IAAA,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC;AACxE;;;;"}
|
package/lib/transformer.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { ResolvedTtscMetroOptions } from "./core/options";
|
|
|
6
6
|
* reads the file via `fs.readFileSync(path.resolve(projectRoot, filename))`)
|
|
7
7
|
* and passes `projectRoot` inside `options`. The ttsc pass needs an absolute
|
|
8
8
|
* path that matches a key in the compiled program, so resolve against
|
|
9
|
-
* `projectRoot
|
|
9
|
+
* `projectRoot`, never `process.cwd()`, which differs from `projectRoot` in
|
|
10
10
|
* monorepos and when Metro is launched from a parent directory. Getting this
|
|
11
11
|
* wrong makes every file look "outside the project" and silently skips the
|
|
12
12
|
* plugin pass.
|
|
@@ -36,7 +36,7 @@ export declare function transform(params: {
|
|
|
36
36
|
* the transformer itself changes: package version + resolved options + the
|
|
37
37
|
* upstream transformer's own key (forwarded Metro's args, e.g. `projectRoot`,
|
|
38
38
|
* so a `babel.config.js` change still busts the cache). Resolving the upstream
|
|
39
|
-
* is deliberately non-fatal here
|
|
39
|
+
* is deliberately non-fatal here: a missing peer must not crash cache-key
|
|
40
40
|
* computation. NOTE: this does not encode the tsconfig / plugin configuration
|
|
41
41
|
* or cross-file type dependencies, so after editing those (or a depended-upon
|
|
42
42
|
* type) run Metro with `--reset-cache`. See the README "Caveats" and
|
package/lib/transformer.js
CHANGED
|
@@ -51,7 +51,7 @@ function options() {
|
|
|
51
51
|
* reads the file via `fs.readFileSync(path.resolve(projectRoot, filename))`)
|
|
52
52
|
* and passes `projectRoot` inside `options`. The ttsc pass needs an absolute
|
|
53
53
|
* path that matches a key in the compiled program, so resolve against
|
|
54
|
-
* `projectRoot
|
|
54
|
+
* `projectRoot`, never `process.cwd()`, which differs from `projectRoot` in
|
|
55
55
|
* monorepos and when Metro is launched from a parent directory. Getting this
|
|
56
56
|
* wrong makes every file look "outside the project" and silently skips the
|
|
57
57
|
* plugin pass.
|
|
@@ -93,7 +93,7 @@ async function transform(params) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
catch (error) {
|
|
96
|
-
// A file that is not part of the tsconfig program is not a build error
|
|
96
|
+
// A file that is not part of the tsconfig program is not a build error,
|
|
97
97
|
// pass it through untransformed. Genuine compile/type failures propagate so
|
|
98
98
|
// Metro surfaces them, matching the other ttsc bundler integrations.
|
|
99
99
|
if (!isFileOutsideProject(error)) {
|
|
@@ -109,7 +109,7 @@ async function transform(params) {
|
|
|
109
109
|
* the transformer itself changes: package version + resolved options + the
|
|
110
110
|
* upstream transformer's own key (forwarded Metro's args, e.g. `projectRoot`,
|
|
111
111
|
* so a `babel.config.js` change still busts the cache). Resolving the upstream
|
|
112
|
-
* is deliberately non-fatal here
|
|
112
|
+
* is deliberately non-fatal here: a missing peer must not crash cache-key
|
|
113
113
|
* computation. NOTE: this does not encode the tsconfig / plugin configuration
|
|
114
114
|
* or cross-file type dependencies, so after editing those (or a depended-upon
|
|
115
115
|
* type) run Metro with `--reset-cache`. See the README "Caveats" and
|
|
@@ -178,7 +178,7 @@ function shouldTransform(filename, opts) {
|
|
|
178
178
|
/**
|
|
179
179
|
* `transformTtsc` throws `"ttsc transform did not return output for <file>"`
|
|
180
180
|
* when the requested file is not part of the compiled program (e.g. excluded
|
|
181
|
-
* from the tsconfig). That case is non-fatal
|
|
181
|
+
* from the tsconfig). That case is non-fatal: the file should pass through.
|
|
182
182
|
*/
|
|
183
183
|
function isFileOutsideProject(error) {
|
|
184
184
|
const message = error instanceof Error ? error.message : String(error);
|
package/lib/transformer.mjs
CHANGED
|
@@ -48,7 +48,7 @@ function options() {
|
|
|
48
48
|
* reads the file via `fs.readFileSync(path.resolve(projectRoot, filename))`)
|
|
49
49
|
* and passes `projectRoot` inside `options`. The ttsc pass needs an absolute
|
|
50
50
|
* path that matches a key in the compiled program, so resolve against
|
|
51
|
-
* `projectRoot
|
|
51
|
+
* `projectRoot`, never `process.cwd()`, which differs from `projectRoot` in
|
|
52
52
|
* monorepos and when Metro is launched from a parent directory. Getting this
|
|
53
53
|
* wrong makes every file look "outside the project" and silently skips the
|
|
54
54
|
* plugin pass.
|
|
@@ -90,7 +90,7 @@ async function transform(params) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
catch (error) {
|
|
93
|
-
// A file that is not part of the tsconfig program is not a build error
|
|
93
|
+
// A file that is not part of the tsconfig program is not a build error,
|
|
94
94
|
// pass it through untransformed. Genuine compile/type failures propagate so
|
|
95
95
|
// Metro surfaces them, matching the other ttsc bundler integrations.
|
|
96
96
|
if (!isFileOutsideProject(error)) {
|
|
@@ -106,7 +106,7 @@ async function transform(params) {
|
|
|
106
106
|
* the transformer itself changes: package version + resolved options + the
|
|
107
107
|
* upstream transformer's own key (forwarded Metro's args, e.g. `projectRoot`,
|
|
108
108
|
* so a `babel.config.js` change still busts the cache). Resolving the upstream
|
|
109
|
-
* is deliberately non-fatal here
|
|
109
|
+
* is deliberately non-fatal here: a missing peer must not crash cache-key
|
|
110
110
|
* computation. NOTE: this does not encode the tsconfig / plugin configuration
|
|
111
111
|
* or cross-file type dependencies, so after editing those (or a depended-upon
|
|
112
112
|
* type) run Metro with `--reset-cache`. See the README "Caveats" and
|
|
@@ -175,7 +175,7 @@ function shouldTransform(filename, opts) {
|
|
|
175
175
|
/**
|
|
176
176
|
* `transformTtsc` throws `"ttsc transform did not return output for <file>"`
|
|
177
177
|
* when the requested file is not part of the compiled program (e.g. excluded
|
|
178
|
-
* from the tsconfig). That case is non-fatal
|
|
178
|
+
* from the tsconfig). That case is non-fatal: the file should pass through.
|
|
179
179
|
*/
|
|
180
180
|
function isFileOutsideProject(error) {
|
|
181
181
|
const message = error instanceof Error ? error.message : String(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/metro",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.6",
|
|
4
4
|
"description": "Metro (React Native / Expo) adapter for ttsc plugins.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"src"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ttsc/unplugin": "0.16.
|
|
38
|
+
"@ttsc/unplugin": "0.16.6"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@expo/metro-config": "*",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"tinyglobby": "^0.2.16",
|
|
65
65
|
"tslib": "^2.8.1",
|
|
66
66
|
"typescript": "7.0.1-rc",
|
|
67
|
-
"ttsc": "0.16.
|
|
67
|
+
"ttsc": "0.16.6"
|
|
68
68
|
},
|
|
69
69
|
"repository": {
|
|
70
70
|
"type": "git",
|