I finally figured it out in my system.
The named export solution is wrong, since rollup-plugin-commonjs will handle the export to Subject.js just fine.
The problem for me was the βincludeβ option in rollup-plugin-commonjs.
There are two problems.
Number one: when specifying inclusions in the parameters as "node_modules / rxjs / **" you must be sure that the full path is resolved where you expect it to.
Example:
I run my build command from "c: / foo / build", but my files are in "c: / my-source", then the included templates can enable "c: / build / node_modules", which means that the commonjs plugin checks whether he should handle "node_modules / rxjs / ", he will see that "c: / my-source / node_modules / rxjs / " does not match "c: / build / node_modules / rxjs / **", so he will not convert export to ES6.
The second problem is case sensitivity. Incoming templates are case sensitive. It also helped me.
Both of these problems can be confirmed by opening the file node_modules \ rollup-plugin-commonjs \ dist \ rollup-plugin-commonjs.cjs.js and debugging the transform function.
If you change the code (at the very beginning of the conversion function) to be something like this
if (id.includes('rxjs\\Subject.js')) { debugger; }
and then run the code in the debugger, you can go through the code until it gets into the filter function. There you will see that the filter function skips the "rxjs / Subject.js" file.
I almost guarantee that this is a problem when an error occurs.
source share