recently I've been trying to convert my aws-lambda project from outputting cjs to esm. The only thing left that doesn't work is my usage of reflect-metadata. In this project I also do chunking:
optimization: {
minimize: false,
splitChunks: {
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
filename: 'vendors-[name].js',
priority: -10,
chunks: 'all'
}
}
}
},
I'm importing reflect metadata like this:
import 'reflect-metadata';
When I had cjs before, I can see this call
// EXTERNAL MODULE: ../../../node_modules/reflect-metadata/Reflect.js
var reflect_metadata_Reflect = __webpack_require__(48060);
After outputting esm (it works when I remove reflect-metadata), I see this err
"TypeError: Cannot read properties of undefined (reading 'call')",
" at __webpack_require__ (webpack:///webpack/bootstrap:19:1)"
I know for sure this is dying at the import line, since I put console.logs before and after it.
The main difference I see is that now the webpack_require for reflect-metadatacall is now
__webpack_require__(8060);
When I remove chunking and everything is in one file it works. I'm guessing that somehow this webpack_require doesn't actually import require-metadata properly. I did try doing something like import * as asdf from 'reflect-metadata'
but no luck
Does anyone have any advice or tips to try?