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

Please create a main field on package.json #90

Closed
ScriptedAlchemy opened this issue Nov 23, 2020 · 6 comments
Closed

Please create a main field on package.json #90

ScriptedAlchemy opened this issue Nov 23, 2020 · 6 comments

Comments

@ScriptedAlchemy
Copy link

Im having some nightmare issues trying to resolve this project with next-transpile-modules

Is it possible to please add some kind of index.js file so require.resolve is able to find the package properly

@ivanoats
Copy link

ivanoats commented Dec 1, 2020

Maybe #56 could be cleaned up.

@chrisveness
Copy link
Owner

The reason that I've never included a 'main' entry is that there is a range of independent entry points into the library; while one user might

import LatLon from 'geodesy/latlon-spherical.js';

or

import LatLon from 'geodesy/latlon-ellipsoidal-vincenty.js';

another user might

import Mgrs, { LatLon } from 'geodesy/mgrs.js';

I'm afraid I've no experience with Next or indeed React – why is it next-transpile-modules requires a main entry?

@ScriptedAlchemy
Copy link
Author

The main field can point to an empty module export. It's just require.resolve and enhanced-handed resolve won't work without a valid field available.

@chrisveness
Copy link
Owner

Looking through these:

I gather that webpack respects both "main" and "module", and that "main" is more used for CommonJS and "module" for ESM ("with package.json "main" specifying the CommonJS entry point and package.json "module" specifying the ES module entry point") – and also that "module" can "point to a folder of ES modules".

So it appears to me that a package.json entry

    "module": "./"

would be correct and accurate, and would satisfy webpack's resolve requirements – have I understood well?

If so, I would be more than happy to include that.

@chrisveness
Copy link
Owner

I've added "module": "./" to package.json in v2.3.0, which I hope resolves this issue.

@ScriptedAlchemy
Copy link
Author

Much appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants