Closed martpie closed 3 years ago
:(
:)
Hey @martpie I'm not sure what you're working on :smile:.
But to let you know my only pain-point with "main", is that I sometimes I want packages to be published too (microbundle...)... In other words
For publishing:
{
"main": "./dist/index.js"
}
For working in the monorepo
{
"main": "./src/index.ts"
}
Some bundlers like microbundle supports the "source" field convention, but I'm not sure if NTM supports precedence of source from main.
{
// useful for next-transpile-modules (based on convention,
// maybe from a configuration option ???)
"source": "./src/index.ts",
// useful for microbundle, rollup, npm publishing....
"main": "./dist/index.js"
}
But that would be awesome.
Is what you're working on or has anything to do with this ?
BTW, thank you for your work, really appreciated
@belgattitude in theory this branch should solve this, as ntm will be looking for the ${module}/package.json
before fall-backing to the previous way.
Could you maybe try this branch and tell me if it solves it for you?
Could you maybe try this branch and tell me if it solves it for you?
Opened an example here: https://github.com/belgattitude/nextjs-monorepo-example/pull/37
Check for this commit where it starts to break ntm: https://github.com/belgattitude/nextjs-monorepo-example/pull/37/commits/037493f127f53aa9d2d63ed207b5b006457df1cc . This commit allows me to publish the packages by setting "main" to "dist/index.js" thus breaking ntm.
Any idea what could help with this new branch ?
I see better now :smile:,
your P/R add support for "exports" field which is super nice but as far as I understand its purpose is different.
Intuitively I'm looking for "source" to disambiguate build and source files but I'm not sure it's the way to go, cause this ecosystem made me insane ;)
What do you think ?
PS:
From microbundle doc, seems they handle this through "source" as well
your P/R add support for "exports" field which is super nice but as far as I understand its purpose is different.
export
is already supported. What my PR does is really just trying to get the module path via require.resolve(path.join(module, 'package.json'))
instead of just require.resolve(module)
, that's it
(automatically resolve a module path assuming its
package.json
location, and not using itspackage.json
main
orexports
fields)