-
Notifications
You must be signed in to change notification settings - Fork 11
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
[WIP] move to esm #15
Conversation
lib/data-factory.js
Outdated
@@ -45,4 +45,4 @@ DataFactory.quad = function (subject, predicate, object, graph) { | |||
|
|||
DataFactory.defaultGraphInstance = new DefaultGraph() | |||
|
|||
module.exports = DataFactory | |||
export default DataFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default export should be avoided with ES modules. At least for non-internal modules
It would be better to have these exported as export BlankNode from './blank-node'
Hi @elf-pavlik. I missed this PR, thanks for your effort. I have proposed similar yesterday for sink-map: rdfjs-base/sink-map#10 Would like to hear your opinion |
Hi @tpluscode I think that a recent esm issue may complicate things. It made me lock my node version to v12.15 It also gave me impression that no one actively maintains esm module 😢 |
Interesting. I have not seen that error myself. Have you? |
Yes, I've stumbled on similar error when using latest node LTS and found that github issue through that. |
I'm really looking forward to having some improvements here. With version 1.1.2 this is a pain, with different import styles working in different tools There's one invocation of require left here: https://github.com/elf-pavlik/data-model/blob/esm/lib/quad.js#L1 So I'm still getting "ReferenceError: require is not defined" I've created elf-pavlik#1 to fix this. |
Using import instead of require
Can we actually discuss removing default exports? With default export commonjs imports will need the additional const rdf = require('@rdfjs/data-model')
-rdf.default.blankNode()
+rdf.blankNode() |
I've just added commit removing all default exports in favor of using only named exports. Commonjs should be able to do const { DataFactory } = require('@rdfjs/data-model') |
fixed in #37 |
I open it to mostly to discuss distributing this library as an ES Module around concrete working PR
This PR makes this module available as ES Module, it relies on
esm
package explained here: https://medium.com/web-on-the-edge/tomorrows-es-modules-today-c53d29ac448cTODO