Commit Graph

20712 Commits

Author SHA1 Message Date
Ben Newman
2453abbcbc Bump package versions for 1.6.2-beta.0 release. release/METEOR@1.6.2-beta.0 2018-01-22 21:28:55 -05:00
Ben Newman
b4a68e99c1 Avoid having to republish all core packages for web.browser.legacy.
I'm not entirely sure this will work, but the alternative is having to
bump the patch version of every core package, so I'd like to see if this
simplification works first.
2018-01-22 21:28:54 -05:00
Ben Newman
ec03b82706 Merge pull request #9439 from meteor/web.browser.legacy
Support a new web.browser.legacy platform to reduce bundle sizes for modern browsers.
2018-01-22 19:45:16 -05:00
Ben Newman
f878ba19c7 Address initial review feedback from @abernix.
I've decided to stick with Meteor.isModern for now, since it's false for
both web.browser.legacy and web.cordova bundles, which would make logic
involving a hypothetical Meteor.platform property more complicated than
simply using Meteor.isModern. I'm open to revisiting this later.
2018-01-22 18:07:56 -05:00
Ben Newman
e0eacc62fd Set Meteor.isModern to false in Cordova environments. 2018-01-22 18:07:56 -05:00
Ben Newman
7fc1b1b73c Introduce "legacy" shorthand for web.browser.legacy and web.cordova. 2018-01-22 18:07:55 -05:00
Ben Newman
2fa38bdf4c Convert utils/archinfo.js to use ECMAScript exports. 2018-01-22 18:07:55 -05:00
Ben Newman
8ccbe3baa0 Avoid breaking backwards compatibility for asset URLs. 2018-01-22 18:07:55 -05:00
Ben Newman
4529885a6a Compile ECMAScript for web.browser with fewer Babel plugins.
https://github.com/meteor/babel-preset-meteor/blob/master/modern.js
https://github.com/meteor/babel/blob/dfcce32868/options.js#L81

With the minimum versions from babel-preset-meteor/modern-versions.js, the
difference between "modern" and "legacy" browsers boils down to supporting
native async functions.

I'm eager to stop compiling generator functions with Regenerator, and none
of the transforms that compile async functions to native generator
functions seem much better than the Regenerator experience (source maps
are still wonky within the async function, so it's obvious you're not
working with native code).

Native async functions are supported by 73% of desktop and mobile browsers
worldwide (81% in the US), and that percentage is only going to keep
increasing. I see no reason not to embrace this future now.
2018-01-22 18:07:55 -05:00
Ben Newman
eba781fd55 Tolerate non-enumerable .raw property in template tag function. 2018-01-22 18:07:55 -05:00
Ben Newman
5d0fd60c61 Allow explicit source parameter to setMinimumBrowserVersions.
Calling getCaller was noticeably slowing down server startup,
unfortunately.

cc @hwillson
2018-01-22 18:07:54 -05:00
Ben Newman
e33d1552c2 Avoid overriding babelCompilerFeatures.runtime if already defined.
This led to a regression in coffeescript-test-helper because the truthy
extraFeatures.runtime property allowed require("@babel/runtime/...") to
appear in a compiled CoffeeScript file, though require was not defined.

If @GeoffreyBooth agrees, we could have the coffeescript package
api.imply("modules"), which would make require would work, but I seem to
remember we had some reasons for not doing that previously.
2018-01-22 18:07:54 -05:00
Ben Newman
24d757c344 Import only modern core-js polyfills in ecmascript-runtime-client.
In my research, I found the data used by @babel/preset-env to be more
conservative than necessary, so I have not followed their minimum version
constraints exactly.

For example, every feature of the ECMAScript `Map` API is clearly
supported in Firefox 45+, according to MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Browser_compatibility

However, @babel/preset-env requires `core-js/modules/es6.map` in any
version of Firefox earlier than 53:
e270fbe7f0/packages/babel-preset-env/data/built-ins.json (L117)

Since I can't find any evidence that @babel/preset-env knows better than
other sources (I think they might just be using a compatibility table that
doesn't go back far enough), I have tentatively trusted MDN in picking
these versions.

If any bugs are ever reported due to this choice of versions and
polyfills, we have two options to fix them:

* Tighten the minimum version constraints so that the affected browsers
  are considered legacy instead of modern.

* Include the missing `core-js` polyfills for all modern browsers.
2018-01-22 18:07:54 -05:00
Ben Newman
62f304bdbc Send dynamic modules appropriate for web.browser[.legacy].
Just as the URLs of static JS resources depend on request.browser, so too
must dynamic modules be loaded from the correct build directory based on
the user agent string of the __meteor__/dynamic-import/fetch HTTP request.
2018-01-22 18:07:54 -05:00
Ben Newman
18ab7e9b39 Enable useBuiltIns option when compiling for modern JS environments.
Background:
https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime#usebuiltins
242538dea1
855d5dda80
2018-01-22 18:07:54 -05:00
Ben Newman
a67c0c7ac9 Record location of decisive calls to setMinimumBrowserVersions.
cc @hwillson
2018-01-22 18:07:54 -05:00
Ben Newman
969e1b37f0 Include Promise polyfill only in web.browser.legacy bundles. 2018-01-22 18:07:53 -05:00
Ben Newman
9424bf08c3 Try loading SockJS dynamically after native WebSocket errors.
To save size in modern browsers, JavaScript bundles built for the
web.browser architecture no longer statically include the SockJS library.
That's safe as long as native WebSockets actually work, but what if
there's a problem with the network that necessitates falling back to
long-polling or some other SockJS strategy?

In those cases, we can load SockJS using a dynamic import(), which is a
little slower than including it in the bundle, but that's OK because the
module will be permanently cached in IndexedDB in production, and falling
back to SockJS should be rare in modern browsers anyway.

Note that this trick would not be possible if the implementation of
dynamic import() still required a socket connection! (#9384)
2018-01-22 18:07:53 -05:00
Ben Newman
bfbb8baf5f Add "/__arch" prefixes to URLs in tools/isobuild/bundler.js.
This avoids the need to add architecture-specific prefixes in
webapp_server.js, and also fixes dynamic module source map URLs.
2018-01-22 18:07:53 -05:00
Ben Newman
a7cdc7004d Make dynamic module HTTP response JSON more human-readable. 2018-01-22 18:07:53 -05:00
Ben Newman
c300f65859 Fix "compiler plugins caching" self-tests for web.browser.legacy. 2018-01-22 18:07:38 -05:00
Ben Newman
e89c946a7e Fix modules self-tests for web.browser.legacy. 2018-01-22 17:56:55 -05:00
Ben Newman
89eaedc749 Fix meteor show <package> self-tests for web.browser.legacy. 2018-01-22 17:56:54 -05:00
Ben Newman
05ef0a6602 Fix compiler plugins self-tests for web.browser.legacy. 2018-01-22 17:56:54 -05:00
Ben Newman
4a4b4f93a9 Fix long-standing bug due to improper use of _.has on an array.
This traces back to my commit a9fde48ca8.
The problem went unnoticed because the only symptom was that duplicate
files were not properly reported.

The "compiler plugins - addAsset" self-test checks for the "Duplicate
source file" error, and was passing until recently, but began failing
after I fixed a bug in the forAllMatchingArchs function that allowed
duplicate callbacks for the same architecture.
2018-01-22 17:56:54 -05:00
Ben Newman
d3b6d5dc4b Upgrade lolex (test) npm dependency of ddp-client to version 2.3.1.
May help prevent the problem that occurred in this Circle CI test run,
since lolex was the package with hash sha1-LycSsbwYDendzF06epbvPAuxYq0=:
https://circleci.com/gh/meteor/meteor/12641
2018-01-22 17:56:54 -05:00
Ben Newman
187c9dce06 Prevent any version of PhantomJS from being considered "modern."
We'll need to set up BrowserStack or headless Chrome tests to exercise
modern JS bundles. It is still very valuable to run tests with
web.browser.legacy in PhantomJS, because most day-to-day development
browsers qualify as "modern," and we don't want "legacy" browsers to
become a blindspot.
2018-01-22 17:56:54 -05:00
Ben Newman
25cbf3c918 Remove no-longer-necessary shim-common package.
Now that both sockjs-shim and es5-shim are using the web.browser.legacy
system instead of injecting <script> tags with the server-render package,
these shared utilities are no longer used anywhere.
2018-01-22 17:56:54 -05:00
Ben Newman
19cd3406f8 Collapse sockjs-shim into socket-stream-client with web.browser.legacy. 2018-01-22 17:56:53 -05:00
Ben Newman
443acfaf5d Use web.browser.legacy instead of server-render to load es5-shim. 2018-01-22 17:56:53 -05:00
Ben Newman
3940488b97 Fix an http test failing due to new static resource URL prefixes. 2018-01-22 17:54:44 -05:00
Ben Newman
8f921a4b87 Prepend prefix to all static URLs, even for WebApp.defaultArch. 2018-01-22 17:54:43 -05:00
Ben Newman
f3053e253a Add architecture prefix to static resource URLs in boilerplate. 2018-01-22 17:54:43 -05:00
Ben Newman
18a3d0fd4f Load bundle-visualizer style.css dynamically. 2018-01-22 17:54:43 -05:00
Ben Newman
6c5c386c4a Allow serving CSS for all client architectures. 2018-01-22 17:54:43 -05:00
Ben Newman
911dae81bb Expose Meteor.isModern on both client and server. 2018-01-22 17:54:43 -05:00
Ben Newman
3a17a032c7 Leverage web.browser.legacy for ecmascript-runtime-client. 2018-01-22 17:54:43 -05:00
Ben Newman
e18ef9eb0e Use isModern in webapp to determine which boilerplate to generate.
Surely it can't be this easy, can it?
2018-01-22 17:54:42 -05:00
Ben Newman
2add13e2d4 Introduce package for specifying minimum "modern" browser versions. 2018-01-22 17:54:42 -05:00
Ben Newman
7fceffbe00 Avoid duplicating calls in forAllMatchingArchs. 2018-01-22 17:54:42 -05:00
Ben Newman
a94db9b6ae Convert PackageAPI to an ECMAScript class. 2018-01-22 17:54:42 -05:00
Ben Newman
ed28140071 Support a new web.browser.legacy platform. 2018-01-22 17:54:42 -05:00
Ben Newman
f6ce506fbd Revoke eagerness of overridden api.mainModule files. 2018-01-22 17:54:41 -05:00
Ben Newman
1fec23f3b7 Always include es5-shim in Cordova JS bundles. (#9566)
Since Cordova renders boilerplate HTML at build time, and doesn't use the
server-render system through the webapp package, it's important that we
include es5-shim (and sham) statically for Cordova clients.

This logic will go away once we have the web.browser.legacy system to
control differential bundling (#9439), but for now it's necessary for any
Cordova clients that still don't have full ECMAScript 5 support.
2018-01-22 17:49:22 -05:00
Ben Newman
c0c2aa32d3 Remove stray packages/deprecated/stylus/.versions file. 2018-01-22 17:32:33 -05:00
Ben Newman
818ef0ed6e Merge pull request #9565 from meteor/undelete-deprecated-stylus-package-to-fix-caching-bug
Bring back deprecated stylus package in order to fix a caching bug.
2018-01-22 17:23:48 -05:00
Ben Newman
cb77875f38 Generate MultiFileCachingCompiler .cache filenames based on getCacheKey. (#9564)
Previously, .cache filenames were simply a hash of the absolute path of
the inputFile, which allowed for cache collisions (on disk) between the
same file compiled for different architectures (web.browser, os.*, ...).
Now, the .cache filenames are generated based on whatever information the
compiler plugin deems uniquely identifying about the input file: whatever
is returned from getCacheKey, plus the absolute path of the file.
2018-01-22 17:17:51 -05:00
Ben Newman
41161774d6 Bump stylus patch version to 2.513.14 and update references. 2018-01-22 16:28:04 -05:00
Ben Newman
f1f287893a Include inputFile.getArch() in StylusCompiler cache key.
Similar to this CachedCoffeeScriptCompiler change:
620689f7de

And this LessCompiler change: 8cadd4e215
2018-01-22 16:24:27 -05:00
Ben Newman
a5fc5b030e Bring back deprecated stylus package in order to fix a caching bug.
This code was recently removed in PR #9445, with this commit:
d644705aa8

Rather than removing deprecated code entirely from the codebase, I think
it's sufficient to keep it in packages/deprecated, and print a deprecation
notice whenever the package is used. This way it's clear that developers
should migrate to other similar packages, but we can still release
important patches for those who haven't been able to migrate yet.

cc @hwillson @abernix
2018-01-22 16:19:55 -05:00