Socket
Socket
Sign inDemoInstall

mini-program-global-runtime-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-program-global-runtime-webpack-plugin - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

2

lib/index.js

@@ -6,5 +6,5 @@ const RuntimeGlobals = require("webpack").RuntimeGlobals;

class MiniProgramGlobalRuntimeWebpackPlugin {
reBuildGlobal = true;
constructor(options = {}) {
this.reBuildGlobal = true;
if (options && options.reBuildGlobal === false) {

@@ -11,0 +11,0 @@ this.reBuildGlobal = false;

@@ -8,8 +8,6 @@ "use strict";

class MiniProgramGlobalProperty extends RuntimeModule {
globalObject = "global";
constructor(globalObject) {
super("global");
this.globalObject = this.globalObject || globalObject;
this.globalObject = globalObject || "global";
}

@@ -16,0 +14,0 @@

@@ -1,2 +0,1 @@

"use strict";

@@ -10,42 +9,40 @@

class MiniProgramGlobalRuntimeModule extends RuntimeModule {
globalObject = "global";
constructor(globalObject) {
super("global");
constructor(globalObject) {
super("global");
this.globalObject = this.globalObject || globalObject;
}
this.globalObject = globalObject || "global";
}
/**
* @returns {string} runtime code
*/
generate() {
return Template.asString([
`${RuntimeGlobals.global} = (function() {`,
Template.indent([
"if (typeof globalThis === 'object') return globalThis;",
`if (typeof ${this.globalObject} === 'object') return ${this.globalObject};`,
"try {",
Template.indent(
// This works in non-strict mode
// or
// This works if eval is allowed (see CSP)
"return this || new Function('return this')();"
),
"} catch (e) {",
Template.indent(
// This works if the window reference is available
"if (typeof window === 'object') return window;"
),
"}"
// It can still be `undefined`, but nothing to do about it...
// We return `undefined`, instead of nothing here, so it's
// easier to handle this case:
// if (!global) { … }
]),
"})();"
]);
}
/**
* @returns {string} runtime code
*/
generate() {
return Template.asString([
`${RuntimeGlobals.global} = (function() {`,
Template.indent([
"if (typeof globalThis === 'object') return globalThis;",
`if (typeof ${this.globalObject} === 'object') return ${this.globalObject};`,
"try {",
Template.indent(
// This works in non-strict mode
// or
// This works if eval is allowed (see CSP)
"return this || new Function('return this')();",
),
"} catch (e) {",
Template.indent(
// This works if the window reference is available
"if (typeof window === 'object') return window;",
),
"}",
// It can still be `undefined`, but nothing to do about it...
// We return `undefined`, instead of nothing here, so it's
// easier to handle this case:
// if (!global) { … }
]),
"})();",
]);
}
}
module.exports = MiniProgramGlobalRuntimeModule;
{
"name": "mini-program-global-runtime-webpack-plugin",
"version": "0.0.6",
"version": "0.0.7",
"description": "生成小程序全局变量",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc