|
| 1 | +# Node.js Modules Team Meeting 2020-06-17 |
| 2 | + |
| 3 | +## Links |
| 4 | + |
| 5 | +* **Recording**: http://www.youtube.com/watch?v=hFfwRkR-L-I |
| 6 | +* **GitHub Issue**: https://github.com/nodejs/modules/issues/528 |
| 7 | +* **Minutes Google Doc**: https://docs.google.com/document/d/1FLK3nkCpxF6D-JFuoZlGpovF0lpSQ_8TP3wini6FsB0/edit |
| 8 | + |
| 9 | +## Present |
| 10 | + |
| 11 | +* Modules team: @nodejs/modules |
| 12 | + |
| 13 | +- Myles Borins (@MylesBorins) |
| 14 | +- Jordan Harband (@ljharb) |
| 15 | +- Darcy Clarke (@darcyclarke) |
| 16 | +- Rob Palmer (@robpalme) |
| 17 | + |
| 18 | +## Agenda |
| 19 | + |
| 20 | +## Announcements |
| 21 | + |
| 22 | +*Extracted from **modules-agenda** labelled issues and pull requests from the **nodejs org** prior to the meeting. |
| 23 | + |
| 24 | +### nodejs/node |
| 25 | + |
| 26 | +#### Special treatment for package.json resolution and exports? [#33460](https://github.com/nodejs/node/issues/33460) |
| 27 | + |
| 28 | +- MB: There are ways to get an entrypoint but it may not be the package root. So heuristics may be needed to find package.json |
| 29 | +- JH: package.jsons can be copied so you can't know for sure. API for bare-identifier to package.json provides a way for tools to work. |
| 30 | +- MB: We could publish an ecosystem package - find-package-json - would be siblings at the root of node_modules. This matters when I want my dependency's package.json. If that hierarchy is guaranteed, direct dependencies should be peers. |
| 31 | +- JH: Use-case is I'm a tool used in a project I don't control. So answer won't be relative to the tool's location. |
| 32 | +- MB: So I'm a dependency of the project. Maybe I'm bundling. Instrumented by the top-level package and I need to find other dependencies. You need to set the root. |
| 33 | +- JH: You can put node_modules at the root of your disk. |
| 34 | +- MB: Everything is resolved to yourself. If overlapping. |
| 35 | +- JH: Node already has the logic. You don't know where your dependencies will come from. |
| 36 | +- MB: Why is this different to the root of your resolve? |
| 37 | +- JH: With exports, you can't know for sure. Will show an example offline. |
| 38 | +- MB: Let's try the ecosystem package approach first. |
| 39 | +- JH: If it can 100% work in userland that's fine. |
| 40 | +- MB: Some people may want to prevent package.json leaking to users. Or maybe if people are ok with it being public, we just change our defaults. |
| 41 | +- GB: Depends how many tools are impacted. Softly feeling we don't need to do anything. |
| 42 | +- MB: If exports is used to generate import maps, maybe package.json shouldn't be available. It's easier to remember the rule that "only exports get exported". |
| 43 | +- JH: README can be used a hint. |
| 44 | +- GB: API to get package root would permit fs.readFile to grab package.json |
| 45 | +- MB: Not 100% but the basic algorithm to resolve the file and then crawl will probably always work. |
| 46 | +- JH: Babel has an option that duplicates package.json |
| 47 | +- GB: You don't look for package.json - you look for node_modules |
| 48 | +- MB: If we had module.resolve to give a path, with a changeable root, you could always go up to node_modules then back down. |
| 49 | +- JH: It's possible. Resolve already needs to duplicate the whole algorithm. |
| 50 | +- MB: If we expose resolve, that gives you everything you need. NODE_PATHS may confuse here. |
| 51 | +- JH: Even if it is doable in userland, it seems silly to not put it in Node. |
| 52 | +- MB: I think we need a meta-issue to discuss this. Bring up a series of APIs at once. Maybe we want to introduce a top-level resolve module. My gut is that we don't need a new API for this. |
| 53 | +resolveType() resolveRoot() resolvePath(). resolveRoot() may be better because it is environment-agnostic. |
| 54 | +- JH: I remain convinced we should have a resolvePackageRoot() somewhere. |
| 55 | +- MB: Maybe a getPackageMetadata. It could be synchronous. There is a large cost to putting this API in core. |
| 56 | + |
| 57 | + |
| 58 | +#### module: CJS exports detection [#33416](https://github.com/nodejs/node/pull/33416) |
| 59 | + |
| 60 | +- GB: How do you define success? Maybe not everything was intended to be exported. |
| 61 | +- MB: Maybe's there's a field in package.json to enable the heuristic? Less work than writing a wrapper. |
| 62 | +- GB: We need to make it as good as possible then merge it in behind a flag to get feedback. |
| 63 | +- JH: People are going to want to use this on abandoned packages. The heuristic is more likely to break due to a change in Babel that upsets the heuristic. |
| 64 | +- MB: User research may be good - but biased responses to "do you want exports for CommonJS if it works X% of the time?" |
| 65 | +- GB: Let's study guy's PR. |
| 66 | +- MB: Releasing under an experimental flag seems worth exploring. |
| 67 | +- GB: It uses a WASM library for parsing. |
| 68 | +- MB: Can we land it non-observable when the flag is off? If so, let's do it. |
| 69 | +- RP: Do we have many people complaining about lack of named exports for CJS? |
| 70 | +- GB: Not really. A few issues. |
| 71 | +- MB: Adding this experimental flag is nice. Combined with auto-extension flags, maybe that gives you the webpack experience as an opt-in mode. |
0 commit comments