Commit Graph

501 Commits

Author SHA1 Message Date
Ben Newman
59124681bc Preserve true "main" and "browser" fields of package.json modules.
This reverts commit 32140c8707, restoring
commit 6c643a4763.
2017-02-07 10:43:20 -05:00
Ben Newman
29b88d29d4 Merge branch 'devel' into release-1.4.3 2017-02-07 10:37:54 -05:00
Ben Newman
3801349437 Merge branch 'master' into devel 2017-02-07 10:36:49 -05:00
Jesse Rosenberger
32140c8707 Revert "Preserve true "main" and "browser" fields of package.json modules."
This reverts commit 6c643a4763.
2017-02-02 20:26:54 -08:00
Ben Newman
a00b19d1fb Merge branch 'devel' into release-1.4.3 2017-02-02 16:07:50 -05:00
Hugh Willson
f57d4d157d Added extra colon-converter calls to the bundler and linker. (#8293)
* Added extra colon-converter calls to the bundler and linker.
* Rewording of convert to convertColons for clarity.
2017-02-02 15:54:59 -05:00
Ben Newman
cc8734ddca Merge branch 'master' into devel 2017-02-02 15:18:48 -05:00
Ben Newman
c683a79595 Unify file.emptyStub and file.imported === "implicit" as file.implicit.
Note that there was a typo in ResourceSlot#addStylesheet, so
file.emptyStub was never === true before.
2017-02-01 10:35:31 -05:00
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
2613582311 Always copy node_modules/.bin into bundle/programs/server/npm.
Fixes #8136.
2017-02-01 09:58:10 -05:00
Ben Newman
0734a70299 Merge branch 'devel' into release-1.4.3 2017-01-19 11:55:29 -05:00
Ben Newman
fd9bda20df Merge pull request #8170 from abernix/feature/fix-7859-messaging
Improve helpfulness of error message when combining different files.
2017-01-10 18:48:01 -05:00
Ben Newman
13eee64d95 Style tweak to reduce indentation in ImportScanner#_addPkgJsonToOutput. 2017-01-04 13:13:45 -05:00
Ben Newman
4fb26259b8 Unify file.emptyStub and file.imported === "implicit" as file.implicit.
Note that there was a typo in ResourceSlot#addStylesheet, so
file.emptyStub was never === true before.
2017-01-04 13:00:24 -05:00
Ben Newman
2eab0b2bf4 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-01-04 11:54:17 -05:00
Jesse Rosenberger
ec69e6d999 Improve helpfulness of error message when combining different files
Make the error message displayed to the developer more helpful in a situation like meteor/meteor#7859 where the `package.js` inadvertently referred to an imProPeRly-CaSeD version of the file it was importing.

No functionality change, just developer experience.

Fixes #7859
2016-12-19 19:36:48 +02:00
Ben Newman
f42c137f55 Always copy node_modules/.bin into bundle/programs/server/npm.
Fixes #8136.
2016-12-06 10:16:43 -05:00
Ben Newman
3dc623cb8f Merge pull request #8120 from hwillson/issue-5626-proper
Help address the Unicode asset filename issues discussed in #5626
2016-12-01 09:40:43 -05:00
Hugh Willson
4a10a1b26b Making sure asset filenames are Unicode normalized when loaded (to help address issue #5626). 2016-11-30 20:31:37 -05:00
Ben Newman
7c148b2a4e Merge branch 'devel' into run-reify-before-babel 2016-11-30 19:51:05 -05:00
Ben Newman
c83094ae26 Tolerate module["import"] properties in findImportedModuleIdentifiers. 2016-11-26 13:07:27 -05:00
Jesse Rosenberger
487b41fd75 Improve compiler error when asset is added with empty contents
While not a Meteor bug, this makes the error message more helpful when a compiler tries adding an asset without data, as demonstrated in meteor/meteor#8034.

Thanks to suggestion by @sdarnell for this.

Closes meteor/meteor#8034
2016-11-24 16:20:46 +02:00
Ben Newman
1b855047ae Limit InputFile#findControlFile to package source root directory.
This is an improvement that I noticed while investigating the
feasibility of fixing #8068.
2016-11-17 13:17:49 -05:00
Ben Newman
fc9c56a73e Improve InputFile#resolve. 2016-11-17 13:12:27 -05:00
Ben Newman
4cf06c37a6 Avoid global/method name ambiguity in InputFile#require. 2016-11-17 13:12:27 -05:00
Ben Newman
24b0ea9fdd Bump compiler/linker/bundler salts to trigger fresh builds. 2016-11-14 21:18:03 -05:00
Ben Newman
e4c7b0890c Watch all imported files in linked npm packages on server. 2016-11-14 14:25:22 -05:00
Ben Newman
2437f72cd7 Strip unnecessary imports for packages with no modules.
Note that even an empty package needs to define Package[name] = {}, so
that other packages can tell at runtime whether it's installed.

Fixes #7927.
2016-11-14 12:51:00 -05:00
Ben Newman
911f25bbf4 Allow lazy api.mainModule modules.
If you call api.mainModule(path, where, { lazy: true }), that main
module will not be evaluated until other code imports it at runtime, and
won't even be bundled if no other code imports it.

Closes #6132.
2016-11-14 12:51:00 -05:00
Ben Newman
61ada2d27b Update statOrNull method of cached Resolver objects.
This solves a problem that sometimes occurs when new modules are added
to an app but the cached Resolver object cannot find them because its
statOrNull method is still using a previous instance of the
corresponding ImportScanner.

Related issues and comments:

https://forums.meteor.com/t/meteor-not-detecting-new-files/31151
https://github.com/Akryum/meteor-vue-component/issues/80
https://github.com/meteor/meteor/pull/7975#issuecomment-259263650
https://github.com/meteor/meteor/issues/8008
2016-11-10 17:50:59 -05:00
Ben Newman
8f07a87bd5 Give package test modules access to Npm.depends dependencies.
Similar in spirit to bbac272530.

Fixes #7999.
2016-11-08 15:36:36 -05:00
Ben Newman
932115120f Don't let options.hash override File#hash() salting. 2016-11-08 14:08:08 -05:00
Ben Newman
4ada5c8a17 Bump LINKER_CACHE_SALT and compiler.BUILT_BY for good measure.
This will trigger recompilation and relinking, which should help prevent
various stale caching issues, e.g. #7977.
2016-11-08 13:50:32 -05:00
Ben Newman
940cc4f4d6 Add salt to File#hash in bundler.js.
This is what determines, among other things, source map URL names of the
form <hash>.map, so this may help to avoid #7977.
2016-11-08 13:48:54 -05:00
Ben Newman
a7ac32e00a Tolerate ENOENT errors in Builder#copyDirectory. 2016-11-08 13:33:20 -05:00
Ben Newman
ad460e0d7d Tolerate files.realpath throwing ELOOP exceptions. 2016-11-04 18:45:51 -04:00
Ben Newman
52697c7167 Cache getProdPackageNames optimistically. 2016-11-04 18:26:03 -04:00
Ben Newman
7f35e94713 Tolerate files.realpath throwing ENOENT exceptions. 2016-11-04 18:14:09 -04:00
Ben Newman
af51b8160c Use absolute paths for external symlinks in Builder#copyDirectory.
Thanks to @worldsayshi for reporting this issue with a reproduction.

Fixes #8005.
Fixes #2876.
Fixes #7154.
2016-11-04 17:44:42 -04:00
Ben Newman
8bc4fe20c6 Cache .meteor-portable values temporarily in memory.
This is another way to fix the bug I previously fixed by passing
options.allowSyntaxError to optimisticReadJsonOrNull.

To reproduce the bug (and/or verify that it is fixed), run the following
commands in a terminal:

  rm -rf meteor/packages/npm-mongo/.npm
  meteor/meteor --get-ready

Before these two commits, optimisticReadJsonOrNull would throw a
SyntaxError when reading one of the .meteor-portable files because an
asynchronous write to the same file had not yet finished.
2016-11-02 13:15:57 -04:00
Ben Newman
909419b36e Optionally tolerate SyntaxError in optimisticReadJsonOrNull. 2016-11-02 13:04:09 -04:00
Ben Newman
f0355276a5 Remove babel-runtime-specific logic from compiler-plugin.js. 2016-11-02 12:05:33 -04:00
Ben Newman
1b3edb2300 Write files with appropriate mode in Builder#copyDirectory.
Fixes #7974.
2016-10-28 16:11:29 -04:00
Ben Newman
8d5bfd8ae9 Trivial: fix comment indentation. 2016-10-28 14:49:46 -04:00
Tom Coleman
04f401c711 JSdoc refactoring to make API boxes work again. 2016-10-27 14:55:56 -07:00
Ben Newman
cadf113e6c Only strip devDependencies when buildMode !== "test".
Follow-up to #7953.
2016-10-25 08:46:33 -07:00
Ben Newman
03e798abc9 Only strip devDependencies when buildMode === "production".
Fixes #7953.
2016-10-24 22:10:02 -07: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
33964e9661 Add profiling for Npm.require calls during server startup. 2016-10-24 18:18:03 -07:00
Ben Newman
739890d955 Bump compiler.BUILT_BY and LINKER_CACHE_SALT. 2016-10-23 18:17:26 -04:00