Code Monkey home page Code Monkey logo

Comments (17)

sobrinho avatar sobrinho commented on May 24, 2024 2

Yep! jeffijoe/awilix#286

from es5-shim.

sobrinho avatar sobrinho commented on May 24, 2024 1

Let me build an example and get back to you.

from es5-shim.

sobrinho avatar sobrinho commented on May 24, 2024 1

https://github.com/sobrinho/es5-shim-480

You can run yarn run serve and access localhost:8080 and open the inspector.

If you remove the es5-shim from the public/index.html, it works just fine.

It is all standard files generated by npx @vue-cli create example and selected Vue2 and JS, added awilix, created a dummy container and then added es5-shim.

I don't think it is related to the Vue or Awilix itself, it is about something that Awilix is doing and Babel is trying to compile.

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024 1

Note that this app crashes immediately in Safari, because Error.captureStackTrace is a nonstandard chrome-only API.

I can definitely reproduce this in Chrome, and will continue to look into the error. It's also possible it's coming from webpack 5, and I've asked them about it as well.

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024 1

Looks like jeffijoe/awilix#287 will fix it, so I'll close this :-)

from es5-shim.

CircleTan avatar CircleTan commented on May 24, 2024

from es5-shim.

sobrinho avatar sobrinho commented on May 24, 2024

Screen Shot 2022-03-08 at 22 11 15

Screen Shot 2022-03-08 at 22 11 22

Pinned the issue to spreading an object that without es5-shim does work.

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024

Hmm - the “could not resolve” error doesn’t seem like it’s coming from es5-shim. What are you using to transpile object spread?

from es5-shim.

sobrinho avatar sobrinho commented on May 24, 2024

The app was created with vue-cli. What info do you need?

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024

I'm not familiar with vue projects. Do you get that error when running eslint, or when bundling (with webpack, i presume?), or at runtime?

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024

ok, so there's a few issues. For one, you're using an out of date version of es5-shim, plus you're pulling it off a CDN instead of bundling it.

Second, the app is already using core-js, and while core-js should work fine in concert with es-shims, you shouldn't need both - i believe core-js provides everything es5-shim does.

Third, es5-shim isn't meant to be used alone; it's meant to be used in concert with the es6-shim - but adding that to the HTML file doesn't fix it.

The actual problem is caused by something doing require(Symbol.toStringTag), but i'm not sure why it would be doing that. The exception is thrown when __webpack_require__ is called, trying to load babel-loader. I'm also not sure why babel would be running in the browser at all - but awilix is requiring it, it seems (i'd file an issue about that; babel's not meant to be used in the browser).

I suspect the problem is that one of the methods es5-shim patches is producing a Symbol, and some code inside babel-loader - or that babel-loader is processing - may not be expecting that.

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024

This is a reduction of the eval'd code inside the webpack bundle that's throwing:

__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _pwd_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */ \"./node_modules/@babel/runtime/helpers/esm/objectSpread2.js\");
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.object.keys.js */ \"./node_modules/core-js/modules/es.object.keys.js\");
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var awilix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! awilix */ \"./node_modules/awilix/lib/awilix.browser.js\");



var container = (0,awilix__WEBPACK_IMPORTED_MODULE_2__.createContainer)();
container.register({
  container: (0,awilix__WEBPACK_IMPORTED_MODULE_2__.asValue)(\"dummy\")
});
var cradle = container.cradle;

var expanded = (0,_pwd_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])({}, cradle);

console.log(Object.keys(cradle));
console.log(Object.keys(expanded));
/* harmony default export */ __webpack_exports__[\"default\"] = ({
  name: 'HelloWorld',
  props: {
    msg: String
  }
});//# sourceURL=[module]

which strongly suggests it's something inside awilix that's throwing the error. Given that its purpose is to do dynamic DI (an unidiomatic thing in JS), this would be unsurprising.

from es5-shim.

sobrinho avatar sobrinho commented on May 24, 2024

Third, es5-shim isn't meant to be used alone; it's meant to be used in concert with the es6-shim - but adding that to the HTML file doesn't fix it.

The problem is that we don't control where our widget is used.

So, a customer have the es5-shim in their website and the widget does not work there.

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024

thanks, that's useful context. the customer is the one using awilix?

from es5-shim.

sobrinho avatar sobrinho commented on May 24, 2024

Nope, I am the one using it. The customer is the one using es5-shim in their website.

from es5-shim.

ljharb avatar ljharb commented on May 24, 2024

Have you filed this with awilix? Their code looks pretty complex, so they can probably find their dynamic requires faster than i can.

from es5-shim.

CircleTan avatar CircleTan commented on May 24, 2024

from es5-shim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.