Skip to content

Commit

Permalink
feat(esm): moving all packages to esm (#1004)
Browse files Browse the repository at this point in the history
* feat(esm): moving apollo utils to esm

* feat(esm): moving apollo utils to esm

* fix(packages): reordering package json

* feat(esm): updating terraform modules to esm

* fix(cs): adding in commonjs support

* feat(esm): moving event bridge to esm

* feat(esm): moving feature flags to esm

* feat(esm): moving image utils to esm

* feat(esm): moving int-mask to esm

* feat(esm): moving jwt-utils to esm

* feat(esm): moving lambda-secrets  to esm

* feat(esm): moving sentry to esm

* feat(esm): moving tracing to esm

* feat(esm): moving ts-logger to esm

* feat(esm): moving backend-benchmarking to esm
  • Loading branch information
bassrock authored Jan 6, 2025
1 parent aa1a5e0 commit 11c8b60
Show file tree
Hide file tree
Showing 189 changed files with 3,695 additions and 2,960 deletions.
2 changes: 1 addition & 1 deletion infrastructure/otel-collector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "otel-collector-cdk",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "dist/main.js",
"types": "src/main.ts",
"type":"module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/parser-graphql-wrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "src/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/pocket-event-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/push-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "push-server-cdk",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "dist/main.js",
"types": "src/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
1 change: 1 addition & 0 deletions infrastructure/push-server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class PushServer extends TerraformStack {
];

return new PocketECSApplication(this, 'application', {
shortName: 'push',
tags: config.tags,
prefix: config.prefix,
containerConfigs: [
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/sendgrid-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "src/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/shareable-lists-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/shared-snowplow-consumer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/shares-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/transactional-emails/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/user-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "user-api-cdk",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "dist/src/main.js",
"types": "src/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/v3-proxy-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc",
"compile": "tsc --pretty",
Expand Down
2 changes: 1 addition & 1 deletion lambdas/user-list-search-corpus-indexing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test-integrations": "jest \"\\.integration\\.ts\" --runInBand"
},
"dependencies": {
"@opensearch-project/opensearch": "^2.10.0",
"@opensearch-project/opensearch": "2.10.0",
"@pocket-tools/event-bridge": "workspace:*",
"@pocket-tools/ts-logger": "workspace:*",
"@sentry/aws-serverless": "8.47.0",
Expand Down
8 changes: 0 additions & 8 deletions packages/apollo-utils/jest.config.js

This file was deleted.

25 changes: 25 additions & 0 deletions packages/apollo-utils/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/?(*.)+(jest|spec).[jt]s?(x)'],
testPathIgnorePatterns: ['/dist/'],
setupFiles: ['./jest.setup.ts'],
setupFilesAfterEnv: ['jest-extended/all'],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
transform: {
['^.+.tsx?$']: [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.json',
isolatedModules: true,
useESM: true,
},
],
}
};

export default config;
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/apollo-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
},
"license": "Apache-2.0",
"author": "",
"type": "module",
"exports": {
"import": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"require": "./dist/index.cjs"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-utils/src/cache/DataloaderKeyValueCache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorsAreMissesCache } from '@apollo/utils.keyvaluecache';
import { DataLoaderCacheInterface } from './interface';
import { DataLoaderCacheInterface } from './interface.ts';
import md5 from 'md5';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-utils/src/context/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './pocketContextManager';
export * from './pocketContextManager.ts';
4 changes: 2 additions & 2 deletions packages/apollo-utils/src/dataloader.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
DataLoaderCacheInterface,
KeyValueCacheSetOptions,
} from './cache/interface';
import * as dataloader from './dataloader';
} from './cache/interface.ts';
import * as dataloader from './dataloader.ts';

