Skip to content

Commit 5164769

Browse files
VinnlRubenVerborgh
authored andcommitted
Add a default export
When importing n3 from an ES module in Node, the exports will be treated as a default export, because the package itself is not an ES module. This _actually_ exports that default module, so that the same syntax (i.e. importing the default export) can be used with both Node and bundlers.
1 parent 5a48a33 commit 5164769

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
termToId,
2323
} from './N3DataFactory';
2424

25+
// Named exports
2526
export {
2627
Lexer,
2728
Parser,
@@ -45,3 +46,28 @@ export {
4546
termFromId,
4647
termToId,
4748
};
49+
50+
// Export all named exports as a default object for backward compatibility
51+
export default {
52+
Lexer,
53+
Parser,
54+
Writer,
55+
Store,
56+
StreamParser,
57+
StreamWriter,
58+
Util,
59+
60+
DataFactory,
61+
62+
Term,
63+
NamedNode,
64+
Literal,
65+
BlankNode,
66+
Variable,
67+
DefaultGraph,
68+
Quad,
69+
Triple,
70+
71+
termFromId,
72+
termToId,
73+
};

0 commit comments

Comments
 (0)