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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 0 additions & 160 deletions dist/rdf-data-model.js

This file was deleted.

6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var DataFactory = require('./lib/data-factory')

module.exports = DataFactory
// Set options as a parameter, environment variable, or rc file.
require = require('esm')(module/*, options */) // eslint-disable-line
module.exports = require('./main.js')
2 changes: 1 addition & 1 deletion lib/blank-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ BlankNode.prototype.termType = 'BlankNode'

BlankNode.nextId = 0

module.exports = BlankNode
export default BlankNode
14 changes: 7 additions & 7 deletions lib/data-factory.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var BlankNode = require('./blank-node')
var DefaultGraph = require('./default-graph')
var Literal = require('./literal')
var NamedNode = require('./named-node')
var Quad = require('./quad')
var Variable = require('./variable')
import BlankNode from './blank-node'
import DefaultGraph from './default-graph'
import Literal from './literal'
import NamedNode from './named-node'
import Quad from './quad'
import Variable from './variable'

function DataFactory () {}

Expand Down Expand Up @@ -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'

2 changes: 1 addition & 1 deletion lib/default-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ DefaultGraph.prototype.equals = function (other) {

DefaultGraph.prototype.termType = 'DefaultGraph'

module.exports = DefaultGraph
export default DefaultGraph
4 changes: 2 additions & 2 deletions lib/literal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var NamedNode = require('./named-node')
import NamedNode from './named-node'

function Literal (value, language, datatype) {
this.value = value
Expand All @@ -22,4 +22,4 @@ Literal.prototype.termType = 'Literal'
Literal.langStringDatatype = new NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#langString')
Literal.stringDatatype = new NamedNode('http://www.w3.org/2001/XMLSchema#string')

module.exports = Literal
export default Literal
2 changes: 1 addition & 1 deletion lib/named-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ NamedNode.prototype.equals = function (other) {

NamedNode.prototype.termType = 'NamedNode'

module.exports = NamedNode
export default NamedNode
2 changes: 1 addition & 1 deletion lib/quad.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Quad.prototype.equals = function (other) {
other.object.equals(this.object) && other.graph.equals(this.graph)
}

module.exports = Quad
export default Quad
2 changes: 1 addition & 1 deletion lib/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Variable.prototype.equals = function (other) {

Variable.prototype.termType = 'Variable'

module.exports = Variable
export default Variable
3 changes: 3 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DataFactory from './lib/data-factory'

export default DataFactory
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"version": "1.1.1",
"description": "A basic implementation of the RDFJS Data Model",
"main": "index.js",
"module": "main.js",
"scripts": {
"build-dist": "browserify index.js --standalone rdf --outfile dist/rdf-data-model.js",
"lint": "standard *.js bin/*.js lib/*.js test/*.js",
"prepublish": "npm run build-dist",
"test": "npm run lint && mocha"
"test": "npm run lint && mocha -r esm"
},
"bin": {
"rdfjs-data-model-test": "./bin/test.js"
Expand All @@ -29,10 +28,10 @@
},
"homepage": "https://github.com/rdfjs/data-model",
"dependencies": {
"@types/rdf-js": "^2.0.1"
"@types/rdf-js": "^2.0.1",
"esm": "^3.2.7"
},
"devDependencies": {
"browserify": "^16.2.2",
"mocha": "^5.2.0",
"standard": "^11.0.1"
},
Expand Down
4 changes: 2 additions & 2 deletions test/blank-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global describe, it */

var assert = require('assert')
import assert from 'assert'

function runTests (DataFactory) {
describe('.blankNode', function () {
Expand Down Expand Up @@ -71,4 +71,4 @@ function runTests (DataFactory) {
})
}

module.exports = runTests
export default runTests
4 changes: 2 additions & 2 deletions test/default-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global describe, it */

var assert = require('assert')
import assert from 'assert'

function runTests (DataFactory) {
describe('.defaultGraph', function () {
Expand Down Expand Up @@ -52,4 +52,4 @@ function runTests (DataFactory) {
})
}

module.exports = runTests
export default runTests
29 changes: 16 additions & 13 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
'use strict'
import namedNodeTest from './named-node'
import blankNodeTest from './blank-node'
import literalTest from './literal'
import defaultGraphTest from './default-graph'
import variableTest from './variable'
import tripleTest from './triple'
import quadTest from './quad'

function runTests (rdf) {
require('./named-node')(rdf)
require('./blank-node')(rdf)
require('./literal')(rdf)
require('./default-graph')(rdf)
require('./variable')(rdf)
require('./triple')(rdf)
require('./quad')(rdf)
function runTests (DataFactory) {
namedNodeTest(DataFactory)
blankNodeTest(DataFactory)
literalTest(DataFactory)
defaultGraphTest(DataFactory)
variableTest(DataFactory)
tripleTest(DataFactory)
quadTest(DataFactory)
}

if (global.rdf) {
runTests(global.rdf)
}

module.exports = runTests
export default runTests
4 changes: 2 additions & 2 deletions test/literal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global describe, it */

var assert = require('assert')
import assert from 'assert'

function runTests (DataFactory) {
describe('.literal', function () {
Expand Down Expand Up @@ -162,4 +162,4 @@ function runTests (DataFactory) {
})
}

module.exports = runTests
export default runTests
4 changes: 2 additions & 2 deletions test/named-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global describe, it */

var assert = require('assert')
import assert from 'assert'

function runTests (DataFactory) {
describe('.namedNode', function () {
Expand Down Expand Up @@ -66,4 +66,4 @@ function runTests (DataFactory) {
})
}

module.exports = runTests
export default runTests
4 changes: 2 additions & 2 deletions test/quad.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global describe, it */

var assert = require('assert')
import assert from 'assert'

function runTests (DataFactory) {
describe('.quad', function () {
Expand Down Expand Up @@ -106,4 +106,4 @@ function runTests (DataFactory) {
})
}

module.exports = runTests
export default runTests
5 changes: 3 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var rdf = require('..')
import DataFactory from '../index.js'
import runTests from './index.js'

require('.')(rdf)
runTests(DataFactory)
4 changes: 2 additions & 2 deletions test/triple.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global describe, it */

var assert = require('assert')
import assert from 'assert'

function runTests (DataFactory) {
describe('.triple', function () {
Expand Down Expand Up @@ -99,4 +99,4 @@ function runTests (DataFactory) {
})
}

module.exports = runTests
export default runTests
Loading