Skip to content

Commit

Permalink
fix: Ensure streams have valid .mjs output modules
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed May 24, 2024
1 parent 379567a commit 4b070e3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions config/node-13-exports.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
const fs = require('fs');

const snakeCaseToCamelCase = str =>
str.replace(/([-_][a-z])/g, group => group.toUpperCase().replace('-', ''));

const copy = name => {
const copy = (filename) => {
// Copy .module.js --> .mjs for Node 13 compat.
const filename = name.includes('-') ? snakeCaseToCamelCase(name) : name;
fs.writeFileSync(
`${process.cwd()}/dist/${filename}.mjs`,
fs.readFileSync(`${process.cwd()}/dist/${filename}.module.js`)
Expand All @@ -14,3 +10,5 @@ const copy = name => {

copy('index');
copy('jsx');
copy('stream');
copy('stream-node');

0 comments on commit 4b070e3

Please sign in to comment.