Skip to content

Commit 671d783

Browse files
committed
fix: add support non-bundler module resolution (tsconfig)
1 parent bc45dcb commit 671d783

10 files changed

+34
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ If you did not opt into the App Engine Developer Preview:
115115

116116
```ts
117117
import { CommonEngine } from '@angular/ssr/node'
118-
import { render } from '@netlify/angular-runtime/common-engine'
118+
import { render } from '@netlify/angular-runtime/common-engine.mjs'
119119

120120
const commonEngine = new CommonEngine()
121121

@@ -135,7 +135,7 @@ If you opted into the App Engine Developer Preview:
135135

136136
```ts
137137
import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
138-
import { getContext } from '@netlify/angular-runtime/context'
138+
import { getContext } from '@netlify/angular-runtime/context.mjs'
139139

140140
const angularAppEngine = new AngularAppEngine()
141141

common-engine.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This is duplicating module resolution from package.json#exports
2+
// because some module resolution settings in tsconfig.json are not honoring export maps
3+
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
4+
export * from './src/common-engine.mjs'

common-engine.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This is duplicating module resolution from package.json#exports
2+
// because some module resolution settings in tsconfig.json are not honoring export maps
3+
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
4+
export * from './src/common-engine.mjs'

context.d.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This is duplicating module resolution from package.json#exports
2+
// because some module resolution settings in tsconfig.json are not honoring export maps
3+
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
4+
export * from './src/context.mjs'

context.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This is duplicating module resolution from package.json#exports
2+
// because some module resolution settings in tsconfig.json are not honoring export maps
3+
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
4+
export * from './src/context.mjs'

demo/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
2-
import { getContext } from '@netlify/angular-runtime/context'
2+
import { getContext } from '@netlify/angular-runtime/context.mjs'
33

44
const angularAppEngine = new AngularAppEngine()
55

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"src/**/*.mjs",
99
"src/**/*.json",
1010
"src/**/*.d.ts",
11+
"context.mjs",
12+
"context.d.mjs",
13+
"common-engine.mjs",
14+
"common-engine.d.mjs",
1115
"manifest.yml"
1216
],
1317
"exports": {
@@ -18,10 +22,18 @@
1822
"default": "./src/index.js"
1923
},
2024
"./common-engine": {
21-
"types": "./src/common-engine.d.ts",
25+
"types": "./src/common-engine.d.mts",
26+
"default": "./src/common-engine.mjs"
27+
},
28+
"./common-engine.mjs": {
29+
"types": "./src/common-engine.d.mts",
2230
"default": "./src/common-engine.mjs"
2331
},
2432
"./context": {
33+
"types": "./src/context.d.mts",
34+
"default": "./src/context.mjs"
35+
},
36+
"./context.mjs": {
2537
"types": "./src/context.d.ts",
2638
"default": "./src/context.mjs"
2739
}
File renamed without changes.
File renamed without changes.

src/helpers/serverModuleHelpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { getProject } = require('./setUpEdgeFunction')
1111

1212
// eslint-disable-next-line no-inline-comments
1313
const NetlifyServerTsCommonEngine = /* typescript */ `import { CommonEngine } from '@angular/ssr/node'
14-
import { render } from '@netlify/angular-runtime/common-engine'
14+
import { render } from '@netlify/angular-runtime/common-engine.mjs'
1515
1616
const commonEngine = new CommonEngine()
1717
@@ -29,7 +29,7 @@ export async function netlifyCommonEngineHandler(request: Request, context: any)
2929

3030
// eslint-disable-next-line no-inline-comments
3131
const NetlifyServerTsAppEngine = /* typescript */ `import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
32-
import { getContext } from '@netlify/angular-runtime/context'
32+
import { getContext } from '@netlify/angular-runtime/context.mjs'
3333
3434
const angularAppEngine = new AngularAppEngine()
3535

0 commit comments

Comments
 (0)