Comments (8)
Next version should fix this once and forever.
from parse-function.
Strange... it's export default
.. I will check it later today
from parse-function.
Those are the configs for Rollup.. https://github.com/tunnckoCoreLabs/hela-config-tunnckocore/tree/v0.5.19/config
It creates ...
Minute later: I think I got what's the problem. parse-function
does not have pkg.legacy
and pkg.unpkg
fields which are needed for the legacy-browsers
and modern-browsers
configs. Hm.
A `hela` shareable config (preset of tasks) for @tunnckoCore GitHub organization - tunnckoCoreLabs/hela-config-tunnckocore
from parse-function.
In anyway... i will release #138 in day or two, for sure. So everything will be simplified in terms of usage and dev workflow / building.
from parse-function.
Can you give me what's the difference between them? What's exported by both?
from parse-function.
require('parse-function/dist/index.js');
returns the parse
function itself.
require('parse-function/dist/index.es.js');
returns an object with a default
property.
It means that you can't use require('parse-function)
in your code because it will resolve to the function itself when run on the server and to an object with a default
key on the browser.
from parse-function.
For what it's worth, here is how I export my modules to provide the same API for both:
index.cjs.js:
class Foo {
}
exports.Foo= Foo;
index.es.js:
export class Foo {
}
Then, using either const {Foo} = require('index.cjs.js');
or const {Foo} = require('index.es.js');
leads to the same result: Foo
will contain the class/constructor.
from parse-function.
Consistency is good thing, yea. But it's totally normal to expect require-ing esm to return an object with default key property.
That's why it's in the module field. Because bundlers will load the module field instead, and so the behaving is the same.
example.js
import parse from 'parse-function'
console.log(parse)
is the function if you use bundlers or running it with node -r esm example.js
.
require
-ing ESM inside CJS is what happening to do the inconsistencies. And that's hat i didn't liked in Babel 6. They kinda forced users to do require('foo-bar').default
because they stopped appending module.exports
but only doing them as exports.[name]
from parse-function.
Related Issues (20)
- Error when parsing a native function HOT 2
- Bug with arguments default value consisting of a list of expressions HOT 11
- fake issue
- v5.1.3 doesn't have a `dist/index.js` file HOT 5
- Ensure dist builds exists
- When default value consists of a list of expressions, default value is not returned as a string
- 5.2.0 has no dist folder HOT 4
- Weekly Digest (10 February, 2019 - 17 February, 2019)
- Weekly Digest (17 February, 2019 - 24 February, 2019)
- Weekly Digest (24 February, 2019 - 3 March, 2019)
- Weekly Digest (3 March, 2019 - 10 March, 2019)
- Arrow function with inner function fails to parse HOT 7
- Function with named parameters is not parsed correctly HOT 1
- V5.3.2 Error: Cannot find module './utils' HOT 4
- Announcement (a bit late): moved to a `tunnckoCore/opensource` monorepo
- add "Plugins Architecture" and "Result" sections
- Strange parser error when an `if` statement is at the top of an async arrow function HOT 8
- Parse bound functions HOT 8
- npm version and github release are not in sync HOT 1
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 parse-function.