Externals with my library #1721
-
So I've seen trying to use a React library I'm about to launch, Crossroad, with Razzle. It's 1.5kb, vs React Router (+Dom)'s 15kb, and part of how I did it is by publishing it as an ESM module. However with Razzle I've seen a couple of discussions on this topic, but couldn't make it work either way: // razzle.config.js
const nodeExternals = require("webpack-node-externals");
module.exports = {
modify: (config, { target, dev }) => {
config.externals =
target === "node"
? [
nodeExternals({
whitelist: [
dev ? "webpack/hot/poll?300" : null,
/\.(eot|woff|woff2|ttf|otf)$/,
/\.(svg|png|jpg|jpeg|gif|ico)$/,
/\.(mp4|mp3|ogg|swf|webp)$/,
/\.(css|scss|sass|sss|less)$/,
/^crossroad/, // <= My library name
/^@bit\/(.*)/
].filter(Boolean)
})
]
: [];
return config;
}
};
Error in both cases:
The error seems clear, but it's like babel is ignoring the line where it says to include the node_packages library in the transpilation process. I'd be happy to contribute a small "how-to" guide for future devs in a similar situation, but first I'd need to solve this issue for myself. Any idea of what can be wrong here? Here is a repo for repro, clone npm install and |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
https://razzlejs.org/docs/customization#transpilation-of-external-modules |
Beta Was this translation helpful? Give feedback.
-
Awesome, thanks! I see I missed that in the other discussions, and that this was already answered :) |
Beta Was this translation helpful? Give feedback.
https://razzlejs.org/docs/customization#transpilation-of-external-modules