Comments (9)
I think it will be possible only if we solve the cjs export.
from js-sdsl.
How about applying export default only to esm?
from js-sdsl.
How about applying export default only to esm?
What do you mean?
from js-sdsl.
provide export default
only to users who use esm.
from js-sdsl.
Do you mean:
import OrderedSet from 'ordered-set';
const { OrderedSet } = require('ordered-set');
from js-sdsl.
yes
from js-sdsl.
yes
Why cjs cannot transform to const OrderedSet = require('ordered-set')
?
from js-sdsl.
The problem is when the named export exists together with default export.
If you use named export, the value you received in require
becomes an object.
However, it is generally impossible to be an object and a constructor of an object(a.k.a class) at the same time, so if you do default export at the same time as named export, one side is ignored.
// lib.ts
class Foo { }
class Bar { }
class Baz { }
export { Foo, Bar };
export default Baz; // this will be ignored in CJS
// index.ts
// This value will be { "Foo": [object Object], "Bar": [object Object] }
const lib = require('./lib.js');
// Because of the Destructuring, it seems like it is the same as a named export. But what the `require` returned was just an object
const { Foo, Bar } = require('./lib.js');
from js-sdsl.
I think there must be some way to transform export default xxx
to exports = xxx
.
I'll promise the single file like OrderedSet.ts
will export only one class member.
Consider this tool: https://www.npmjs.com/package/ts-transform-default-export.
from js-sdsl.
Related Issues (20)
- Find a way to do bench for database connection
- Memory complexity? HOT 12
- iterator access denied?why? HOT 3
- [RFC] About the version 5.x
- ESM build has classes downleveled to functions, but CJS build does not HOT 3
- Find a new way to do publish HOT 4
- Question: OrderedSet and comparison function HOT 4
- OrderedSet with less than 3 items reverse iteration infinite loop HOT 4
- OrderedMapIterator.pointer does not support array destructuring assignment (TypeError: it.pointer is not iterable) HOT 3
- `isAccessible` property for iterators? HOT 2
- Queue is empty, but the last value still exists HOT 2
- Standardize HashContainer HOT 1
- Optimize HashContainer until the performance is on par with ES6 HOT 9
- Reduce packaging size HOT 15
- bug: get wrong tree index when tree size is 1 HOT 1
- Make heap stronger HOT 1
- Write examples for all apis
- Error: Cannot find module './Base' HOT 2
- Display version selection on the home page of gh-pages HOT 7
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 js-sdsl.