Open ClaytonTDM opened 1 week ago
It seems it was always tested with a bundler so I never seed this issue, but there is missing "type": "module"
in package.json ( you can add it yourself for now into package.json of this module to see if it works). Anyway, it doesn't change the fact that you try to import ESM code from commonjs (require), which is not supported by vanilla node.js: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
It also breaks with ESM.
Ok, I can't get it working with something like this which is stupid, I don't know how I should configure tsconfig to make it work:
// node file.mjs
import { AssetsParser, getLoadedModelsStore, getLoadedBlockstatesStore } from 'mc-assets'
import blockstatesModels from 'mc-assets/dist/blockStatesModels.json' assert { type: 'json' }
const blockstatesStore = getLoadedBlockstatesStore(blockstatesModels)
console.log(blockstatesStore.get('latest', 'stone'))
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '<...>/node_modules/.pnpm/mc-assets@0.2.12/node_modules/mc-assets/dist/stores' imported from <...>/node_modules/.pnpm/mc-assets@0.2.12/node_modules/mc-assets/dist/index.js
I'm unable to use the module with the example code due to the following error:
The first line of my file being:
const { AssetsParser, getLoadedModelsStore, getLoadedBlockstatesStore } = require('mc-assets');