webpack-dynamic-require
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -16,2 +16,12 @@ "use strict"; | ||
g.webpackData = __webpack_require__; | ||
// webpack3 don't hava r function | ||
if (!__webpack_require__.r) { | ||
// define __esModule on exports | ||
__webpack_require__.r = function (exports) { | ||
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}; | ||
} | ||
} | ||
@@ -22,10 +32,14 @@ // else, try to access it using webpackJsonp (the function only seems to be available if CommonsChunkPlugin is used) | ||
if (webpackVersion == 1) { | ||
g.webpackJsonp([], { 0: function (module, exports, __webpack_require__) { | ||
g.webpackJsonp([], { | ||
0: function (module, exports, __webpack_require__) { | ||
g.webpackData = __webpack_require__; | ||
} }); | ||
} | ||
}); | ||
} | ||
else { | ||
g.webpackJsonp([], { 123456: function (module, exports, __webpack_require__) { | ||
g.webpackJsonp([], { | ||
123456: function (module, exports, __webpack_require__) { | ||
g.webpackData = __webpack_require__; | ||
} }, [123456]); | ||
} | ||
}, [123456]); | ||
} | ||
@@ -32,0 +46,0 @@ } |
{ | ||
"name": "webpack-dynamic-require", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "you can require cdn bundle dynamic", | ||
@@ -5,0 +5,0 @@ "main": "lib/Dynamic.js", |
@@ -1,3 +0,3 @@ | ||
import {GetModuleNameFromPath, GetModuleNameFromVarName} from "./Utils"; | ||
export {GetModuleNameFromPath, GetModuleNameFromVarName}; | ||
import { GetModuleNameFromPath, GetModuleNameFromVarName } from "./Utils"; | ||
export { GetModuleNameFromPath, GetModuleNameFromVarName }; | ||
@@ -11,3 +11,3 @@ declare var window: Window, global: any; | ||
declare var __webpack_require__ : any; | ||
declare var __webpack_require__: any; | ||
// if webpack-data was not explicitly specified prior to library import, try to find the data | ||
@@ -18,3 +18,13 @@ if (g.webpackData == null) { | ||
g.webpackData = __webpack_require__; | ||
// webpack3 don't hava r function | ||
if (!__webpack_require__.r) { | ||
// define __esModule on exports | ||
__webpack_require__.r = function (exports: any) { | ||
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}; | ||
} | ||
} | ||
// else, try to access it using webpackJsonp (the function only seems to be available if CommonsChunkPlugin is used) | ||
@@ -25,11 +35,15 @@ else if (g.webpackJsonp) { | ||
g.webpackJsonp([], | ||
{0: function(module: any, exports: any, __webpack_require__: any) { | ||
g.webpackData = __webpack_require__; | ||
}} | ||
{ | ||
0: function (module: any, exports: any, __webpack_require__: any) { | ||
g.webpackData = __webpack_require__; | ||
} | ||
} | ||
); | ||
} else { | ||
g.webpackJsonp([], | ||
{123456: function(module: any, exports: any, __webpack_require__: any) { | ||
g.webpackData = __webpack_require__; | ||
}}, | ||
{ | ||
123456: function (module: any, exports: any, __webpack_require__: any) { | ||
g.webpackData = __webpack_require__; | ||
} | ||
}, | ||
[123456] | ||
@@ -44,12 +58,13 @@ ); | ||
} | ||
} | ||
export var allModulesText: string; | ||
export var moduleIDs = {} as {[key: string]: number | string}; | ||
export var moduleNames = {} as {[key: number]: string; [key: string]: string;}; | ||
export var moduleIDs = {} as { [key: string]: number | string }; | ||
export var moduleNames = {} as { [key: number]: string;[key: string]: string; }; | ||
export function ParseModuleData(forceRefresh = false) { | ||
if (allModulesText != null && !forceRefresh) return; | ||
let moduleWrapperFuncs = Object.keys(g.webpackData.m).map(moduleID=>g.webpackData.m[moduleID]); | ||
allModulesText = moduleWrapperFuncs.map(a=>a.toString()).join("\n\n\n").replace(/\\"/g, `"`); | ||
let moduleWrapperFuncs = Object.keys(g.webpackData.m).map(moduleID => g.webpackData.m[moduleID]); | ||
allModulesText = moduleWrapperFuncs.map(a => a.toString()).join("\n\n\n").replace(/\\"/g, `"`); | ||
@@ -93,6 +108,6 @@ // these are examples of before and after webpack's transformation: (based on which the 1st regex below finds path-comments) | ||
MakeGlobal({allModulesText, moduleIDs, moduleNames}); | ||
MakeGlobal({ allModulesText, moduleIDs, moduleNames }); | ||
} | ||
const moduleCache : {[key: string]: any} = { | ||
const moduleCache: { [key: string]: any } = { | ||
}; | ||
@@ -115,3 +130,3 @@ | ||
MakeGlobal({GetIDForModule}); | ||
MakeGlobal({ GetIDForModule }); | ||
export function GetIDForModule(name: string) { | ||
@@ -122,3 +137,3 @@ ParseModuleData(); | ||
MakeGlobal({Require}); | ||
MakeGlobal({ Require }); | ||
export function Require(name: string) { | ||
@@ -125,0 +140,0 @@ if (name === undefined) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40262
816