meteor icon indicating copy to clipboard operation
meteor copied to clipboard

Support import.meta

Open alextaaa opened this issue 3 years ago • 8 comments

I try use a new ES module but catch the error

SyntaxError: Cannot use 'import.meta' outside a module
W20221129-01:33:22.402(3)? (STDERR)     at new Script (vm.js:102:7)
W20221129-01:33:22.402(3)? (STDERR)     at createScript (vm.js:262:10)
W20221129-01:33:22.402(3)? (STDERR)     at Object.runInThisContext (vm.js:310:10)

alextaaa avatar Nov 28 '22 22:11 alextaaa

Try to recompile module

package.json:

 "meteor": {
    "mainModule": {
      "client": "client/main.js",
      "server": "server/main.js"
    },
    "nodeModules": {
      "recompile": {
        "your-esm-module": true
      }
    }
  }

More info: https://github.com/meteor/meteor/blob/4442d0e0bf66d890c9dc1bf04f371cfcb82519d7/guide/source/using-npm-packages.md#recompiling-npm-packages

afrokick avatar Nov 29 '22 05:11 afrokick

Thx, but I try to use external modern npm module and catch the error in the module

meteor npm i modern_module

It's not working for me

"meteor": {
    "nodeModules": {
      "recompile": {
        "modern_module": true
      }
    }
  }

Same problem

W20221129-11:00:25.589(3)? (STDERR) /Users/devpro/app/my_project/.meteor/local/build/programs/server/packages/modules.js:531

SyntaxError: Cannot use 'import.meta' outside a module
W20221129-01:33:22.402(3)? (STDERR)     at new Script (vm.js:102:7)
W20221129-01:33:22.402(3)? (STDERR)     at createScript (vm.js:262:10)
W20221129-01:33:22.402(3)? (STDERR)     at Object.runInThisContext (vm.js:310:10)

alextaaa avatar Nov 29 '22 08:11 alextaaa

I changed the issue name to make it more clear. Meteor has never supported import.meta, and is something we should add.

zodern avatar Nov 29 '22 17:11 zodern

ok cool

Could you add the thing to the next release 2.9 ?

alextaaa avatar Nov 29 '22 18:11 alextaaa

I have the same problem with a module that uses import.meta. I cannot use the new version of the module because of this. It would be great to have support for import.meta in future releases. Thanks.

ra2ge avatar Feb 16 '24 10:02 ra2ge