tiddly-gittly/git-sync-js

SyntaxError: Unexpected token 'export'

Opened this issue · 2 comments

The lib is crashing when used with a typescript configuration:

tsconfig.json :

{
  "compilerOptions": {
    "target": "ESNext",
    "sourceMap": true,
    "outDir": "dist",
    "strict": true,
    "lib": ["esnext"],
    "esModuleInterop": true,
    "moduleResolution": "node16",
    "module": "Node16",
    "downlevelIteration": true,
    "resolveJsonModule": true,
    "noImplicitAny": false,
    "typeRoots": [
      "./src/types",
      "./node_modules/@types/"
    ]
  },
  "include": ["./**/*.d.ts","src//*.ts", "src//*.json",
    "../.env", ".eslintrc.json", "typings.d.ts"]
}

Logs:

server-1   | /server/node_modules/git-sync-js/dist/src/index.js:2
server-1   | export * from './clone';
server-1   | ^^^^^^
server-1   | 
server-1   | SyntaxError: Unexpected token 'export'
server-1   |     at wrapSafe (node:internal/modules/cjs/loader:1376:18)
server-1   |     at Module._compile (node:internal/modules/cjs/loader:1405:20)
server-1   |     at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
server-1   |     at Object.require.extensions.<computed> [as .js] (/server/node_modules/ts-node/src/index.ts:1608:43)
server-1   |     at Module.load (node:internal/modules/cjs/loader:1275:32)
server-1   |     at Function.Module._load (node:internal/modules/cjs/loader:1091:12)
server-1   |     at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
server-1   |     at Module.require (node:internal/modules/cjs/loader:1297:12)
server-1   |     at require (node:internal/modules/helpers:123:16)
server-1   |     at Object.<anonymous> (/server/src/integrations/git/GitRepositoryComponent.ts:1:1)
server-1   |     at Module._compile (node:internal/modules/cjs/loader:1460:14)
server-1   |     at Module.m._compile (/server/node_modules/ts-node/src/index.ts:1618:23)
server-1   |     at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
server-1   |     at Object.require.extensions.<computed> [as .ts] (/server/node_modules/ts-node/src/index.ts:1621:12)
server-1   |     at Module.load (node:internal/modules/cjs/loader:1275:32)
server-1   |     at Function.Module._load (node:internal/modules/cjs/loader:1091:12)
server-1   |     at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
server-1   |     at Module.require (node:internal/modules/cjs/loader:1297:12)
server-1   |     at require (node:internal/modules/helpers:123:16)
server-1   |     at Object.<anonymous> (/server/src/core/startup/index.ts:5:1)
server-1   |     at Module._compile (node:internal/modules/cjs/loader:1460:14)
server-1   |     at Module.m._compile (/server/node_modules/ts-node/src/index.ts:1618:23)
server-1   |     at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
server-1   |     at Object.require.extensions.<computed> [as .ts] (/server/node_modules/ts-node/src/index.ts:1621:12)
server-1   |     at Module.load (node:internal/modules/cjs/loader:1275:32)
server-1   |     at Function.Module._load (node:internal/modules/cjs/loader:1091:12)
server-1   |     at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
server-1   |     at Module.require (node:internal/modules/cjs/loader:1297:12)
server-1   |     at require (node:internal/modules/helpers:123:16)
server-1   |     at Object.<anonymous> (/server/src/index.ts:11:1)
server-1   |     at Module._compile (node:internal/modules/cjs/loader:1460:14)
server-1   |     at Module.m._compile (/server/node_modules/ts-node/src/index.ts:1618:23)
server-1   |     at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
server-1   |     at Object.require.extensions.<computed> [as .ts] (/server/node_modules/ts-node/src/index.ts:1621:12)
server-1   |     at Module.load (node:internal/modules/cjs/loader:1275:32)
server-1   |     at Function.Module._load (node:internal/modules/cjs/loader:1091:12)
server-1   |     at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
server-1   |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)
server-1   |     at phase4 (/server/node_modules/ts-node/src/bin.ts:649:14)
server-1   |     at bootstrap (/server/node_modules/ts-node/src/bin.ts:95:10)
server-1   |     at main (/server/node_modules/ts-node/src/bin.ts:55:10)
server-1   |     at Object.<anonymous> (/server/node_modules/ts-node/src/bin.ts:800:3)
server-1   |     at Module._compile (node:internal/modules/cjs/loader:1460:14)
server-1   |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
server-1   |     at Module.load (node:internal/modules/cjs/loader:1275:32)
server-1   |     at Function.Module._load (node:internal/modules/cjs/loader:1091:12)
server-1   |     at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
server-1   |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)
server-1   |     at node:internal/main/run_main_module:30:49

This is most likely due to the package.json file not setting type: "module"

Probably, but I never tried to build it as esm, I also use this package as cjs in https://github.com/tiddly-gittly/TidGi-Desktop . I'm not sure why there will be export * from './clone';

in this project's tsconfig there is

  "compilerOptions": {
    "target": "ESNext",

and it should not need the type: "module"