Skip to content

Commit

Permalink
🙈
Browse files Browse the repository at this point in the history
  • Loading branch information
kuitos committed Aug 1, 2019
1 parent a40bb44 commit c6a4cef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ example/bundle.js.map
lib/
esm/
node_modules/
dist
yarn.lock
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"build:dist": "rm -fr ./lib && webpack --env.minimize --display normal && webpack --display normal",
"build:esm": "rm -fr ./esm && babel ./src --out-dir ./esm --ignore 'src/**/__tests__/**/*.js'",
"prepush": "npm run lint",
"release": "np --no-cleanup --yolo --no-publish",
"test": "jest --no-cache"
},
"repository": {
Expand Down Expand Up @@ -51,6 +52,7 @@
"babel-loader": "^8.0.2",
"husky": "^1.3.1",
"jest": "^23.6.0",
"np": "^5.0.3",
"regenerator-runtime": "^0.13.1",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0"
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ function execScripts(entry, scripts, proxy = window) {
noteGlobalProps();

try {
geval(`;(function(window){;${inlineScript}\n})(window.proxy);`);
// bind window.proxy to change `this` reference in script
geval(`;(function(window){;${inlineScript}\n}).bind(window.proxy)(window.proxy);`);
} catch (e) {
console.error(`error occurs while executing the entry ${scriptSrc}`);
console.error(e);
Expand All @@ -105,7 +106,8 @@ function execScripts(entry, scripts, proxy = window) {

} else {
try {
geval(`;(function(window){;${inlineScript}\n})(window.proxy);`);
// bind window.proxy to change `this` reference in script
geval(`;(function(window){;${inlineScript}\n}).bind(window.proxy)(window.proxy);`);
} catch (e) {
console.error(`error occurs while executing ${scriptSrc}`);
console.error(e);
Expand Down

0 comments on commit c6a4cef

Please sign in to comment.