Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

v3.0.83+ looks to be incompatible with "strict mode" #607

Closed
antongolub opened this issue Sep 25, 2018 · 1 comment
Closed

v3.0.83+ looks to be incompatible with "strict mode" #607

antongolub opened this issue Sep 25, 2018 · 1 comment
Labels

Comments

@antongolub
Copy link

antongolub commented Sep 25, 2018

Hi there.

node -r esm --use-strict

produces:

node_modules/esm/esm.js:1
const __global__ = this;(function (require, module, __jest__, __shared__) { "use strict";var __shared__;const e=module,t={Array:global.Array,Buffer:global.Buffer,Error:global.Error,EvalError:global.EvalError,Function:global.Function,JSON:global.JSON,Object:global.Object,Promise:global.Promise,RangeError:global.RangeError,ReferenceError:global.ReferenceError,Reflect:global.Reflect,SyntaxError:global.SyntaxError,TypeError:global.TypeError,URIError:global.URIError,eval:global.eval},r=global.console;module.exports=(function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.d=function(e,t,r){Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,get:r})},r.n=function(e){return e.a=e,()=>e.a},r.r=function(){},r(r.s=2)})([(function(e,t){var r;t=e.exports=H,"object"==typeof process&&process,r=function(){},t.SEMVER_SPEC_VERSION="2.0.0";var i=256,n=N

TypeError: Cannot read property 'Array' of undefined
    at /Users/antongolub/projects/homepage/node_modules/esm/esm.js:1:136
    at I (/Users/antongolub/projects/homepage/node_modules/esm/esm.js:11:23)

because of:

const globalThis = (function () {
  return this
})()

which returns undefined.

The previous impl looks worse but works fine:

Function('return this')()

NodeJS v10.7.0
esm v3.0.83

@jdalton jdalton added the bug label Sep 25, 2018
@jdalton
Copy link
Member

jdalton commented Sep 25, 2018

Thanks @antongolub!

I avoided Function('return this')() because it can trip CSP unsafe-eval errors in Electron. I believe 95e43be should tackle both 🙃

jdalton added a commit that referenced this issue Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants