-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgemstone-loader-json.js
More file actions
34 lines (27 loc) · 1021 Bytes
/
gemstone-loader-json.js
File metadata and controls
34 lines (27 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
** GemstoneJS -- Gemstone JavaScript Technology Stack
** Copyright (c) 2016-2019 Gemstone Project <http://gemstonejs.com>
** Licensed under Apache License 2.0 <https://spdx.org/licenses/Apache-2.0>
*/
/* load external requirements */
const loaderUtils = require("loader-utils")
/* the exported Webpack loader function */
module.exports = function (content) {
/* determine Webpack loader query parameters */
const options = Object.assign({}, {
}, loaderUtils.getOptions(this), this.resourceQuery ? loaderUtils.parseQuery(this.resourceQuery) : null)
void (options)
/* indicate to Webpack that our results are
fully deterministic and can be cached */
this.cacheable(true)
/* parse JSON */
try {
content = JSON.parse(content)
}
catch (ex) {
this.emitError(`gemstone-loader-json: [JSON]: ERROR: ${ex}`)
}
/* export result as a JavaScript string */
content = `module.exports = ${JSON.stringify(content)}`
return content
}