Skip to content

Commit 3e0e5f4

Browse files
committed
refactor: enforce new TS NodeJS ESM resolution and add explicit extensions
Enables the new Node 16 module resolution, inserts the `package.json` files with `type: module` where needed. Also performs all changes needed to satisfy the new module resolution. The new resolution ensures our code is fully ESM compatible. Bundlers are fine without extensions currently, but this may change and using the explicit extension is guaranteeing proper ESM and allows us to benefit from TS intellisense.
1 parent 9a7fc3d commit 3e0e5f4

File tree

252 files changed

+1793
-1235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+1793
-1235
lines changed

.circleci/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ jobs:
179179
name: Check code by running linters
180180
command: yarn lint
181181

182+
# TODO(ESM): This can be removed when Bazel also uses the new `Node16/next` resolution.
183+
- run:
184+
name: Ensure TypeScript code passes type checking
185+
command: yarn tsc -p tsconfig.json
186+
182187
publish_snapshot_build:
183188
executor: docker-linux-executor
184189
steps:

apps/account-functions/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export {beforeCreate} from './before-create';
2-
export {beforeSignIn} from './before-sign-in';
1+
export {beforeCreate} from './before-create.js';
2+
export {beforeSignIn} from './before-sign-in.js';

apps/functions/githubWebhook/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as functions from 'firebase-functions';
22
import * as admin from 'firebase-admin';
3-
import {handlePullRequestEvent} from './pull-request';
4-
import {handleStatusEvent} from './status';
3+
import {handlePullRequestEvent} from './pull-request.js';
4+
import {handleStatusEvent} from './status.js';
55
import {LabelEvent, StatusEvent} from '@octokit/webhooks-types';
6-
import {handleLabelEvent} from './label';
6+
import {handleLabelEvent} from './label.js';
77

88
admin.initializeApp({...functions.firebaseConfig()});
99

apps/functions/githubWebhook/label.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import {LabelEvent} from '@octokit/webhooks-types';
22
import {firestore} from 'firebase-admin';
33
// TODO(josephperrott): Remove usage of FirestoreReference and fromFirestoreReference.
4-
import {Label, FirestoreReference, fromFirestoreReference} from '../../shared/models/server-models';
4+
import {
5+
Label,
6+
FirestoreReference,
7+
fromFirestoreReference,
8+
} from '../../shared/models/server-models.js';
59

610
export async function handleLabelEvent(event: LabelEvent) {
711
const {getFirestoreRefForGithubModel, fromGithub} = Label.getGithubHelpers();

apps/functions/githubWebhook/pull-request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
PullRequest,
66
FirestoreReference,
77
fromFirestoreReference,
8-
} from '../../shared/models/server-models';
8+
} from '../../shared/models/server-models.js';
99

1010
export async function handlePullRequestEvent({pull_request}: PullRequestEvent) {
1111
const {getFirestoreRefForGithubModel, fromGithub} = PullRequest.getGithubHelpers();

apps/functions/githubWebhook/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Status,
66
FirestoreReference,
77
fromFirestoreReference,
8-
} from '../../shared/models/server-models';
8+
} from '../../shared/models/server-models.js';
99

1010
export async function handleStatusEvent(event: StatusEvent) {
1111
const {getFirestoreRefForGithubModel, fromGithub} = Status.getGithubHelpers();

apps/functions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {githubWebhook} from './githubWebhook/index';
1+
export {githubWebhook} from './githubWebhook/index.js';

apps/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "test",
3+
"type": "module"
4+
}

apps/prs/src/app/app-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
22
import {RouterModule, Routes} from '@angular/router';
33

44
const routes: Routes = [
5-
{path: 'login', loadChildren: () => import('./login/login.module').then((m) => m.LoginModule)},
5+
{path: 'login', loadChildren: () => import('./login/login.module.js').then((m) => m.LoginModule)},
66
];
77

88
@NgModule({

apps/prs/src/app/app.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {TestBed} from '@angular/core/testing';
22
import {RouterTestingModule} from '@angular/router/testing';
3-
import {AppComponent} from './app.component';
3+
import {AppComponent} from './app.component.js';
44
import {MatToolbarModule} from '@angular/material/toolbar';
55
import {MatSidenavModule} from '@angular/material/sidenav';
66
import {NoopAnimationsModule} from '@angular/platform-browser/animations';

0 commit comments

Comments
 (0)