Bug #4639
closedSaxonJS in Electron appears non-standard.
100%
Updated by Grant Vergottini over 4 years ago
I don’t know where my description disappeared to.
I am finding the require(‘saxon-js’) does not work as expected in a node.js service within electron.
In a normal node.js environment, this works:
const SaxonJS = require(‘saxon-js’); // SaxonJS = an object with methods
However, in Electron, the exact same code results in SaxonJS being just the empty object {}.
In experimenting, I discovered that:
const foobar = require(‘saxon-js’); // SaxonJS is assigned properly somehow, foobar = undefined
Or even just:
require(‘saxon-js’); // SaxonJS is assigned properly somehow
would result in the SaxonJS object magically being defined. It appears that, at least in Electron’s way of scoping variables, the SaxonJS object is globally defined within the require() and that the assignment to an external constant of the same name mucks things up in a way that causes the resulting SaxonJS object to be an empty object
Updated by Debbie Lockett over 4 years ago
- Project changed from Saxon to SaxonJS
Thanks for logging this issue. We have no experience of Electron, but will certainly need to investigate this.
Updated by Debbie Lockett over 4 years ago
As suggested, we are indeed declaring SaxonJS as a global variable internally, as well as adding it to module.exports; and I can believe that this is the cause of the problem.
I'm currently testing changes to remove the global variable, to check for regression. (Running our usual browser and Node.js test suite test drivers, and Mocha test suites).
I haven't actually tested anything in Electron though.
Updated by Debbie Lockett over 4 years ago
- Status changed from New to In Progress
Changes committed to remove the SaxonJS
global variable declaration in externs, and use the platform.expose
method to expose the SaxonJS
object as required (i.e. add to module.exports
on Node.js, and add to window
object as global variable in browser).
Hopefully this is a fix for the bugs #4639, #4669. Still need to do some more testing to confirm.
Updated by Debbie Lockett over 4 years ago
Code changes reverted. The changes had caused our W3C test driver to break when running on Node.js, because it assumes that SaxonJS
is a global. We need to rethink this.
Updated by Norm Tovey-Walsh almost 4 years ago
- Status changed from In Progress to Resolved
The SaxonJS internals have been adjusted so that they neither create nor rely on a global "SaxonJS" object. I was able to construct a small Electron application and demonstrate that SaxonJS could be loaded with require()
.
Updated by Norm Tovey-Walsh over 3 years ago
- Status changed from Resolved to Closed
This issue has been resolved in the Saxon 2.2 maintenance release.
Updated by Debbie Lockett over 3 years ago
- % Done changed from 0 to 100
- Fixed in JS Release set to Saxon-JS 2.2
- Fix Committed on JS Branch 2 added
Please register to edit this issue
Also available in: Atom PDF Tracking page