Skip to content

fix: add support for non-bundler module resolution (tsconfig) #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ If you did not opt into the App Engine Developer Preview:

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

const commonEngine = new CommonEngine()

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

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

const angularAppEngine = new AngularAppEngine()

4 changes: 4 additions & 0 deletions common-engine.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This is duplicating module resolution from package.json#exports
// because some module resolution settings in tsconfig.json are not honoring export maps
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
export * from './src/common-engine.mjs'
4 changes: 4 additions & 0 deletions common-engine.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This is duplicating module resolution from package.json#exports
// because some module resolution settings in tsconfig.json are not honoring export maps
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
export * from './src/common-engine.mjs'
4 changes: 4 additions & 0 deletions context.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This is duplicating module resolution from package.json#exports
// because some module resolution settings in tsconfig.json are not honoring export maps
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
export * from './src/context.mjs'
4 changes: 4 additions & 0 deletions context.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This is duplicating module resolution from package.json#exports
// because some module resolution settings in tsconfig.json are not honoring export maps
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution
export * from './src/context.mjs'
2 changes: 1 addition & 1 deletion demo/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
import { getContext } from '@netlify/angular-runtime/context'
import { getContext } from '@netlify/angular-runtime/context.mjs'

const angularAppEngine = new AngularAppEngine()

19 changes: 16 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,11 @@
"src/**/*.js",
"src/**/*.mjs",
"src/**/*.json",
"src/**/*.d.ts",
"src/**/*.d.mts",
"context.mjs",
"context.d.mts",
"common-engine.mjs",
"common-engine.d.mts",
"manifest.yml"
],
"exports": {
@@ -18,11 +22,19 @@
"default": "./src/index.js"
},
"./common-engine": {
"types": "./src/common-engine.d.ts",
"types": "./src/common-engine.d.mts",
"default": "./src/common-engine.mjs"
},
"./common-engine.mjs": {
"types": "./src/common-engine.d.mts",
"default": "./src/common-engine.mjs"
},
"./context": {
"types": "./src/context.d.ts",
"types": "./src/context.d.mts",
"default": "./src/context.mjs"
},
"./context.mjs": {
"types": "./src/context.d.mts",
"default": "./src/context.mjs"
}
},
@@ -46,6 +58,7 @@
"pretest:fixtures:angular-17": "cd tests/fixtures/angular-17 && npm ci",
"pretest:fixtures:angular-19-common-engine": "cd tests/fixtures/angular-19-common-engine && npm ci",
"pretest:fixtures:angular-19-app-engine": "cd tests/fixtures/angular-19-app-engine && npm ci",
"pretest:fixtures:angular-19-app-engine-node-module-resolution": "cd tests/fixtures/angular-19-app-engine-node-module-resolution && npm ci",
"pretest:fixtures:angular-19-prerender-false": "cd tests/fixtures/angular-19-prerender-false && npm ci",
"pretest:fixtures:nx-angular-19-common-engine": "cd tests/fixtures/nx-angular-19-common-engine && npm ci",
"pretest:fixtures:nx-angular-19-app-engine": "cd tests/fixtures/nx-angular-19-app-engine && npm ci",
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion src/helpers/knownServerTsSignatures.json
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
"577f7bc87c16bd10bac499e228ef24d23dc4dd516e469b5db3eefae4edcf6345": "CommonEngine",
"5678601ed12556305074503967b44ae42c45c268579db057c25cbf4b21a7212e": "CommonEngine",
"33d360cdf4819d90afeecd49952241191ee490900fa919a46f990186be3e8b5f": "CommonEngine",
"140c0a0b4a8b648378d53630bee6bef9c3418daf27b372f50c06ab83c9d84a39": "CommonEngine",
"76419eb94b4b8672ba3bd79d34c5a66c7c30ff173995ecc6e0adc5808b86822d": "AppEngine",
"a5aad843a116e34ce61264117cba981cff5eea3e6672815a4db08e7b4e5599d6": "AppEngine"
"a5aad843a116e34ce61264117cba981cff5eea3e6672815a4db08e7b4e5599d6": "AppEngine",
"5e0de282eb33582f8ec4c3da2946762d4c95794cb749cfb589407f4d4a0115a7": "AppEngine"
}
4 changes: 2 additions & 2 deletions src/helpers/serverModuleHelpers.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ const { getProject } = require('./setUpEdgeFunction')

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

// eslint-disable-next-line no-inline-comments
const NetlifyServerTsAppEngine = /* typescript */ `import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
import { getContext } from '@netlify/angular-runtime/context'
import { getContext } from '@netlify/angular-runtime/context.mjs'
const angularAppEngine = new AngularAppEngine()
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false

[*.md]
max_line_length = off
trim_trailing_whitespace = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Angular19AppEngine

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.0-rc.0.

## Development server

To start a local development server, run:

```bash
ng serve
```

Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.

## Code scaffolding

Angular CLI includes powerful code scaffolding tools. To generate a new component, run:

```bash
ng generate component component-name
```

For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:

```bash
ng generate --help
```

## Building

To build the project run:

```bash
ng build
```

This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.

## Running unit tests

To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:

```bash
ng test
```

## Running end-to-end tests

For end-to-end (e2e) testing, run:

```bash
ng e2e
```

Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.

## Additional Resources

For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
Loading