Skip to content

Commit

Permalink
Update bundling mechanism for globals injection caching
Browse files Browse the repository at this point in the history
This contains the required changes for the openhab-js injection caching inside the JS Scripting addon.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed Jan 1, 2023
1 parent 6c6433b commit 7c7588e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# WARNING: Please keep in mind that npm disregards .gitignore when there is a .npmignore file!

@openhab-globals.js
.github
.vscode
.idea
.markdownlint.yaml
.vscode
coverage
DEPLOY.md
doc
Expand All @@ -14,4 +16,4 @@ jest.config.js
openhab-*.tgz
out
test
.markdownlint.yaml

8 changes: 8 additions & 0 deletions @openhab-globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Injection of openhab-js namespaces as globals inside the addon

(function (global) {
'use strict';
Object.assign(globalThis, require('./index'));
// Support legacy NodeJS libraries
globalThis.global = globalThis;
})(this);
13 changes: 9 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
const path = require('path');

module.exports = {
entry: './index.js',
mode: 'development',
entry: './@openhab-globals.js',
mode: 'production',
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
externals: [
{
'@runtime': {
Expand Down Expand Up @@ -45,9 +50,9 @@ module.exports = {
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'openhab.js',
filename: '@openhab-globals.js',
library: {
name: 'openhab',
name: '@openhab-globals',
type: 'umd'
},
globalObject: 'this'
Expand Down

0 comments on commit 7c7588e

Please sign in to comment.