Comments (8)
Wow. Your know more than me!
I heard this might be a good option to publish module like stampit https://github.com/developit/microbundle
from stampit.
We accept PRs π
Even half baked PRs π
from stampit.
Yes. It is possible. Please, guide me through.
Do I need to add "module": "dist/stampit.module.js",
to the package.json
?
Anything else is needed?
from stampit.
Thanks!
Do I need to add "module": "dist/stampit.module.js", to the package.json?
This, too, if I understand it correctly (not an expert on this)
It seems that currently, stampit uses node-compatible common.js-style module.exports
or export to a global variable (see code) and an optional build step via uglyify to get a minimized version of the library.
I guess the best way would be writing ES6 style and converting to common.js via rollup (minimal example). But this might be too much of a change so I understand if this is not priority.
from stampit.
Before I cause a mess there β it seems that the code as been ES6 compatible, but was subsequently changed. This seems to have been part of minification, which I do not fully understand (was this for the code to be small itself or for being better minify-able?).
Another thing that is striking is the use of "var1", "var2"β¦ through the code, introduced in "further minification 7" β why var var1
instead of var properties
? (similar changes towards less speaking variable names were also done before, e.g. in "further minification 2")
from stampit.
from stampit.
Out of curiosity, what are the use cases for ES modules?
One "silly" idea comes to my mind: have the source use ES Module syntax and use TypeScript compiler to compile the CommonJS version.
If there is any other tool chain to transform CommonJS to ESM (or vice versa) I'd gladly give it a look.
from stampit.
Out of curiosity, what are the use cases for ES modules?
The modern tooling usually works fine with both - ES6 exporting and the CJS. However, they work slightly better with ES6 exporting version.
There is nothing to treeshake in stampit, so that can't be the main reason.
One "silly" idea comes to my mind: have the source use ES Module syntax and use TypeScript compiler to compile the CommonJS version.
That's a good idea. I was thinking about it a lot myself. Can be done with Babel compiler too. Or Rollup. Or the above mentioned microbundle
.
If there is any other tool chain to transform CommonJS to ESM (or vice versa) I'd gladly give it a look.
Here is my typical approach.
I copy the the Preact project setup. :)
from stampit.
Related Issues (20)
- Performance degradation in node.js 8 HOT 12
- 'Use metadata in static functions' sample code throws an error HOT 1
- Suggestions on how to leverage stampit w/ Vue.js? HOT 6
- Need some guidance HOT 5
- β¨ Add .version to stampit object HOT 4
- Link to API docs is broken in Readme? HOT 3
- Compose using an instance? HOT 4
- [Bug] RangeError: 'Maximum call stack size exceeded' when use setters HOT 3
- [SOLVED] How to express stampit factories and instances in typescript HOT 4
- Implementing the Decorator Pattern HOT 5
- π Stamps vs Traits vs Mixins vs Has-a/Is-a composition vs Multiple inheritance (classes) feature-by-feature comparison HOT 3
- when i return something in init(), and then i can not call all methods HOT 10
- when i use getter and setter, i got this, is this a issue? HOT 21
- array in props persist across instances of stamp HOT 1
- Website is down HOT 3
- Not so much an issue but a question. HOT 4
- Please helpοΌI would like update V2 to V4 HOT 1
- RFC: TypeScript version bump + Type enhancements HOT 4
- Can't seem to mock axios in a stamp HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stampit.