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

[WIP] move to esm #15

Closed
wants to merge 4 commits into from
Closed

[WIP] move to esm #15

wants to merge 4 commits into from

Conversation

elf-pavlik
Copy link

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-c53d29ac448c

TODO

  • bin/test.js

@@ -45,4 +45,4 @@ DataFactory.quad = function (subject, predicate, object, graph) {

DataFactory.defaultGraphInstance = new DefaultGraph()

module.exports = DataFactory
export default DataFactory
Copy link

@tpluscode tpluscode Apr 24, 2020

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'

@tpluscode
Copy link

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

@elf-pavlik
Copy link
Author

Hi @tpluscode

I think that a recent esm issue may complicate things. It made me lock my node version to v12.15

standard-things/esm#868

It also gave me impression that no one actively maintains esm module 😢

@tpluscode
Copy link

Interesting. I have not seen that error myself. Have you?

@elf-pavlik
Copy link
Author

Yes, I've stumbled on similar error when using latest node LTS and found that github issue through that.

@retog
Copy link

retog commented Apr 29, 2020

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
@tpluscode
Copy link

Can we actually discuss removing default exports?

With default export commonjs imports will need the additional default

const rdf = require('@rdfjs/data-model')

-rdf.default.blankNode()
+rdf.blankNode()

@elf-pavlik
Copy link
Author

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')

@bergos
Copy link
Contributor

bergos commented Dec 29, 2021

fixed in #37

@bergos bergos closed this Dec 29, 2021
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

Successfully merging this pull request may close these issues.

4 participants