Git Product home page Git Product logo

Comments (11)

Raynos avatar Raynos commented on July 18, 2024

@dobrite this is why you cannot turn on global strict mode.

You must turn on strict mode at a per file level.

from error.

dobrite avatar dobrite commented on July 18, 2024

In regards to a global use strict. The code I wrote is not doing this. Should I take it up with cyclejs then?

I do feel that a utility library should adhere to strict mode, in this case skipping the name property and instead using an alternate property (_name in your case). It is already a no-op on at least chrome.

In any case thanks for the quick response and happy new year! 🎉

from error.

Raynos avatar Raynos commented on July 18, 2024

@dobrite

Interestingly the problem you described doesn't exist in node but exists in chrome.

from error.

Raynos avatar Raynos commented on July 18, 2024

I can reproduce the problem in node 0.11.x

still error itself doesn't use strict mode so unless you use global strict mode this shouldn't happen.

For example

> function foo() { 'use strict'; function g() {}; g.name = 'bar'; return g; }
undefined
> foo()
TypeError: Cannot assign to read only property 'name' of function g() {}
    at foo (repl:1:56)
    at repl:1:1
    at REPLServer.defaultEval (repl.js:130:27)
    at bound (domain.js:257:14)
    at REPLServer.runBound [as eval] (domain.js:270:12)
    at REPLServer.<anonymous> (repl.js:277:12)
    at REPLServer.EventEmitter.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:202:10)
    at REPLServer.Interface._line (readline.js:531:8)
    at REPLServer.Interface._ttyWrite (readline.js:812:14)
> function foo() { function g() {}; g.name = 'bar'; return g; }
undefined
> foo()
[Function: g]
> function fab() { 'use strict'; return foo(); }
undefined
> fab()
[Function: g]

from error.

dobrite avatar dobrite commented on July 18, 2024

I updated my comment above (sorry). Since it already is a no-op on Chrome error and extend shouldn't rely on it working. Perhaps skip the name property with extend? That way strict doesn't throw and _name is set for whatever nefarious purposes you have 😁

from error.

Raynos avatar Raynos commented on July 18, 2024

@dobrite I can skip the name property but that requires an extra copy and a delete.

I'm taking advantage of the fact that assigning name is a no-op so I dont have to write more code or do more copies.

from error.

Raynos avatar Raynos commented on July 18, 2024

@dobrite how exactly are you using webpack and cycle together ?

from error.

dobrite avatar dobrite commented on July 18, 2024

It's just cyclejs''s README code and a minimal package.json and webpack config to get it going.

I have to run out the door but I'll throw up a repo later. cheers!

from error.

Raynos avatar Raynos commented on July 18, 2024

Might be related to Raynos/xtend#25

from error.

staltz avatar staltz commented on July 18, 2024

I think webpack might be enforcing a global 'use strict' then. Cycle.js doesn't do that, it uses strict per file only.

from error.

dobrite avatar dobrite commented on July 18, 2024

So the issue was es6-loader in the webpack config I was using. es6-loader uses es6-module-transpiler and es6-transpiler, the former of which enforces use strict on es6 modules. A few different threads turned up that es6 modules, by definition, always enforce strict semantics (TIL!).

I think I can get by with excluding node_modules from es6-loader.

I apologize for the issues as it ultimately was not your libraries. Thank you both for your help! Cheers 🍻

from error.

Related Issues (10)

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.