Skip to content

Commit 9d21e40

Browse files
committed
apply moduleResolution to shim imports
1 parent 6533c9a commit 9d21e40

File tree

12 files changed

+38
-1
lines changed

12 files changed

+38
-1
lines changed

jscomp/gentype/ModuleResolver.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,14 @@ let importPathForReasonModuleName ~(config : Config.t) ~outputFileRelative
272272
| shimModuleName ->
273273
if !Debug.moduleResolution then
274274
Log_.item "ShimModuleName: %s\n" (shimModuleName |> ModuleName.toString);
275+
let importExtension =
276+
match config.moduleResolution with
277+
| Node -> ".shim"
278+
| Node16 -> ".shim.js"
279+
| Bundler -> ".shim.ts"
280+
in
275281
let importPath =
276-
resolveModule ~config ~importExtension:".shim" ~outputFileRelative
282+
resolveModule ~config ~importExtension ~outputFileRelative
277283
~resolver ~useBsDependencies:false shimModuleName
278284
in
279285
if !Debug.moduleResolution then

jscomp/gentype_tests/typescript-react-example/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/gentype_tests/typescript-res-bundler/bsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"module": "es6",
55
"moduleResolution": "bundler",
66
"importPath": "relative",
7+
"shims": {
8+
"Js": "Js"
9+
},
710
"debug": {
811
"all": false
912
},

jscomp/gentype_tests/typescript-res-bundler/src/Bar.bs.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/gentype_tests/typescript-res-bundler/src/Bar.gen.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import * as BarBS__Es6Import from './Bar.bs';
77
const BarBS: any = BarBS__Es6Import;
88

9+
import type {Json_t as Js_Json_t} from '../src/shims/Js.shim.ts';
10+
911
import type {t as Foo_t} from './Foo.gen.tsx';
1012

1113
export const makeFoo: (_1:{ readonly bar: number }) => Foo_t = BarBS.makeFoo;
14+
15+
export const jsonStringify: (_1:Js_Json_t) => string = BarBS.jsonStringify;

jscomp/gentype_tests/typescript-res-bundler/src/Bar.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ let makeFoo = (~bar) => {
33
open Foo
44
{...make(), bar}
55
}
6+
7+
@genType let jsonStringify = Js.Json.stringify
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type Json_t = unknown;

jscomp/gentype_tests/typescript-res-node16/bsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"module": "es6",
55
"moduleResolution": "node16",
66
"importPath": "relative",
7+
"shims": {
8+
"Js": "Js"
9+
},
710
"debug": {
811
"all": false
912
},

jscomp/gentype_tests/typescript-res-node16/src/Bar.bs.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/gentype_tests/typescript-res-node16/src/Bar.gen.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import * as BarBS__Es6Import from './Bar.bs';
77
const BarBS: any = BarBS__Es6Import;
88

9+
import type {Json_t as Js_Json_t} from '../src/shims/Js.shim.js';
10+
911
import type {t as Foo_t} from './Foo.gen.js';
1012

1113
export const makeFoo: (_1:{ readonly bar: number }) => Foo_t = BarBS.makeFoo;
14+
15+
export const jsonStringify: (_1:Js_Json_t) => string = BarBS.jsonStringify;

jscomp/gentype_tests/typescript-res-node16/src/Bar.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ let makeFoo = (~bar) => {
33
open Foo
44
{...make(), bar}
55
}
6+
7+
@genType let jsonStringify = Js.Json.stringify
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type Json_t = unknown;

0 commit comments

Comments
 (0)