GithubHelp home page GithubHelp logo

Comments (17)

iambumblehead avatar iambumblehead commented on May 22, 2024 1

Two changes fix this package for the latest versions of node,

  1. The module loader "getSource" definition must be exported as "load". node shows this in the test process "(node:14251) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getSource". I searched for ways to conditionally export "getSource" or "load" depending upon the node version but didn't find a way to it.
  2. The value returned by "load" needs to include a property format: 'module' or an error is thrown.

Here's what I propose,

  • release a minor version, exporting both 'load' and 'getSource' hooks. The deprecation warning will show when this package gets used,
  • release a new major version, removing 'getSource' and updating the README with some information about that

Maybe "getSource" should be kept rather than removed, I'm not sure.

@mroderick do you have any input?

cc @Swivelgames feel free to give your opinion or ignore as well.

from esmock.

mroderick avatar mroderick commented on May 22, 2024 1

I can confirm that the issue has been resolved 👍

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

@mroderick thanks for messaging me here. I'll take a look this evening to try resolving this.

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

The mac+node issue described here affects me (though they are discussing a different version) https://stackoverflow.com/questions/69452504/zlib-error-when-attempting-to-run-npm-install-or-yarn#answer-69743293

I'll need to resolve environment issues before I can look into this

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

the PR auto-closed this ticket...

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

its published as version 0.4.2 https://www.npmjs.com/package/esmock

feel free to re-open this issue @mroderick

I didn't intend close the issue but wrote 'closes #16' in the PR description and github closed it. Anyway, I think its resolved.

from esmock.

maherma-adg avatar maherma-adg commented on May 22, 2024

With version [email protected] on 16.13.0 you get this warning:
(node:13737) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getSource

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

@maherma-adg do you recommend a way to resolve this? I searched for a way to conditionally export 'getSource' if node version is less than 16.12, but node forces the file to declare exports statically.

what do you think of think of this idea... two module loaders, one for node v12-v16.11 and another for node v16.13+

node v12-v16.11

mocha --loader=esmock/loader.getSource.mjs

node v16.12+

mocha --loader=esmock

I'm not exactly sure if it will work, but I think it could work.

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

I would prefer if "--loader=esmock" could be used always but how does one make that load a file that only exports "getSource" for node v12-v16.11?

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

@maherma-adg I found a way to make the warning go away #19

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

@maherma-adg try the newest version

from esmock.

maherma-adg avatar maherma-adg commented on May 22, 2024

It's works with ava, but I can't make it work with jest, anyone can?

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

@maherma-adg I haven't tried it with jest, but doesn't jest process everything through a transpiler? Maybe that's why it doesn't work... maybe its transforming the sources into cjs or something similar

from esmock.

maherma-adg avatar maherma-adg commented on May 22, 2024

As far as I know, jest only transpile when needed ( and you must configure transpiler ) for TS, Vue, JSX, etc. I'll try to dig deeper.
Thanks for your useful tool.
Manuel.

UPDATE: My mistake, reading more into doc, I see automatic transform through babel is done for JS files.

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

@maherma-adg https://jestjs.io/docs/ecmascript-modules try disabling transformations or configuring them to produce esm

from esmock.

OlaoluwaM avatar OlaoluwaM commented on May 22, 2024

How can I set the loader for jest on esm?

from esmock.

iambumblehead avatar iambumblehead commented on May 22, 2024

@OlaoluwaM if you make a PR with a sample basic jest test in it, I can try and make things work with that

from esmock.

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.