Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ES modules or CommonJS in distribution #194

Closed
RDIL opened this issue Apr 29, 2022 · 3 comments
Closed

Provide ES modules or CommonJS in distribution #194

RDIL opened this issue Apr 29, 2022 · 3 comments
Assignees

Comments

@RDIL
Copy link

RDIL commented Apr 29, 2022

Hi!

Loving this project so far, but Ive ran into an issue where I can't use it because it doesn't provide a suitable distribution format. UMD works in the browser, but not in an environment like Vite (with SSR), so it would be awesome if either CommonJS or ES modules were published in addition. I was able to easily swap over the default module format to CommonJS using this change:

diff --git a/build/webpack.config.js b/build/webpack.config.js
--- a/build/webpack.config.js	(revision 64504c93027b06802fed2b6d8053d0f4613e2284)
+++ b/build/webpack.config.js	(date 1651198213319)
@@ -25,8 +25,7 @@
     },
     output: {
         filename: '[name].js',
-        libraryTarget: 'umd',
-        umdNamedDefine: true,
+        libraryTarget: 'commonjs2',
         globalObject: `(typeof self !== 'undefined' ? self : this)`
     },
     plugins: [
@@ -36,4 +35,4 @@
             openAnalyzer: false
         })
     ]
-};
\ No newline at end of file
+};

But this is more of a proof-of-concept, as ideally both UMD and CJS should be published to maintain backwards compatibility.

This would be awesome to have, and I thank you in advance for if you do accept this suggestion!

@newcat
Copy link
Owner

newcat commented May 7, 2022

Good point! I actually did this for Baklava v2 but never "ported it back" to v1. I hope I have some time in the next couple of days to do this.

Also thanks for the generous donation, I really appreciate it!

@newcat newcat self-assigned this May 7, 2022
newcat added a commit that referenced this issue May 21, 2022
@newcat
Copy link
Owner

newcat commented May 21, 2022

Implemented in v1.10.0. Hope it works!

@newcat newcat closed this as completed May 21, 2022
@RDIL
Copy link
Author

RDIL commented May 22, 2022

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants