(refactor) use build.transpile inside of nuxt.config.js for esm-only dependencies

https://v2.nuxt.com/docs/configuration-glossary/configuration-build#transpile
This commit is contained in:
Valentyne Stigloher 2023-12-20 18:51:04 +01:00
parent 92e051efb7
commit fa5bb609ec

View File

@ -239,12 +239,12 @@ export default {
use: 'yaml-loader', use: 'yaml-loader',
}); });
config.module.rules.push({ config.module.rules.push({
test: /.js/, test: /\.js$/,
loader: 'string-replace-loader', loader: 'string-replace-loader',
options: { options: {
// To load .json files inside of .js files of type module in a node environment, // To load .json files inside of .js files of type module in a node environment,
// one has to either load from the filesystem or via a created require(). // one has to either load from the filesystem or via a created require().
// While a load vie filesystem is very unfriendly to webpack, // While a load via filesystem is very unfriendly to webpack,
// the explicit creation of a require() function can be removed. // the explicit creation of a require() function can be removed.
// This probably gets replaced in the future by a `import from with { type: 'json' }` // This probably gets replaced in the future by a `import from with { type: 'json' }`
// statement, which is currently (2023-12) experimental in node and not well supported in webpack. // statement, which is currently (2023-12) experimental in node and not well supported in webpack.
@ -261,12 +261,8 @@ export default {
], ],
}, },
}); });
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
});
}, },
transpile: ['markdown-it'],
}, },
env: { env: {
ENV: process.env.ENV, ENV: process.env.ENV,