Skip to content

Commit

Permalink
Fix Mesh ESM (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan authored Nov 28, 2022
1 parent 748ddee commit e5a62eb
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .changeset/calm-pigs-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@accounter-toolkit/green-invoice-graphql': minor
'@accounter-toolkit/hashavshevet-mesh': patch
'@accounter-toolkit/payper-mesh': patch
---

ESM compatability fix
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ module.exports = {
'**/generated-types/',
'.changeset/*.md',
'*/**/.mesh/',
'*/**/mesh-artifacts/',
],
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist/
**/__generated__/
**/generated-types/
**/.mesh
**/mesh-artifacts
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ node_modules/
dist/
.husky/_/
**/.mesh
**/mesh-artifacts
.bob/
CHANGELOG.md
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"ci:lint": "eslint --output-file eslint_report.json --format json",
"lint": "eslint --ignore-path .gitignore .",
"postbuild": "yarn workspaces run postbuild",
"postinstall": "patch-package",
"pre-commit": "lint-staged",
"prebuild": "rimraf dist/ .bob/ && yarn lint && yarn prettier && yarn workspaces run prebuild",
"prettier": "prettier --ignore-path .gitignore --write --list-different .",
Expand All @@ -34,6 +35,7 @@
"eslint-plugin-simple-import-sort": "8.0.0",
"husky": "8.0.2",
"lint-staged": "13.0.4",
"patch-package": "^6.5.0",
"prettier": "2.8.0",
"prettier-plugin-sql": "0.12.1",
"typescript": "4.9.3"
Expand Down
3 changes: 0 additions & 3 deletions packages/green-invoice-graphql/.meshrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,3 @@ serve:
sdk:
generateOperations:
selectionSetDepth: 2

require:
- ts-node/register/transpile-only
5 changes: 2 additions & 3 deletions packages/green-invoice-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@
],
"scripts": {
"build": "tsc",
"copy-files": "cp -a .mesh/ dist/.mesh/",
"dev": "ts-node ./src/index.ts",
"generate": "mesh build --fileType js",
"postbuild": "yarn copy-files",
"generate": "NODE_OPTIONS=\"--loader ts-node/esm\" mesh build && mv .mesh src/mesh-artifacts",
"postbuild": "exit 0",
"prebuild": "yarn generate",
"prepublish": "yarn build",
"pretest": "yarn build",
Expand Down
4 changes: 2 additions & 2 deletions packages/green-invoice-graphql/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMeshSDK, Sdk } from '../.mesh/index.js';
import { getMeshSDK, Sdk } from './mesh-artifacts/index.js';

