Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"module" field doesn't point at a module #317

Closed
43081j opened this issue Mar 22, 2020 · 2 comments
Closed

"module" field doesn't point at a module #317

43081j opened this issue Mar 22, 2020 · 2 comments

Comments

@43081j
Copy link
Contributor

43081j commented Mar 22, 2020

When used as an es module via the "module" property and a bundler, we get no exports.

The sources, and the commonjs output are individual exports, such as:

module.exports.install = fn;
// means:
const {install} = require('@sinonjs/fake-timers');

However, the browserify output results in an empty export:

import {install} from '@sinonjs/fake-timers';  // ERRORS
import * as timers from '@sinonjs/fake-timers'; // this is how it should be but is {} at the minute
import fakeTimers from '@sinonjs/fake-timers'; // ERRORS, no default export
timers.install; // DOESNT EXIST

the problem here seems to be that "module" in package.json should point at an ES module, but clearly doesn't. it instead points at a browserify bundle.. which is rather dated and will not work as expected in bundlers which interpret the "module" field.

@43081j 43081j changed the title ESM usage is stuffed into a default "module" field doesn't point at a module Mar 22, 2020
@mantoni
Copy link
Member

mantoni commented Mar 23, 2020

For Sinon we solved this by generating a separate esm module in the build.js script:

https://github.com/sinonjs/sinon/blob/d2b4b726529f167d908747d2173b5491794ac718/build.js#L61-L80

The module field in package.json points to this module. We'd need to the same for fake-timers to fix this.

@stale
Copy link

stale bot commented May 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 22, 2020
@stale stale bot closed this as completed May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants