How can I get babel to respect the sovereignty of a linked module?

Viewed 22

I've created a simple repo on github to repro my base issue: https://github.com/spiderworm/babel-problem

I have two npm modules locally. One is a library module, the other a demo site for the library module. Since they're both local only, I've npm linked the library module to the demo site.

The demo site was built with create-react-app. Unfortunately, when trying to npm start the demo site, it fails to transpile because of the private member "#" token found in the linked module.

Failed to compile.

../my-test-lib/index.js 5:2
Module parse failed: Unexpected character '#' (5:2)
File was processed with these loaders:
 * ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| 
| export default class MyTestLib {
>   #something = 'hi';
| 
|   constructor() {

Why would babel be trying to transpile the code in the linked module instead of respecting its sovereignty, and why would it fail to compile private member syntax which is supported in node?

0 Answers
Related