babel-plugin-preval icon indicating copy to clipboard operation
babel-plugin-preval copied to clipboard

'preval can also handle some simple dynamic values as well' not working on webpack

Open ilyary opened this issue 3 years ago • 0 comments

Using: "webpack": "^4.46.0", "nuxt": "^2.15.8", "babel-plugin-preval": "^5.0.0",

const locale = 'ru'

// @/langs/ru.js:
// // @preval
//
// module.exports = require('../tools/i18n').packs.ru
const langPack = require(`@/langs/${locale}.js`) // WORKS
//const langPack = preval`module.exports = require('../tools/i18n').packs.ru` // WORKS
//const langPack = preval`module.exports = require('../tools/i18n').packs.${locale}` // DOES NOT WORK

Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: ${project}/plugins/index.js: Unable to determine the value of your preval string at PluginPass.TaggedTemplateExpression (${project}/node_modules/babel-plugin-preval/dist/index.js:72:17)

ilyary avatar Dec 01 '21 08:12 ilyary