Using libxml-xsd in an electronic application fails with binding errors

I would like to validate an XML file based on its schema in an electronic application.

I have an angular2 service that works before including my libxml-xsd require statement. As soon as I add this to the top of my utility file:

const xsd = require('libxml-xsd');

I run npm run buildthat executes this:

webpack --progress --profile --colors --display-error-details --display-cached

I see the following new output warnings:

WARNING in ./~/bindings/bindings.js
Critical dependencies:
76:22-40 the request of a dependency is an expression
76:43-53 the request of a dependency is an expression
 @ ./~/bindings/bindings.js 76:22-40 76:43-53

WARNING in ./~/bindings/README.md
Module parse failed: /Users/myusername/Documents/Personal/MyApp/node_modules/bindings/README.md Unexpected token (2:3)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:3)
    at Parser.pp$4.raise (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp$3.parseExprAtom (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1822:12)
    at Parser.pp$3.parseExprSubscripts (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1715:21)
    at Parser.pp$3.parseMaybeUnary (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1692:19)
    at Parser.pp$3.parseExprOp (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1656:43)
    at Parser.pp$3.parseExprOp (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1658:21)
    at Parser.pp$3.parseExprOps (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1639:17)
    at Parser.pp$3.parseMaybeConditional (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1620:21)
    at Parser.pp$3.parseMaybeAssign (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1597:21)
    at Parser.pp$3.parseExpression (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:1573:21)
    at Parser.pp$1.parseStatement (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:727:47)
    at Parser.pp$1.parseTopLevel (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:638:25)
    at Parser.parse (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:516:17)
    at Object.parse (/Users/myusername/Documents/Personal/MyApp/node_modules/acorn/dist/acorn.js:3098:39)
    at Parser.parse (/Users/myusername/Documents/Personal/MyApp/node_modules/webpack/lib/Parser.js:902:15)
    at DependenciesBlock.<anonymous> (/Users/myusername/Documents/Personal/MyApp/node_modules/webpack/lib/NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (/Users/myusername/Documents/Personal/MyApp/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
    at nextLoader (/Users/myusername/Documents/Personal/MyApp/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
    at /Users/myusername/Documents/Personal/MyApp/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
    at Storage.finished (/Users/myusername/Documents/Personal/MyApp/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
    at /Users/myusername/Documents/Personal/MyApp/node_modules/graceful-fs/graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:446:3)
 @ ./~/bindings ^\.\/.*$

Then I launched my application by doing:, electron main.jswhich then throws this error in the browser console:

Uncaught Error: Could not locate the bindings file. Tried:
 → /Users/myusername/Documents/Personal/MyApp/build/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/build/Debug/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/build/Release/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/out/Debug/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/Debug/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/out/Release/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/Release/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/build/default/xmljs.node
 → /Users/myusername/Documents/Personal/MyApp/compiled/6.5.0/darwin/x64/xmljs.node

Can someone help me run libxml-xsd under my application configuration? Does this have anything to do with webpack? If so, how can I change its configuration to bring it to the appropriate files?

+4
2

bindings.js GitHub.

WebPack

module.exports = {
  plugins: [
    new webpack.IgnorePlugin(/^mock-firmata$/),
    new webpack.ContextReplacementPlugin(/bindings$/, /^$/)
  ],
  externals: ["bindings"]
}

, libxml-xsd . , . , require('fs');, .

+1

, asar-unpack asar-unpack-dir , .

, , . API asar-unpack-dir glob. ( asar, , , .)

+1

Source: https://habr.com/ru/post/1681688/


All Articles