Coder Social home page Coder Social logo

ESM about any-observable HOT 7 OPEN

sindresorhus avatar sindresorhus commented on May 8, 2024
ESM

from any-observable.

Comments (7)

sindresorhus avatar sindresorhus commented on May 8, 2024 1

I'd like to keep this open so it's not forgotten. There's some useful info here. I'll circle back to this issue later this year.

from any-observable.

sindresorhus avatar sindresorhus commented on May 8, 2024

Sure, but only native ESM. I don't want any build step. You need to target Node.js 12.

You can see how I recently did it here: sindresorhus/quick-lru@a408ce9

from any-observable.

brettz9 avatar brettz9 commented on May 8, 2024

Thanks. I don't see a clear way for Karma to be used with ESM outside of an old Karma ESM package which is recommending Web Test Runner. Should I switch to that test runner?

from any-observable.

sindresorhus avatar sindresorhus commented on May 8, 2024

Sure

from any-observable.

brettz9 avatar brettz9 commented on May 8, 2024

Hmmm...

In order to preserve the detection and dynamic registration of your "shortcut" capabilities, I think the API would need to change to support the asynchronous nature of the dynamic native ESM imports, i.e., one would have to import an export function and await its result in order to use the Observable.

Top-level await might be usable, but would require Node 14+ (and browser support is currently very limited: https://caniuse.com/mdn-javascript_operators_await_top_level ).

Alternatively, the dynamic detection could be dropped in favor of requiring a specific implementation.

from any-observable.

sindresorhus avatar sindresorhus commented on May 8, 2024

What problems does making this package ESM solve? Because it sounds like converting it to ESM will cause more problems than it solves. ESM can import CommonJS.

from any-observable.

brettz9 avatar brettz9 commented on May 8, 2024

I like being able to make direct imports without a build step for browser (or polyglot) environments, but maybe it is just best to wait (or I could just make a specific fork). Will close for now then. Thanks!

from any-observable.

Related Issues (17)

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.