Open KonradHoeffner opened 2 years ago
When using import { Namespace, graph, sym, parse, SPARQLToQuery } from "rdflib";
instead of import * as rdf from "rdflib"
, it still doesn't work with npm run dev
, however it works with npm run build && npm run preview
on Vite!
They scripts are defined in package.json as:
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
The problem still occurs with Vite v2.9.5 and rdflib 2.2.19.
$ npm create vite@latest
$ cd vite-project
$ npm install rdflib rollup-plugin-node-globals
Then create vite.config.js
as defined in the original post and add the following to main.js
:
import * as rdf from "rdflib";
const RDF = rdf.Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
Then run npm run build
:
> vite-project@0.0.0 build
> vite build
vite v2.9.5 building for production...
✓ 195 modules transformed.
'default' is not exported by node_modules/queue-microtask/index.js, imported by node_modules/n3/src/N3Lexer.js
file: /tmp/vite-project/node_modules/n3/src/N3Lexer.js:3:7
1: // **N3Lexer** tokenizes N3 documents.
2: import namespaces from './IRIs';
3: import queueMicrotask from 'queue-microtask';
^
4:
5: const { xsd } = namespaces;
error during build:
Error: 'default' is not exported by node_modules/queue-microtask/index.js, imported by node_modules/n3/src/N3Lexer.js
at error (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:198:30)
at Module.error (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:12521:16)
at Module.traceVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:12879:29)
at ModuleScope.findVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:11509:39)
at ChildScope.findVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:6477:38)
at ClassBodyScope.findVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:6477:38)
at ChildScope.findVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:6477:38)
at FunctionScope.findVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:6477:38)
at ChildScope.findVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:6477:38)
at TrackingScope.findVariable (/tmp/vite-project/node_modules/rollup/dist/shared/rollup.js:6477:38)
Has anyone successfully used this library in the browser with Vite? In my own attempt using vite 2.6.4, there was first an "global is not defined" error but after fixing that, using the following
vite.config.js
, I now get the errorUncaught SyntaxError: import not found: default N3Lexer.js:3:7
.vite.config.js
Code
Error from npm run build