Switch Library Type from CommonJs2 => UMD ( (#135)

Co-authored-by: Peter Krieg <pkrieg2@gmail.com>
This commit is contained in:
Rick van Lieshout 2021-12-08 17:37:44 +01:00 committed by GitHub
parent 9a0c974b2a
commit 719bb2f496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 743 additions and 721 deletions

View File

@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [[7.0.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.1)]
- Switched from CommonJS to UMD module
## [[6.4.1](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.1))] ## [[6.4.1](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/6.4.1))]
- Added missing typing - Added missing typing

View File

@ -1,5 +1,14 @@
/*! For license information please see index.js.LICENSE.txt */ /*! For license information please see index.js.LICENSE.txt */
!(function () { !(function (e, t) {
"object" == typeof exports && "object" == typeof module
? (module.exports = t())
: "function" == typeof define && define.amd
? define([], t)
: "object" == typeof exports
? (exports.ReactCookieConsent = t())
: (e.ReactCookieConsent = t());
})(self, function () {
return (function () {
var e = { var e = {
808: function (e, t, n) { 808: function (e, t, n) {
var o, r, i; var o, r, i;
@ -171,7 +180,8 @@
Object.defineProperty(e, "__esModule", { value: !0 }); Object.defineProperty(e, "__esModule", { value: !0 });
}); });
var o = {}; var o = {};
!(function () { return (
(function () {
"use strict"; "use strict";
n.r(o), n.r(o),
n.d(o, { n.d(o, {
@ -308,19 +318,19 @@
g = { STRICT: "strict", LAX: "lax", NONE: "none" }, g = { STRICT: "strict", LAX: "lax", NONE: "none" },
S = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" }, S = { HIDDEN: "hidden", SHOW: "show", BY_COOKIE_VALUE: "byCookieValue" },
C = function () { C = function () {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : w, var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : j,
t = l().get(e); t = l().get(e);
return void 0 === t && (t = l().get(x(e))), t; return void 0 === t && (t = l().get(x(e))), t;
}, },
k = function () { k = function () {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : w; var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : j;
l().remove(e); l().remove(e);
}, },
x = function (e) { x = function (e) {
return "".concat(e, "-legacy"); return "".concat(e, "-legacy");
}, },
w = "CookieConsent", j = "CookieConsent",
j = function (e) { w = function (e) {
var t = e.condition, var t = e.condition,
n = e.wrapper, n = e.wrapper,
o = e.children; o = e.children;
@ -347,7 +357,10 @@
if ("function" == typeof Proxy) return !0; if ("function" == typeof Proxy) return !0;
try { try {
return ( return (
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0 Boolean.prototype.valueOf.call(
Reflect.construct(Boolean, [], function () {})
),
!0
); );
} catch (e) { } catch (e) {
return !1; return !1;
@ -524,7 +537,7 @@
C = n.disableButtonStyles, C = n.disableButtonStyles,
k = n.enableDeclineButton, k = n.enableDeclineButton,
x = n.flipButtons, x = n.flipButtons,
w = n.ButtonComponent, j = n.ButtonComponent,
T = n.overlay, T = n.overlay,
B = n.overlayClasses, B = n.overlayClasses,
E = n.overlayStyle, E = n.overlayStyle,
@ -533,18 +546,18 @@
I = {}, I = {},
_ = {}, _ = {},
N = {}, N = {},
A = {}, R = {},
L = {}; A = {};
switch ( switch (
(a (a
? ((I = u({}, r)), ? ((I = u({}, r)),
(_ = u({}, i)), (_ = u({}, i)),
(N = u({}, c)), (N = u({}, c)),
(A = u({}, l)), (R = u({}, l)),
(L = u({}, E))) (A = u({}, E)))
: ((I = u({}, f(f({}, this.state.style), r))), : ((I = u({}, f(f({}, this.state.style), r))),
(A = u({}, f(f({}, this.state.contentStyle), l))), (R = u({}, f(f({}, this.state.contentStyle), l))),
(L = u({}, f(f({}, this.state.overlayStyle), E))), (A = u({}, f(f({}, this.state.overlayStyle), E))),
C C
? ((_ = u({}, i)), (N = u({}, c))) ? ((_ = u({}, i)), (N = u({}, c)))
: ((_ = u({}, f(f({}, this.state.buttonStyle), i))), : ((_ = u({}, f(f({}, this.state.buttonStyle), i))),
@ -557,12 +570,12 @@
case m.BOTTOM: case m.BOTTOM:
I.bottom = "0"; I.bottom = "0";
} }
var R = []; var L = [];
return ( return (
k && k &&
R.push( L.push(
t().createElement( t().createElement(
w, j,
{ {
key: "declineButton", key: "declineButton",
style: N, style: N,
@ -576,9 +589,9 @@
p p
) )
), ),
R.push( L.push(
t().createElement( t().createElement(
w, j,
{ {
key: "acceptButton", key: "acceptButton",
style: _, style: _,
@ -592,23 +605,23 @@
s s
) )
), ),
x && R.reverse(), x && L.reverse(),
t().createElement( t().createElement(
j, w,
{ {
condition: T, condition: T,
wrapper: function (e) { wrapper: function (e) {
return t().createElement("div", { style: L, className: B }, e); return t().createElement("div", { style: A, className: B }, e);
}, },
}, },
t().createElement( t().createElement(
"div", "div",
{ className: "".concat(d), style: I }, { className: "".concat(d), style: I },
t().createElement("div", { style: A, className: b }, this.props.children), t().createElement("div", { style: R, className: b }, this.props.children),
t().createElement( t().createElement(
"div", "div",
{ className: "".concat(v) }, { className: "".concat(v) },
R.map(function (e) { L.map(function (e) {
return e; return e;
}) })
) )
@ -684,7 +697,7 @@
visible: S.BY_COOKIE_VALUE, visible: S.BY_COOKIE_VALUE,
onAccept: function () {}, onAccept: function () {},
onDecline: function () {}, onDecline: function () {},
cookieName: w, cookieName: j,
cookieValue: !0, cookieValue: !0,
declineCookieValue: !1, declineCookieValue: !1,
setDeclineCookie: !0, setDeclineCookie: !0,
@ -739,5 +752,7 @@
}); });
const B = T; const B = T;
})(), })(),
(module.exports = o); o
})(); );
})();
});

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{ {
"name": "react-cookie-consent", "name": "react-cookie-consent",
"version": "6.4.1", "version": "7.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"version": "6.4.1", "version": "7.0.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"js-cookie": "^2.2.1", "js-cookie": "^2.2.1",

View File

@ -4,7 +4,7 @@
"name": "Rick van Lieshout", "name": "Rick van Lieshout",
"email": "info@rickvanlieshout.com" "email": "info@rickvanlieshout.com"
}, },
"version": "6.4.1", "version": "7.0.0",
"description": "A small, simple and customizable cookie consent bar for use in React applications.", "description": "A small, simple and customizable cookie consent bar for use in React applications.",
"main": "build/index.js", "main": "build/index.js",
"types": "build/index.d.ts", "types": "build/index.d.ts",

View File

@ -6,7 +6,10 @@ module.exports = {
output: { output: {
path: path.resolve(__dirname, "build"), path: path.resolve(__dirname, "build"),
filename: "index.js", filename: "index.js",
libraryTarget: "commonjs2", // THIS IS THE MOST IMPORTANT LINE! :mindblow: I wasted more than 2 days until realize this was the line most important in all this guide. library: {
name: "ReactCookieConsent",
type: "umd",
},
environment: { environment: {
arrowFunction: false, // the generated runtime-code should not use arrow functions arrowFunction: false, // the generated runtime-code should not use arrow functions
}, },
@ -16,7 +19,7 @@ module.exports = {
{ {
test: /\.js$/, test: /\.js$/,
include: path.resolve(__dirname, "src"), include: path.resolve(__dirname, "src"),
exclude: /(node_modules|bower_components|build)/, exclude: /(node_modules|build)/,
use: { use: {
loader: "babel-loader", loader: "babel-loader",
options: { options: {