fent / randexp.js

Create random strings that match a given regular expression.
http://fent.github.io/randexp.js/
MIT License
1.83k stars 92 forks source link

Compile package to es5 #68

Open tsjohns9 opened 5 years ago

tsjohns9 commented 5 years ago

This package, as well as node-drange are not transpiled to es5, and it makes cross-browser support difficult. This module is part of my dependency tree and broke ie11 support due to the use of es6 features. It would be nice if this could be distributed so that it has more cross-browser support

fent commented 5 years ago

Are you using a package bundler? If so, which one?

My understanding is that in the future, bundlers will handle transpiling, letting library authors focus only on the library, and not on how to export the library. I don't even think that I should include a minified version, since that's one of the first things bundler's handle. This is actually one of the only projects that includes a minified browserified version.

tsjohns9 commented 5 years ago

Yes, I am using webpack. What we have been doing is excluding all node_modules from running through babel-loader. To work around this I had to identify the packages that were not already transpiled to es5, and then have webpack run those through babel-loader. This is fine for now, but I can't image this is how other projects handle dependencies that are not already transpiled to es5. If we ever add a new package, and somewhere in the dependency tree there is a module that is not already transpiled we will have to identify that and add include it in webpack.

ryoppippi commented 5 months ago

Hi This is bun's bag, but if you compile randexp.js to es5 or just use named exports, it solves

1 ❱ bun run index.ts
1 | (function (entry, fetcher)
    ^
SyntaxError: Missing 'default' export in module './node_modules/randexp/lib/randexp.js'.

This is related to this issue https://github.com/oven-sh/bun/issues/7465