Commit Graph

9 Commits

Author SHA1 Message Date
Ben Newman
6c643a4763 Preserve true "main" and "browser" fields of package.json modules.
Previously, when building a JavaScript bundle for the client, if a
package.json file had a string-valued "browser" field, we would replace
the value of the "main" field of the bundled package.json module with the
value of the "browser" field. This trick was important because it allowed
an npm package to have a different entry point on the client than it had
on the server.

However, that approach became inconsistent if the package.json file was
also explicitly imported as a module, because the package.json stub used
for module resolution prevented the real contents of package.json from
getting bundled, and disagreed with the original package.json module about
the value of the "main" field.

To resolve that inconsistency, it seems better to avoid modifying the
"main" field of package.json modules, and instead rely on the runtime
module system to make sense of the "browser" field, regardless of whether
the package.json module is a stub used only for module resolution or
contains the full contents of the original package.json file.

The ability to understand "browser" fields of package.json modules was
introduced in install@0.8.3:
377d1a3b51

This is potentially a backwards-incompatible change for developers using
this version of `ImportScanner` and `Resolver` who have not yet upgraded
their `modules-runtime` package to at least version 0.7.8. The solution is
to upgrade `modules-runtime`, though it would be nice to enforce that
better somehow.
2017-02-01 10:34:52 -05:00
Ben Newman
7bcc50c842 Add profiling for meteorInstall-based require calls.
The options.wrapRequire API is new in install@0.8.2.
2016-10-24 18:48:16 -07:00
Ben Newman
70f9dee8f1 Make require.resolve work for built-in modules on the server. 2016-05-19 17:04:09 -04:00
Ben Newman
218a4432b1 Support module.import(id, setters) and module.export(id, getters). 2016-05-19 17:04:09 -04:00
Ben Newman
b3a83bd118 Install reliable stubs for all Package[name] objects.
If a Meteor package had a file called index.js, the runtime module system
would resolve "meteor/<name>" to "/node_modules/meteor/<name>/index.js",
instead of falling back to Package[<name>] as expected.

Installing a stub for Package[<name>] at /node_modules/meteor/<name>.js
means the runtime module system no longer needs the fallback, and will no
longer be confused by index.js files.

Fixes #6590.
2016-04-07 13:05:52 -04:00
Ben Newman
b7b854511f Upgrade install package to remove APIs unused by modules-runtime.
The npm install package has coevolved with the Meteor 1.3 module system,
and now it's time to prune off vestigial features that were never actually
useful to Meteor.
2016-03-11 19:24:27 -05:00
Ben Newman
c9660d9f83 Implement module.useNode() for importing node_modules on the server.
Upgrading the install package to 0.5.6 was vital to enable support for
Module.prototype.useNode: 9eb8351e11
2016-03-07 19:41:15 -05:00
Ben Newman
d475a45580 Implement meteorInstall.addExtension.
This paves the way for enabling additional optional file extensions
beyond .js and .json, such as .coffee, .ts, and .jsx.

Part of #6151.
2016-02-19 18:25:27 -05:00
Ben Newman
f73a2a968a Move implementation of meteorInstall into modules-runtime.
This allows the modules package to use meteorInstall to define itself.
2016-01-18 18:54:56 -05:00