Trying a second app. Anybody run into a import.meta
error in other libraries?
I’ve been trying to use the latest METEOR@3.3-rc.0
with a .swcrc
file:
{
"$schema": "https://swc.rs/schema.json",
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": true,
"dynamicImport": true,
"privateMethod": true,
"functionBind": false,
"exportDefaultFrom": true,
"exportNamespaceFrom": true,
"decorators": false,
"decoratorsBeforeExport": false,
"topLevelAwait": true,
"importMeta": true
},
"transform": {
"react": {
"runtime": "automatic",
"importSource": "react",
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment",
"throwIfNamespace": true,
"development": false,
"useBuiltins": false
},
"optimizer": {
"globals": {
"vars": {
"import.meta": "{ env: { NODE_ENV: 'development' }, url: 'file:///' }"
}
}
}
},
"target": "es2020",
"loose": false,
"externalHelpers": false,
"keepClassNames": true
},
"module": {
"type": "es6",
"strict": false,
"strictMode": true,
"lazy": false,
"noInterop": false,
"ignoreDynamic": true,
"preserveImportMeta": true,
"resolveFully": false
},
"minify": false,
"sourceMaps": true,
"inlineSourcesContent": true,
"isModule": true,
"env": {
"targets": {
"chrome": "90",
"firefox": "90",
"safari": "14",
"edge": "90"
}
},
"exclude": [],
"include": []
}
But so far, no luck. Doing a little research:
Cornerstone3D uses modern ES module syntax including import.meta
for worker registration and environment detection. Meteor’s bundling system (even with SWC) is treating these as non-module scripts during the bundling phase.
Potential Solutions for MDG to Investigate:
- Module Context Preservation: Ensure that when processing node_modules with ES module syntax, the module context is preserved
- import.meta Polyfill: Provide a built-in
import.meta
polyfill during the bundling phase
- Selective Module Processing: Allow certain packages to be processed as true ES modules rather than being bundled