shexjs / shex.js

shex.js javascript package
MIT License
60 stars 17 forks source link

ShexJison error can't resolve 'fs' on solid-sdk-forms #75

Closed scenaristeur closed 4 years ago

scenaristeur commented 4 years ago

Windows 10, node v12.18.1 The second part of my issue seems to come from shexjs ? https://github.com/inrupt/solid-sdk-forms/issues/130#issue-661983839

I tried to install @shexjs/core & @shexjs/parser manually as dep of my project, but now, when i run 'npm run dev' with a webpack conf, i got


   ERROR in ./node_modules/@shexjs/parser/lib/ShExJison.js
   Module not found: Error: Can't resolve 'fs' in 'C:\Users\Smag\Documents\dev\shighl-elements\node_modules\@shexjs\parser\lib'
    @ ./node_modules/@shexjs/parser/lib/ShExJison.js 1852:17-30
    @ ./node_modules/@shexjs/parser/shex-parser.js
    @ ./node_modules/@inrupt/solid-sdk-forms/dist/solid-forms.es5.js
    @ ./src/shighl-crud.js
i 「wdm」: Failed to compile.
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'
ericprud commented 4 years ago

You probably want to copy the node webpack directives from https://github.com/shexSpec/shex.js/blob/master/webpack.config.js#L27

scenaristeur commented 4 years ago

Hi, i've give up with solid-sdk-form, i'm building mine, with your browserified version but I have another question : Loading remote shex is ok with

  window.shexLoader.load([f], [], [], []).then(loaded =...

but i also want to read & parse the schema of an uploaded file. with an <input type="file">

but how do i get the schema? with

    const reader = new FileReader()
       reader.onload = this.handleFileLoad;
       reader.readAsText(f)
ericprud commented 4 years ago

you want something like

const shexc = require('fs').readFileSync('test/cli/1dotOr2dotCLOSED.shex', 'utf8')
const parser = require('@shexjs/parser').construct('http://example.com/base/url/')
console.warn(parser.parse(shexc), null, 2)
scenaristeur commented 4 years ago

thxs, that folks ! https://scenaristeur.github.io/shighl-vuejs,

https://github.com/scenaristeur/shighl-vuejs/blob/f259dec1bc117533fb1e6d3cbf9b1cec188b0822/src/components/mixins/ShexMixin.js#L5