From a6d44038133bede19549c07d7f527b8da3a80ede Mon Sep 17 00:00:00 2001 From: David-Emmanuel DIVERNOIS Date: Tue, 1 Apr 2025 15:52:22 +0200 Subject: [PATCH] Move platform code to index so that lib/jsonld is platform-independent --- lib/index.js | 6 +++++- lib/jsonld.js | 4 ---- package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 93a12da4..1b6ea48e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,4 +5,8 @@ * * Copyright 2010-2021 Digital Bazaar, Inc. */ -module.exports = require('./jsonld'); +const platform = require('./platform'); +const jsonld = require('./jsonld'); +platform.setupGlobals(jsonld); +platform.setupDocumentLoaders(jsonld); +module.exports = jsonld; diff --git a/lib/jsonld.js b/lib/jsonld.js index c6931aeb..5a24944c 100644 --- a/lib/jsonld.js +++ b/lib/jsonld.js @@ -34,7 +34,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ const canonize = require('rdf-canonize'); -const platform = require('./platform'); const util = require('./util'); const ContextResolver = require('./ContextResolver'); const IdentifierIssuer = util.IdentifierIssuer; @@ -1024,9 +1023,6 @@ jsonld.RequestQueue = require('./RequestQueue'); /* WebIDL API */ jsonld.JsonLdProcessor = require('./JsonLdProcessor')(jsonld); -platform.setupGlobals(jsonld); -platform.setupDocumentLoaders(jsonld); - function _setDefaults(options, { documentLoader = jsonld.documentLoader, ...defaults diff --git a/package.json b/package.json index facc56b5..381f1682 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,7 @@ ] }, "browser": { - "./lib/index.js": "./lib/jsonld.js", + "./lib/index.js": "./lib/index.js", "./lib/platform.js": "./lib/platform-browser.js", "crypto": false, "http": false,