linq.ts: SyntaxError: Unexpected token `export`

Node v10.15.3

Imported like this:

import { List } from 'linqts';

myproject/node_modules/linqts/dist/index.js:10
[0] [1] export { default as List } from './src/list';
[0] [1] ^^^^^^
[0] [1] 
[0] [1] SyntaxError: Unexpected token export
[0] [1]     at new Script (vm.js:80:7)
[0] [1]     at createScript (vm.js:274:10)
[0] [1]     at Object.runInThisContext (vm.js:326:10)
[0] [1]     at Module._compile (internal/modules/cjs/loader.js:664:28)
[0] [1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
[0] [1]     at Module.load (internal/modules/cjs/loader.js:600:32)
[0] [1]     at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
[0] [1]     at Function.Module._load (internal/modules/cjs/loader.js:531:3)
[0] [1]     at Module.require (internal/modules/cjs/loader.js:637:17)
[0] [1]     at require (internal/modules/cjs/helpers.js:22:18)

Here is my tscconfig.json:

{
  "compilerOptions": {
    "declaration": false,
    "noUnusedLocals": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2017",
      "dom"
    ],
    "removeComments": false,
    "sourceMap": true,
    "mapRoot": "../dist/",
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "../dist/",
    "target": "es2016",
    "allowJs": false,
    "typeRoots": [
      "../node_modules/@types"
    ],
    "baseUrl": "."
    
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 26 (16 by maintainers)

Most upvoted comments

So, here’s what I did. Cloned your project and ran npm run build to get the dist folder. Created a typeScript project and imported the index.js folder from the dist generated. The TS project ran without any errors. The issue is indeed the way you are publishing to npm. I couldn’t find a publish command in your package.json. I can open up a PR, but essentially what we need to do, is to publish the contents of the dist folder, which has all TypeScript imports compiled down to node requires

Sure @kutyel 😬

Also, @mrsauravsahu feel free to provide a PR if you want to contribute! 😉

Can you please format your code, you can use back ticks ` 3 of them wrapped around your code so it is easier to read.