class FakeCache implements DataLoaderCacheInterface {
get(key: string): Promise<string | undefined> {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-utils/src/dataloader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataLoaderCacheInterface } from './cache/interface';
import { DataLoaderCacheInterface } from './cache/interface.ts';

export type BatchFnProps<T, U> = {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-utils/src/errorHandler/errorHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { gql } from 'graphql-tag';
import { buildSubgraphSchema } from '@apollo/subgraph';
import { ApolloServerErrorCode } from '@apollo/server/errors';
import assert from 'assert';
import { sentryPlugin, defaultLogger } from '../sentry/apolloSentryPlugin';
import { errorHandler, NotFoundError } from './errorHandler';
import { sentryPlugin, defaultLogger } from '../sentry/apolloSentryPlugin.ts';
import { errorHandler, NotFoundError } from './errorHandler.ts';
import * as Sentry from '@sentry/node';
import { ApolloServerPluginUsageReportingDisabled } from '@apollo/server/plugin/disabled';
import { GraphQLError } from 'graphql';
Expand Down
22 changes: 11 additions & 11 deletions packages/apollo-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// this is the entry point for the npm package
// anything we want consumable (module, type, class, etc) should be exported here
export * from './cache/DataloaderKeyValueCache';
export * from './cache/interface';
export * from './dataloader';
export * from './errorHandler/errorHandler';
export * from './scalars';
export * from './pagination/';
export * from './plugins/defaultPlugin';
export * from './sentry/expressSentryMiddleware';
export * from './utils';
export * from './context';
export * from './cache/DataloaderKeyValueCache.ts';
export * from './cache/interface.ts';
export * from './dataloader.ts';
export * from './errorHandler/errorHandler.ts';
export * from './scalars/index.ts';
export * from './pagination/index.ts';
export * from './plugins/defaultPlugin.ts';
export * from './sentry/expressSentryMiddleware.ts';
export * from './utils.ts';
export * from './context/index.ts';

// export a generic object with all Pocket Custom Scalars
import { GraphQLValidUrl, isoStringScalar } from './scalars';
import { GraphQLValidUrl, isoStringScalar } from './scalars/index.ts';

export const PocketDefaultScalars = {
ISOString: isoStringScalar,
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-utils/src/pagination/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { PaginationInput, ValidatedPagination } from './types';
export { validatePagination } from './validatePagination';
export { PaginationInput, ValidatedPagination } from './types.ts';
export { validatePagination } from './validatePagination.ts';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validatePagination } from './validatePagination';
import { validatePagination } from './validatePagination.ts';

describe('pagination validation', () => {
const defaultPageSize = 30;
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-utils/src/pagination/validatePagination.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UserInputError } from '../errorHandler/errorHandler';
import { PaginationInput, ValidatedPagination } from './types';
import { UserInputError } from '../errorHandler/errorHandler.ts';
import { PaginationInput, ValidatedPagination } from './types.ts';

export function validatePagination(
pagination: PaginationInput | null | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-utils/src/plugins/defaultPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApolloServerPluginUsageReportingDisabled } from '@apollo/server/plugin/
import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace';
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
import { sentryPlugin } from '../sentry/apolloSentryPlugin';
import { sentryPlugin } from '../sentry/apolloSentryPlugin.ts';
import { Server } from 'http';
import { ApolloServerPlugin, BaseContext } from '@apollo/server';

Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-utils/src/scalars/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { GraphQLValidUrl } from './ValidUrlScalar';
export { isoStringScalar } from './isoStringScalar';
export { GraphQLValidUrl } from './ValidUrlScalar.ts';
export { isoStringScalar } from './isoStringScalar.ts';
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ApolloServer } from '@apollo/server';
import { ApolloServerPluginUsageReportingDisabled } from '@apollo/server/plugin/disabled';
import { buildSubgraphSchema } from '@apollo/subgraph';
import { gql } from 'graphql-tag';
import { errorHandler } from '../errorHandler/errorHandler';
import { isoStringScalar } from './isoStringScalar';
import { errorHandler } from '../errorHandler/errorHandler.ts';
import { isoStringScalar } from './isoStringScalar.ts';

const isoUTCDateStr = '2023-02-11T18:39:48.000Z';
const isoUTCDateObj = new Date(isoUTCDateStr);
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-utils/src/scalars/isoStringScalar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DateTime } from 'luxon';
import { Kind } from 'graphql';
import { isoStringScalar } from './isoStringScalar';
import { isoStringScalar } from './isoStringScalar.ts';

const isoESTDateStr = '2023-02-11T13:39:48.000-05:00';
const isoESTDateObj = new Date(isoESTDateStr);
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-utils/src/scalars/isoStringScalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DateTime, Settings } from 'luxon';
import {
InternalServerError,
UserInputError,
} from '../errorHandler/errorHandler';
} from '../errorHandler/errorHandler.ts';

export const isoStringScalar = new GraphQLScalarType({
name: 'ISOString',
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-utils/src/sentry/apolloSentryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
GraphQLRequestListener,
} from '@apollo/server';
import { ApolloServerErrorCode } from '@apollo/server/errors';
import { InternalErrorCode } from '../errorHandler/errorHandler';
import { InternalErrorCode } from '../errorHandler/errorHandler.ts';
import { setLogger, Logger } from '@pocket-tools/ts-logger';

export const defaultLogger: Logger = setLogger();
Expand Down
6 changes: 0 additions & 6 deletions packages/backend-benchmarking/jest.config.js

This file was deleted.

23 changes: 23 additions & 0 deletions packages/backend-benchmarking/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest/presets/default-esm', // or other ESM presets
testEnvironment: 'node',
testMatch: ['**/?(*.)+(jest|spec).[jt]s?(x)'],
testPathIgnorePatterns: ['/dist/'],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
transform: {
['^.+.tsx?$']: [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.json',
isolatedModules: true,
useESM: true,
},
],
}
};

export default config;
12 changes: 12 additions & 0 deletions packages/backend-benchmarking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
},
"license": "ISC",
"author": "",
"type": "module",
"exports": {
"import": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"require": "./dist/index.cjs"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -32,6 +43,7 @@
"@pocket-tools/eslint-config": "workspace:*",
"@types/jest": "29.5.14",
"@types/node": "^22.8.2",
"@types/chance": "1.1.6",
"jest": "29.7.0",
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-benchmarking/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// this is the entry point for the npm package
// anything we want consumable (module, type, class, etc) should be exported here

export * from './timeIt';
export * as seeds from './seeds';
export * from './timeIt.ts';
export * as seeds from './seeds/index.ts';
2 changes: 1 addition & 1 deletion packages/backend-benchmarking/src/seeds/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './list';
export * from './list.ts';
Loading

0 comments on commit 11c8b60

Please sign in to comment.