Doesn't work with Babel 7
I get the following error with Babel 7.
Error: Error: No substitution given for "$0". If this is not meant to be a
placeholder you may want to consider passing one of the following options to @babel/template:
- { placeholderPattern: false, placeholderWhitelist: new Set(['$0'])}
- { placeholderPattern: /^$0$/ }
at metadata.placeholders.forEach.placeholder (/Users/david/my-project/node_modules/@babel/template/lib/populate.js:27:15)
at Array.forEach (native)
at populatePlaceholders (/Users/david/my-project/node_modules/@babel/template/lib/populate.js:24:27)
at arg (/Users/david/my-project/node_modules/@babel/template/lib/string.js:22:51)
at err (/Users/david/my-project/node_modules/@babel/template/lib/builder.js:77:14)
at addRequire (/Users/david/my-project/node_modules/babel-plugin-transform-inline-imports-commonjs/transform-inline-imports-commonjs.js:199:43)
at PluginPass.exit (/Users/david/my-project/node_modules/babel-plugin-transform-inline-imports-commonjs/transform-inline-imports-commonjs.js:479:39)
at newFn (/Users/david/my-project/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/Users/david/my-project/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/Users/david/my-project/node_modules/@babel/traverse/lib/path/context.js:40:17)
=============
at module.exports.context (/Users/david/my-project/node_modules/babel-plugin-transform-inline-imports-commonjs/transform-inline-imports-commonjs.js:18:22)
at e (/Users/david/my-project/node_modules/@babel/core/lib/config/full.js:165:14)
at cachedFunction (/Users/david/my-project/node_modules/@babel/core/lib/config/caching.js:33:19)
at loadPluginDescriptor (/Users/david/my-project/node_modules/@babel/core/lib/config/full.js:200:28)
at config.plugins.reduce (/Users/david/my-project/node_modules/@babel/core/lib/config/full.js:69:20)
at Array.reduce (native)
at recurseDescriptors (/Users/david/my-project/node_modules/@babel/core/lib/config/full.js:67:38)
at loadFullConfig (/Users/david/my-project/node_modules/@babel/core/lib/config/full.js:108:6)
I was hoping I could replace this plugin with @babel/plugin-transform-modules-commonjs plugin by using the option { "lazy": true }, but apparently it doesn't work as expected and doesn't fix the cyclic dependencies issues.
By the way, I tried to fix the issue by passing { placeholderPattern: false, placeholderWhitelist: new Set(['$0'])} to the template function as suggested but it didn't help.
I was able finally to get it to work with @babel/plugin-transform-modules-commonjs plugin. I configured my .babelrc as following
["@babel/plugin-transform-modules-commonjs", {
"lazy": ["*"]
}],
For those who couldn't get it to work with just "lazy": ["*"] check this comment on making lazy a function that returns true.