Commit Graph

7008 Commits

Author SHA1 Message Date
Ben Newman
50b44f6465 Update meteor-babel to version 7.0.0-beta.54. 2018-07-17 20:35:37 -04:00
Ben Newman
f4946306c0 Make IPC system more testable, and implement some basic tests. 2018-07-17 16:44:58 -04:00
Ben Newman
2450ffe84d Remove unreliable modification of Autoupdate versions from self-test. 2018-07-16 18:59:51 -04:00
Ben Newman
77ed148614 Use listener API for communication between build/server processes.
Fixes #10073, per
https://github.com/meteor/meteor/issues/10073#issuecomment-405290391

While thinking about this bug, I realized that sending IPC messages to
specific packages in the server process was much less flexible than
sending messages based on an arbitrary topic string, since the topic
string approach allows both `autoupdate` and `dynamic-import` to listen
for the same message.

The topic string approach calls for a listener interface like
`onMessage(topic, callback)`, which elegantly replaces the previous
approach of requiring packages to export a single `onMessage` function.

However, because the `meteor` package does not have access to the module
system, implementing the `onMessage` listener interface in the `meteor`
package would have required exposing an API like `Meteor.onMessage(topic,
callback)`, which has an unpleasant global smell to it. Instead, the
`onMessage` function should be explicitly imported (using the module
system) from a less-generically-named package.

Since I knew I was going to have to move the message dispatch logic out of
the `meteor` package, I decided to create a new package called
`inter-process-messaging` to implement the parent/child components of the
IPC system.
2018-07-16 18:59:50 -04:00
Ben Newman
34bbbcb0f9 Calculate autoupdate versions correctly in cordova/builder.js.
Follow-up to the recent rewrite of autoupdate:
fe9e4035f9

Should fix #10067.
2018-07-12 11:57:09 -04:00
Ben Newman
244fd2a677 Replace Package._on(name, callback) with Package._promise(name).
https://github.com/meteor/meteor/pull/10055#discussion_r201855997

As I explained in this comment, Package._on(packageName, callback) was a
bad API because it never called the callback if the package was not
installed, which caused any app not using the autoupdate package to get
stuck trying to communicate with the autoupdate package.
2018-07-11 19:37:44 -04:00
Ben Newman
05e7aebef7 Merge branch 'devel' into release-1.7.1 2018-07-11 15:52:05 -04:00
Ben Newman
2765238a29 Update meteor-babel to version 7.0.0-beta.53. 2018-07-11 15:29:45 -04:00
Ben Newman
1387473cf5 Pause requests for the legacy bundle while rewriting it.
This is the solution I came up with for the problems I described here:
https://github.com/meteor/meteor/pull/10055#issuecomment-403219805
2018-07-10 21:17:14 -04:00
Ben Newman
4b17a0b760 Allow sending IPC messages from build process to server process.
Instead of having every message consumer listen to every message and act
on the ones that seem relevant to its interests, we now have a single
process.on("message", callback) hook that can dispatch messages to
different Meteor packages running in the server process.

