I'm try to use third-party libraries in my NuxtJS project. This dependencies has cjs and mjs extensions.
Simple import
import { DataModel } from '@glazed/datamodel'
import { DIDDataStore } from '@glazed/did-datastore'
raised error:
ERROR Failed to compile with 1 errors friendly-errors 16:55:12
ERROR in ./node_modules/@glazed/datamodel/dist/lib.cjs friendly-errors 16:55:12
Module parse failed: Unexpected token (1:1104) friendly-errors 16:55:12
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
My nuxt.config.js file:
transpile: [
'dids',
'did-jwt',
'@glazed/tile-loader',
'@glazed/did-datastore',
'@glazed/datamodel',
],
extend(config) {
...
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
})
config.module.rules.push({
test: /\.сjs$/,
include: /node_modules/,
type: "javascript/auto",
})
...
What's wrong?