Coder Social home page Coder Social logo

svelte-es5-meteor's People

Contributors

elidoran avatar klaussner avatar

Watchers

 avatar  avatar  avatar

Forkers

elidoran

svelte-es5-meteor's Issues

babel madness: typeof -> _typeof -> _typeof4

Svelte has this line in its dispatchObservers function:

// src/shared/index.js
if ( newValue === oldValue && typeof newValue !== 'object' ) continue;

After compiling it to ES5 for package "svelte-es5-meteor" it becomes:

// dist/[email protected] line 14606
if (newValue === oldValue && 
  (typeof newValue === 'undefined' ? 'undefined' : _typeof(newValue)) !== 'object') 
    continue;

Then, after Meteor's build system processes it I get an error saying _typeof is not defined.

I checked through the source code it built using View Page Source and found Meteor is changing the use of typeof. It grabs that from 'babel/runtime/typeof' and assigns it to _typeof3 and then does the ES5 interop (_interopRequireDefault) thing to make a _typeof4 with a default property containing it. Then, the later code uses _typeof4.default instead of typeof.

Except, the "dispatchObservers" function still uses _typeof, which doesn't exist. It was defined in svelte but didn't make it into the code sent to the browser.

I then changed the line in dist/svelte.js to be the way the original src/shared/index.js is. Reset the meteor project and started the app. Then the line looks like this:

if (newValue === oldValue && 
  (typeof newValue === "undefined" ? "undefined" : (0, _typeof3.default)(newValue)) !== 'object')
    continue;

It is now replacing the typeof use with the _typeof3 variable Meteor put in there (which was _typeof4 previously). So, it works because that is defined.

It seems to me the transpiling for "svelte-es5-meteor" is changing that line in a way which prevents it from being changed later by Meteor when Meteor tries to replace the typeof operations. Or, somehow it's failing to include a declaration creating _typeof in the browser code.

Have you encountered this?

I'm not sure what the fix should be. Is it to avoid transpiling the line used in generating code? Or, ensure _typeof is defined in the code sent to the browser?

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.