remix-run / history

Manage session history with JavaScript
MIT License
8.29k stars 961 forks source link

fix: import history from ESM #934

Closed ryanflorence closed 2 years ago

ryanflorence commented 2 years ago

Removing closure compiiler fixes the problem. The build is now much faster and the resulting file size difference is marginal.

The UMD production file size went from 6,105 bytes with closure compiler to 6,164 without it. We can afford 59 bytes to get ESM support.

ryanflorence commented 2 years ago

I verified manually with this:

npm run build
mkdir ~/Desktop/test
touch ~/Desktop/test/go.mjs
cp -R build ~/Desktop/test/node_modules

Then running this script works as expected:

import { createMemoryHistory } from 'history';
console.log(createMemoryHistory);
kristoferbaxter commented 2 years ago

Seems like a smart tradeoff to me as well.

Does this mean the dependency can also be removed in package.json? I didn't see another usage.