We’re trying to register custom blocks specifically for our theme, which uses the times
function from lodash-es. If we import it via
import { times } from 'lodash-es'
or
const times = require('lodash/times')
we either get a failing build due to a Terser error or a console error when in the gutenberg editor (require is not defined
).
From what I understand, @babel/preset-env
should handle both of these scenarios, but we’re not able to get this working. My assumption is that it’s because babel-loader
is set to ignore files within node_modules
, but I don’t know how to modify the exclude
option within the babel config in bud.config.js to let babel transform imports from node_modules
. We’ve done this in create-guten-block
with no issue before, and the webpack config between that and bud are pretty similar overall, so we’re at a loss for how to get this work, here.
How should we approach this?