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

Usage in vanilla JavaScript #4

Closed
namedgraph opened this issue Jan 12, 2019 · 2 comments
Closed

Usage in vanilla JavaScript #4

namedgraph opened this issue Jan 12, 2019 · 2 comments

Comments

@namedgraph
Copy link

As I understand, the example uses require() from Node.js:

const ParserN3 = require('@rdfjs/parser-n3')
const Readable = require('stream').Readable

Does this project depend Node.js or can it be used from plain vanilla JS as well? I think it should be clarified.

@tpluscode
Copy link
Contributor

tpluscode commented Jan 17, 2019

Yes, this and other rdfjs packages are modularised using commonjs. It is natively supported by nodejs but unfortunately not understood by browsers which now all support Modules (import and export)

Does this project depend Node.js or can it be used from plain vanilla JS as well?

That does not mean that rdfjs packages are not usable in browser environment. There are multiple tools which make is possible to combine the two module systems:

  1. most popular webpack
  2. slightly different rollup
  3. an older and aptly named browserify

@elf-pavlik
Copy link

elf-pavlik commented Mar 1, 2019

I made PR to different repo which provides a pattern for distributing native ES modules and having nodejs compatibility via esm module: rdfjs-base/data-model#15
If it lands there I could make similar PRs to other repositories.
This still works well with various bundlers at the same time allowing simple import and <script type="module">

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

No branches or pull requests

4 participants