Receiving packages should export an onMessage function. The onMessage
function may be async, and its result will be delivered back to the build
process as the result of the sendMessage Promise.
2018-07-10 21:17:14 -04:00
Ben Newman
ff3dbf2f1b Send another client refresh message after legacy build completes.
Also removed the AppRunner#_refreshing boolean hack, since reporting
errors during IPC communication seems desirable.
2018-07-06 20:07:45 -04:00
Ben Newman
b9a05d85f6 Permit delayed bundling only if !Console.isHeadless(). 2018-07-04 13:44:12 -04:00
Ben Newman
7f88d26a60 Pass { childProcess, runLog } into post-startup callback function. 2018-07-04 13:44:12 -04:00
Ben Newman
3c5566f532 Avoid nested Profile.run calls in watch.sha{1,512} functions. 2018-07-04 13:44:11 -04:00
Ben Newman
aade180d46 Build web.browser.legacy bundle after startup on rebuilds. 2018-07-04 12:26:23 -04:00
Ben Newman
3d1db19e79 Remove unused NODE_PATH logic from bundler.js and run-app.js. 2018-07-04 10:51:06 -04:00
Ben Newman
5be6c45e77 Clean up previousBuilders caching in bundler.bundle.
Most importantly, we no longer return a copy of previousBuilders from
bundler.bundle, but simply modify the input object over time. The copying
approach was nice in theory, but incompatible with delaying the bundling
of certain architectures (e.g. web.browser.legacy) until some time after
bundler.bundle returns.
2018-07-04 10:25:53 -04:00
Ben Newman
8310870c44 Tolerate clientJson.clientArchs in dynamic-import boot.js setup. 2018-07-04 10:15:26 -04:00
Ben Newman
159fcb3818 Replace clientPaths with clientArchs in config.json. 2018-07-04 10:15:24 -04:00
Ben Newman
ecddfcd08d Use binding behavior of buildmessage.markBoundary in more places.
This functionality was introduced in 7b6fd0ee10.
2018-07-04 10:12:52 -04:00
Ben Newman
90026ea8fc Merge branch 'devel' into release-1.7.1 2018-07-03 14:10:44 -04:00
Ben Newman
cad8151151 Improve File hashing logic in bundler.js. (#10050)
Follow-up to https://github.com/meteor/meteor/pull/9933.

As recommended by @abernix, the sha1 hash of every file is now computed
from the file's sha512 hash, so we don't have to hash the entire contents
of the file twice with two different algorithms.

Other changes/improvements:

* Invalidate the hashes when/if `File#setContents` is called.

* Ignore `options.hash` and just compute hashes from actual file contents.
  Disagreement here would be worse than any performance benefits from
  precomputing the hash.
2018-07-03 14:02:08 -04:00
Timo Horstschaefer
ef3af685ab Enable Sub-Resource Integrity hashes for JS and CSS files (#9933) 2018-07-03 12:30:22 -04:00
Ben Newman
6cea010800 Use Reify Visitor to reimplement findImportedModuleIdentifiers.
Now possible because of https://github.com/benjamn/reify/pull/202.

Similar in spirit to a62a2adf77.
2018-07-02 20:09:12 -04:00
Ben Newman
e8d85362d1 Ensure getPrelinkedOutputCached cannot mix modern/legacy output. 2018-06-30 13:02:21 -04:00
Ben Newman
1cd91b5409 Cache File#getPrelinkedOutput in linker.js.
Another big win thanks to optimistic caching.
2018-06-30 11:44:25 -04:00
Ben Newman
1ed095c36d Cache minified CSS in minifyCssFiles rather than relying on plugins.
Static CSS gets merged in development as well as production by
ClientTarget#minifyCss; the only difference is that the CSS is also
minified in production. This development-time merging is especially
expensive because it involves source maps, and happens on every rebuild of
the app. That's why ClientTarget#minifyCss consistently shows up in
METEOR_PROFILE output for rebuilds.

The standard-minifier-css package tries to cache the merging based on the
hashes of the input files:
8a562523a4/packages/standard-minifier-css/plugin/minify-css.js (L58-L62)

However, not all CSS minifier plugins use a strategy like this, and
https://atmospherejs.com/juliancwirko/postcss is an increasingly popular
one that does not.

The time has come to move this caching logic into the Meteor build tool
itself, so that CSS minifier plugins no longer have to worry about basic
caching, and everyone who uses CSS minifiers with Meteor will benefit.

This implementation leverages Meteor's powerful optimistic caching
techniques to keep previous results in memory only as long as the minifier
object remains reachable.
2018-06-30 11:34:40 -04:00
Ben Newman
7b6fd0ee10 Let buildmessage.markBoundary take optional context argument.
Since markBoundary is essentially creating a bound wrapper function,
there's no reason we can't actually bind the function to a specific
context (this) object at the same time, instead of having to bind the
function and then wrap it with buildmessage.markBoundary.
2018-06-30 11:02:02 -04:00
Ben Newman
8b04c25390 Emit multiple meteorInstall calls for distinct meteorInstallOptions.
I recently noticed a bug whereby modules transferred from the application
bundle to the modules bundle would lose their application-specific import
extensions, since all modules installed in the modules bundle have only
.js and .json as import extensions, matching default Node behavior.

This commit fixes that bug by emitting one meteorInstall call per distinct
meteorInstallOptions object. This logic would work if every module had a
different meteorInstallOptions object, but in practice the modules bundle
should end up with exactly two meteorInstall calls, because a single
options object is shared among all modules from the same source batch.
2018-06-28 18:07:34 -04:00
Ben Newman
ae609e0d96 Improve file.imported logic in the ImportScanner. 2018-06-28 14:12:24 -04:00
Ben Newman
ea69f4ece1 Make unchecked pending errors fatal in OutputResource#_get. 2018-06-26 14:37:09 -04:00
Ben Newman
cf804f22e4 Do not return files with errors from ImportScanner#getOutputFiles.
This works whether or not the file object is a JsOutputResource.
2018-06-26 14:25:32 -04:00
Ben Newman
59eecf9dad Ensure at least one error reported when lazyFinalizer fails. 2018-06-26 14:24:16 -04:00
Ben Newman
5abc8fbdd2 Always record ResourceSlot errors in InputFile#addError. 2018-06-26 13:54:09 -04:00
Ben Newman
9f7ef9cdb1 Fix compiler plugins caching self-test for the stylus plugin. 2018-06-26 13:09:37 -04:00
Ben Newman
de3fef17ca Stop eagerly forcing compilation of lazy CssOutputResources.
This should be a better fix for the problem I tried to fix with
479e505d71.

If we're going to be using compileOneFileLater by default, that's what we
should be testing in the compiler plugins self-tests.
2018-06-26 13:09:28 -04:00
Ben Newman
f7f3d34181 Mark non-isRoot files lazy in MultiFileCachingCompiler.
The concept of a "root" file is specific to MultiFileCachingCompiler, so
we need to normalize it into a representation that makes sense to the rest
of the compiler plugin system.

Should help with #10014.
2018-06-26 13:09:14 -04:00
Ben Newman
9f06a6f6c5 Allow resolving index.* modules with non-.js file extensions. (#10027)
The previous commit enabled importing index.* modules at runtime, but
unfortunately the build-time Resolver logic also needed updating, which
will require a new Meteor release.
2018-06-25 14:36:45 -04:00
Ben Newman
281a849432 Be more defensive about lazy stylesheets that fail to compile.
I should have paid more attention to @abernix's analysis here, as it was
exactly right: https://github.com/meteor/meteor/pull/9983#issuecomment-397240476

cc @pagesrichie
2018-06-16 11:02:29 -04:00
Ben Newman
ce34a60387 Source maps and minification for dynamic CSS modules. (#9998)
When a CSS (or compiled-to-CSS) module is lazy (e.g., in `imports/` or
`node_modules`) and not otherwise imported by another CSS module, Meteor
automatically turns it into a JS module so that it can be handled by the
`ImportScanner`, and imported dynamically by other JS modules.

Until now, there were two problems with CSS handled in this way: it did
not have proper source maps, and the CSS text was not minified in
production.

This commit introduces a special minification step for dynamic CSS, which
must take place before we create the dynamic JS module. Waiting for the
usual minification of CSS would be a mistake, since that happens long
after the `ImportScanner` and `Linker` have already processed JavaScript
modules. Modifying the contents of JS modules at that point would be
impossible without recomputing source maps, etc.

Since the JS module dynamically creates a `<style>` tag and appends it to
the `<head>` of the document, the code of the JS module has no meaningful
relationship to the lines of CSS text that are actually evaluated by the
browser, so it would be a mistake to give the JS module the same source
map as the original CSS resource.

Instead, when there is a source map, we write it out as an asset that can
be requested at runtime, and append a sourceMappingURL comment to the end
of the CSS text referring to this asset URL. Note that this only happens
in development, which makes sense because minification in production
invalidates the source map, and we don't want to expose source code in
production anyway.
2018-06-15 16:10:26 -04:00
Ben Newman
a1f4e94c59 Merge branch 'master' into devel 2018-06-13 19:51:26 -04:00
Ben Newman
ea394be6e8 Don't ignore tests/ directory if meteor.testModule defined.
According to traditional Meteor file loading rules, tests/ directories are
completely ignored: https://guide.meteor.com/structure.html#special-directories

However, if you specify a meteor.testModule in your package.json that
refers to a file inside a tests/ directory, Meteor should permit modules
to be loaded from tests/, as well as any modules that are imported by the
meteor.testModule entry point.

Fixes #9991.
2018-06-13 17:59:40 -04:00
Ben Newman
85a66caa89 Merge branch 'master' into devel 2018-06-13 15:30:10 -04:00
Ben Newman
9b28ece2ba Bump @babel/runtime version in starter application skeletons. 2018-06-13 14:21:20 -04:00
Rob Fallows
a9af151df9 Update default and --minimal app skeletons. Fixes #9961 (#9977) 2018-06-13 13:22:39 -04:00
Ben Newman
2b505936b4 Tolerate async lazyFinalizer functions when immediately invoked. 2018-06-12 11:02:37 -04:00
Ben Newman
baa6108f0c Stop representing JS compilation errors as file objects. 2018-06-11 21:55:50 -04:00
Ben Newman
df712b6b7a Allow lazyFinalizer functions to return Promises. 2018-06-11 19:35:42 -04:00
Ben Newman
79cb14afbe Avoid accessing .data in ImportScanner until files get scanned. 2018-06-11 17:18:08 -04:00
Ben Newman
6f93bd1def Use custom CssOutputResource class in ResourceSlot#addStylesheet. 2018-06-11 17:18:08 -04:00