comlink icon indicating copy to clipboard operation
comlink copied to clipboard

comlink support for ES5

Open gamegee opened this issue 5 years ago • 1 comments

Not sure if it's a suggestion or an issue.

I am using comlink-loader and I have encountered issue with my webkpack config and comlink. Indeed, my webpack config transpile my source code from ES6 syntax to ES5.

// webpack-config.js
...
{
  test: /\.worker\.(js|ts)$/i,
  use: [
    {
      loader: 'comlink-loader',
      options: {
        singleton: true
      }
    }
  ]
},
{
  test: /\.(j|t)sx?$/,
  use: 'happypack/loader?id=js'
},
{
  test: /\.(jpe?g|png|gif|svg)$/i,
  use: {
    loader: 'file-loader',
    options: {
      name: production ? '[hash].[ext]' : '[name][hash.[ext]',
      outputPath: 'assets/images',
      esModule: false
    }
  }
}
...

But comlink module has ES6 syntax out of the box and usually you don't have to transpile node_modules. I am running into this issue:

Unexpected token: keyword «const» [./node_modules/comlink/dist/esm/comlink.mjs:13,0][application-f5b2baede3200cfef2b1.js:43532,0]

Wouldn't it be better to directly expose ES5 syntax from comlink module ?

gamegee avatar Jun 22 '20 13:06 gamegee

have the same problem

selma-li avatar Aug 11 '21 06:08 selma-li