From 62098530b1705e173966e4a962cfc6ebb6d9b06c Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Wed, 7 Aug 2019 12:49:06 +0200 Subject: [PATCH] Only allow commonjs modules in external dependencies --- packages/notification/rollup.config.js | 4 +++- packages/notification/src/utils.js | 21 ++++++++----------- packages/notification/src/vpu-notification.js | 4 ++-- packages/notification/vendor/common | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/notification/rollup.config.js b/packages/notification/rollup.config.js index 3c158bf9..5b589a6b 100644 --- a/packages/notification/rollup.config.js +++ b/packages/notification/rollup.config.js @@ -20,7 +20,9 @@ export default { plugins: [ multiEntry(), resolve(), - commonjs(), + commonjs({ + include: 'node_modules/**' + }), json(), replace({ "process.env.BUILD": '"' + build + '"', diff --git a/packages/notification/src/utils.js b/packages/notification/src/utils.js index 15874eb6..92d5ba98 100644 --- a/packages/notification/src/utils.js +++ b/packages/notification/src/utils.js @@ -1,13 +1,10 @@ +export const createUUID = () => { + let dt = new Date().getTime(); + const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + const r = (dt + Math.random()*16)%16 | 0; + dt = Math.floor(dt/16); + return (c==='x' ? r :(r&0x3|0x8)).toString(16); + }); -module.exports = { - createUUID: () => { - let dt = new Date().getTime(); - const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { - const r = (dt + Math.random()*16)%16 | 0; - dt = Math.floor(dt/16); - return (c==='x' ? r :(r&0x3|0x8)).toString(16); - }); - - return uuid; - } -}; + return uuid; +} diff --git a/packages/notification/src/vpu-notification.js b/packages/notification/src/vpu-notification.js index 14db6245..c95fa4b3 100644 --- a/packages/notification/src/vpu-notification.js +++ b/packages/notification/src/vpu-notification.js @@ -1,5 +1,5 @@ import {i18n} from './i18n'; -import utils from './utils' +import {createUUID} from './utils' import {html} from 'lit-element'; import VPULitElement from 'vpu-common/vpu-lit-element'; import commonUtils from 'vpu-common/utils'; @@ -33,7 +33,7 @@ class VPUNotification extends VPULitElement { } that.notificationBlock = that._("#notification"); - const notificationId = `notification-${utils.createUUID()}`; + const notificationId = `notification-${createUUID()}`; const type = typeof e.detail.type !== 'undefined' ? e.detail.type : "info"; const body = typeof e.detail.body !== 'undefined' ? e.detail.body : ""; diff --git a/packages/notification/vendor/common b/packages/notification/vendor/common index 3623e0d1..b30eaa64 160000 --- a/packages/notification/vendor/common +++ b/packages/notification/vendor/common @@ -1 +1 @@ -Subproject commit 3623e0d1d062c1048ee37ac779d9425b56ffe26b +Subproject commit b30eaa6475ccc65b5f99d2ead86ddbe2b8e015a7 -- GitLab