Project

Profile

Help

Bug #4639

SaxonJS in Electron appears non-standard.

Added by Grant Vergottini 7 months ago. Updated 4 months ago.

Status:
In Progress
Priority:
Low
Category:
-
Sprint/Milestone:
-
Start date:
2020-07-10
Due date:
% Done:

0%

Estimated time:
Applies to JS Branch:
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Company:
-
Contact person:
-
Additional contact persons:
-

History

#1 Updated by Michael Kay 7 months ago

Could you expand on this please?

#2 Updated by Grant Vergottini 7 months 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

#3 Updated by Debbie Lockett 7 months ago

  • Project changed from Saxon to Saxon-JS

Thanks for logging this issue. We have no experience of Electron, but will certainly need to investigate this.

#4 Updated by Debbie Lockett 6 months 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.

#5 Updated by Debbie Lockett 5 months 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.

#6 Updated by Debbie Lockett 4 months ago

  • Assignee set to Debbie Lockett

#7 Updated by Debbie Lockett 4 months 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.

Please register to edit this issue

Also available in: Atom PDF Tracking page