export const init = async (id: string, secret: string): Promise<{ sdk: Sdk }> => {
const authParams = {
Expand All @@ -18,4 +18,4 @@ export const init = async (id: string, secret: string): Promise<{ sdk: Sdk }> =>
return { sdk };
};

export * from '../.mesh/index.js';
export * from './mesh-artifacts/index.js';
3 changes: 0 additions & 3 deletions packages/hashavshevet-mesh/.meshrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ sdk:
generateOperations:
selectionSetDepth: 2

require:
- ts-node/register/transpile-only

additionalTypeDefs: |
extend type Transaction {
batch: Batch
Expand Down
3 changes: 0 additions & 3 deletions packages/payper-mesh/.meshrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@ serve:
sdk:
generateOperations:
selectionSetDepth: 2

require:
- ts-node/register/transpile-only
16 changes: 16 additions & 0 deletions patches/@graphql-mesh+utils+0.42.8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/node_modules/@graphql-mesh/utils/index.js b/node_modules/@graphql-mesh/utils/index.js
index 0e786ed..4de73f6 100644
--- a/node_modules/@graphql-mesh/utils/index.js
+++ b/node_modules/@graphql-mesh/utils/index.js
@@ -40,6 +40,11 @@ async function defaultImportFn(path) {
return new Function(`return import(${JSON.stringify(path)})`)();
}
throw e;
+ }).catch(e => {
+ if (crossHelpers.path.isAbsolute(path) && !path.endsWith('.js') && !path.endsWith('.ts')) {
+ return defaultImportFn(`${path}.ts`);
+ }
+ throw e;
});
if (module.default != null) {
module = module.default;
88 changes: 86 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,11 @@
"@whatwg-node/fetch" "0.4.6"
tslib "^2.3.1"

"@yarnpkg/lockfile@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==

abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
Expand Down Expand Up @@ -2746,6 +2751,11 @@ chownr@^1.1.1:
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b"
integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==

ci-info@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==

ci-info@^3.1.0, ci-info@^3.2.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.4.0.tgz#b28484fd436cbc267900364f096c9dc185efb251"
Expand Down Expand Up @@ -2999,6 +3009,17 @@ cross-spawn@^5.1.0:
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
dependencies:
nice-try "^1.0.4"
path-key "^2.0.1"
semver "^5.5.0"
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -4014,6 +4035,13 @@ [email protected]:
micromatch "^4.0.2"
pkg-dir "^4.2.0"

find-yarn-workspace-root@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd"
integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==
dependencies:
micromatch "^4.0.2"

flat-cache@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11"
Expand Down Expand Up @@ -4593,6 +4621,13 @@ is-callable@^1.2.7:
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==

is-ci@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c"
integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==
dependencies:
ci-info "^2.0.0"

is-ci@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.1.tgz#db6ecbed1bd659c43dac0f45661e7674103d1867"
Expand Down Expand Up @@ -4965,6 +5000,13 @@ kind-of@^6.0.3:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

klaw-sync@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
dependencies:
graceful-fs "^4.1.11"

kleur@^4.1.4:
version "4.1.5"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-4.1.5.tgz#95106101795f7050c6c650f350c683febddb1780"
Expand Down Expand Up @@ -5476,6 +5518,11 @@ next-tick@1, next-tick@^1.1.0:
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb"
integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==

nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

no-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d"
Expand Down Expand Up @@ -5677,7 +5724,7 @@ onetime@^6.0.0:
dependencies:
mimic-fn "^4.0.0"

[email protected]:
[email protected], open@^7.4.2:
version "7.4.2"
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
Expand Down Expand Up @@ -5856,6 +5903,26 @@ [email protected], pascal-case@^3.1.2:
no-case "^3.0.4"
tslib "^2.0.3"

patch-package@^6.5.0:
version "6.5.0"
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.5.0.tgz#feb058db56f0005da59cfa316488321de585e88a"
integrity sha512-tC3EqJmo74yKqfsMzELaFwxOAu6FH6t+FzFOsnWAuARm7/n2xB5AOeOueE221eM9gtMuIKMKpF9tBy/X2mNP0Q==
dependencies:
"@yarnpkg/lockfile" "^1.1.0"
chalk "^4.1.2"
cross-spawn "^6.0.5"
find-yarn-workspace-root "^2.0.0"
fs-extra "^7.0.1"
is-ci "^2.0.0"
klaw-sync "^6.0.0"
minimist "^1.2.6"
open "^7.4.2"
rimraf "^2.6.3"
semver "^5.6.0"
slash "^2.0.0"
tmp "^0.0.33"
yaml "^1.10.2"

[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
Expand Down Expand Up @@ -5884,6 +5951,11 @@ path-is-absolute@^1.0.0:
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==

path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==

path-key@^3.0.0, path-key@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
Expand Down Expand Up @@ -6435,6 +6507,13 @@ [email protected], rimraf@^3.0.2:
dependencies:
glob "^7.1.3"

rimraf@^2.6.3:
version "2.7.1"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==
dependencies:
glob "^7.1.3"

rollup-plugin-generate-package-json@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-generate-package-json/-/rollup-plugin-generate-package-json-3.2.0.tgz#e9c1d358f2be6c58b49853af58205292d45a33ff"
Expand Down Expand Up @@ -6523,7 +6602,7 @@ secure-json-parse@^2.4.0:
resolved "https://registry.yarnpkg.com/secure-json-parse/-/secure-json-parse-2.5.0.tgz#f929829df2adc7ccfb53703569894d051493a6ac"
integrity sha512-ZQruFgZnIWH+WyO9t5rWt4ZEGqCKPwhiw+YbzTwpmT9elgLrLcfuyUiSnwwjUiVy9r4VM3urtbNF1xmEh9IL2w==

"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.6.0, semver@^5.7.1:
"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0, semver@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
Expand Down Expand Up @@ -6626,6 +6705,11 @@ simple-update-notifier@^1.0.7:
dependencies:
semver "~7.0.0"

slash@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==

slash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
Expand Down

0 comments on commit e5a62eb

Please sign in to comment.