Skip to content

Commit 2b1ac37

Browse files
authored
Merge pull request #1325 from input-output-hk/chore/tsc-alias
LW-10722 chore: add tsc-alias to make dist/esm files imports complient with latest node.js versions
2 parents d6b3c7b + 741d794 commit 2b1ac37

File tree

101 files changed

+276
-188
lines changed

Some content is hidden

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

101 files changed

+276
-188
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
'error',
5555
{
5656
paths: ['lodash'],
57-
patterns: ['@cardano-sdk/*/src/*']
57+
patterns: ['@cardano-sdk/*/src/*', 'lodash/*', '!lodash/*.js']
5858
}
5959
],
6060
'no-shadow': 'off',

.github/workflows/continuous-integration-e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
- name: 🔨 Build
5252
run: |
5353
yarn install --immutable --inline-builds --mode=skip-build
54-
yarn build
54+
yarn build:cjs
5555
docker build --no-cache .
5656
env:
5757
NODE_OPTIONS: '--max_old_space_size=8192'

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RUN yarn --immutable --inline-builds --mode=skip-build
5555
COPY packages packages
5656
RUN \
5757
echo "export const unused = 'unused';" > packages/e2e/src/index.ts &&\
58-
NODE_OPTIONS=--max_old_space_size=10240 yarn build
58+
NODE_OPTIONS=--max_old_space_size=10240 yarn build:cjs
5959

6060
FROM nodejs-builder as cardano-services-production-deps
6161
RUN yarn workspaces focus --all --production

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
],
1212
"scripts": {
1313
"build": "yarn workspaces foreach -v run build",
14+
"build:cjs": "yarn workspaces foreach -v run build:cjs",
1415
"circular-deps:check": "yarn workspaces foreach -v run circular-deps:check",
1516
"cleanup-build": "yarn workspaces foreach -v run cleanup && yarn install && yarn workspaces foreach -v run build",
1617
"reinstall": "yarn workspaces foreach -v run cleanup:nm && yarn install",
@@ -84,6 +85,7 @@
8485
"ts-jest": "^28.0.7",
8586
"ts-node": "^10.0.0",
8687
"ts-node-dev": "^1.1.8",
88+
"tsc-alias": "^1.8.10",
8789
"typedoc": "^0.23.24",
8890
"typedoc-plugin-missing-exports": "^1.0.0",
8991
"typescript": "^4.7.4"

packages/cardano-services-client/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
},
2121
"license": "Apache-2.0",
2222
"scripts": {
23-
"build:esm": "tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020",
24-
"build:cjs": "tsc --build src",
25-
"build:version": "bash -c 'if node ./scripts/createVersionSource.js --check ; then node ./scripts/createVersionSource.js --create && yarn lint:fix ; fi && cp ./package.json ./dist/package.json'",
26-
"build": "yarn build:version && run-s build:cjs build:esm module-fixup",
27-
"module-fixup": "cp ../../build/cjs-package.json ./dist/cjs/package.json && cp ../../build/esm-package.json ./dist/esm/package.json",
23+
"build": "yarn build:cjs && tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020 && tsc-alias -p src/tsconfig.json --outDir ./dist/esm && cp ../../build/esm-package.json ./dist/esm/package.json",
24+
"build:cjs": "yarn build:version && tsc --build src && cp ./package.json dist/ && cp ../../build/cjs-package.json ./dist/cjs/package.json",
25+
"build:version": "bash -c 'if node ./scripts/createVersionSource.js --check ; then node ./scripts/createVersionSource.js --create && yarn lint:fix ; fi'",
2826
"tscNoEmit": "echo typescript --noEmit command not implemented yet",
2927
"cleanup:dist": "rm -rf dist",
3028
"circular-deps:check": "madge --circular dist/cjs",
@@ -50,6 +48,7 @@
5048
"madge": "^5.0.1",
5149
"npm-run-all": "^4.1.5",
5250
"ts-jest": "^28.0.7",
51+
"tsc-alias": "^1.8.10",
5352
"typescript": "^4.7.4"
5453
},
5554
"dependencies": {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
declare module '*.json';
2+
3+
// exclude from build, as it has to be imported at runtime
4+
declare module '../package.json';

packages/cardano-services/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
"sideEffects": false,
2222
"license": "Apache-2.0",
2323
"scripts": {
24-
"build:cjs": "tsc --build src && chmod +x ./dist/cjs/cli.js",
25-
"build:copy-assets": "bash ./copy-assets.sh",
26-
"build": "run-s build:cjs build:copy-assets",
24+
"build": "yarn build:cjs",
25+
"build:cjs": "tsc --build src && chmod +x ./dist/cjs/cli.js && bash ./copy-assets.sh",
2726
"build:test-db": "./test/jest-setup/rebuild-test-db.sh",
2827
"cleanup:dist": "rm -rf dist",
2928
"cleanup:nm": "rm -rf node_modules",

packages/cardano-services/src/Asset/CardanoTokenRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Logger } from 'ts-log';
44
import { TokenMetadataService } from './types';
55
import { contextLogger } from '@cardano-sdk/util';
66
import axios, { AxiosInstance } from 'axios';
7-
import pick from 'lodash/pick';
7+
import pick from 'lodash/pick.js';
88

99
export const DEFAULT_TOKEN_METADATA_CACHE_TTL = Seconds(10 * 60);
1010
export const DEFAULT_TOKEN_METADATA_REQUEST_TIMEOUT = Milliseconds(3 * 1000);

packages/cardano-services/src/ChainHistory/DbSyncChainHistory/ChainHistoryBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import {
3939
mapTxTokenMap,
4040
mapWithdrawal
4141
} from './mappers';
42-
import omit from 'lodash/omit';
43-
import orderBy from 'lodash/orderBy';
42+
import omit from 'lodash/omit.js';
43+
import orderBy from 'lodash/orderBy.js';
4444

4545
export class ChainHistoryBuilder {
4646
#db: Pool;

packages/cardano-services/src/ChainHistory/DbSyncChainHistory/DbSyncChainHistoryProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { QueryResult } from 'pg';
1818
import { TxMetadataService } from '../../Metadata';
1919
import { hexStringToBuffer } from '@cardano-sdk/util';
2020
import { mapBlock, mapTxAlonzo, mapTxIn, mapTxOut } from './mappers';
21-
import orderBy from 'lodash/orderBy';
21+
import orderBy from 'lodash/orderBy.js';
2222

2323
/** Properties that are need to create DbSyncChainHistoryProvider */
2424
export interface ChainHistoryProviderProps {

0 commit comments

Comments
 (0)