Commit Graph

7206 Commits

Author SHA1 Message Date
Ben Newman
2dae9be561 Regression test that the graphql package can be imported. 2019-06-25 14:25:23 -04:00
Robert Lowe
f214eba7d9 Allow for METEOR_GIT_COMMIT_HASH in lieu of findGitCommitHash's execFile (#10586) 2019-06-23 11:54:47 -04:00
Ben Newman
88004d4649 Add a basic regression test of issue #10563. 2019-06-20 12:11:29 -04:00
Ben Newman
9f88fa35c3 Use full power of compiler plugins to compile unanticipated modules.
Instead of merely supporting ECMAScript module syntax via Reify, we should
really be compiling unanticipated modules (typically within node_modules)
using the same logic that the rest of the application uses.

Note: this processing applies only to .js files for now, since that's what
the ImportScanner works with.

Should help with #10563.
2019-06-20 12:11:29 -04:00
Ben Newman
a2f5e1c3e5 Make PackageSourceBatch ResourceSlot creation more reusable. 2019-06-20 12:11:29 -04:00
Ben Newman
bd89ac8d1b Merge branch 'devel' into release-1.8.2 2019-06-19 13:19:11 -04:00
Filipe Névola
ce14282304 Enable running multiple Cordova apps from same application source (#10577)
Fixes #10576.
2019-06-19 13:07:25 -04:00
zodern
d0de6e1176 Add assets to watchSet, again (#10565)
Follow-up to #10452.
2019-06-17 12:51:33 -04:00
Ben Newman
f0d39b86e6 Avoid module.useNode() for packages with "module" entry points. 2019-05-17 11:22:23 -04:00
Ben Newman
9fc6642f5a Compile unhandled JS imports for server bundles, too. 2019-05-17 10:59:17 -04:00
Ben Newman
28d74dcc9f Use Reify to compile dynamic import(...). 2019-05-15 19:12:09 -04:00
Ben Newman
d5d7413a38 Compile all unhandled node_modules client JS with Reify.
Although I hoped we could be clever about which npm packages we compiled,
there are already too many exceptions to the rules (for example, not all
npm packages that contain ESM code have a "module" entry point in
package.json).

It seems safer simply to compile all modules imported from node_modules
that have not already been handled by compiler plugins, and trust that our
disk+memory caching system will provide acceptable build performance.

Should help with #10547, #10544, and #10546.
2019-05-10 15:43:48 -04:00
Ben Newman
646fa4e3ee Consider only named packages in optimisticLookupPackageJson.
Sometimes (very rarely) an npm package may contain package.json files
other than the one found in the root package directory. For example, the
date-fns@2.0.0-alpha.27 package includes a small package.json file for
each of its functions (date-fns/someDateFn/package.json) that contains
only { sideEffects, typings }, for whatever reason. These package.json
files clearly do not serve the same purpose as date-fns/package.json, and
it would be convenient to ignore them in optimisticLookupPackageJson. The
easiest way I can see to accomplish that is to ignore package.json files
that do not have a "name" property, since any package.json file that
governs an actual package must have a name.

Should fix #10547.
2019-05-06 17:23:06 -04:00
Ben Newman
d9fd447e6f Avoid using fs.unlinkSync on directories.
Should help with #10549.
2019-05-05 19:37:45 -04:00
Ben Newman
f4af3ab2fa Backstop ESM module compilation with Reify in the ImportScanner.
Instead of compiling ESM syntax in node_modules using compiler plugins,
the ImportScanner can provide "native" support for ESM syntax by using
Reify to quickly compile just the import/export syntax in any imported
modules that were not already handled by compiler plugins.

Since this code runs every time the app is built, it should not matter
which version of Meteor was used to publish a package. Compared to the
previous implementation based on PackageSource#_findSources and unibuild
JSON files (#10545), this implementation should have far fewer
compatibility concerns, as well as being faster thanks to not processing
or compiling modules until the ImportScanner determines that they are
actually imported.

Though the number of files that get compiled by this system should be
relatively small for now, to maintain good performance, the results of the
compilation are cached on disk and in memory.
2019-05-05 19:10:13 -04:00
Ben Newman
72c704bcae Revert using _findSources to scan .npm/package/node_modules.
After much thought, I believe this implementation (#10545) would have
caused severe compatibility problems when using packages published with
earlier versions of Meteor in a Meteor 1.8.2 app, or when publishing
packages with Meteor 1.8.2 for use with earlier Meteor versions.

Specifically, this implementation relied on writing the additional
.npm/package/node_modules resources found by _findSources into the
unibuild JSON file(s), and there just wasn't any good way to make sure the
new JSON format could be safely consumed by previous Meteor versions.

Even if we found a way to hide the new resources from older versions of
Meteor, perhaps by putting them in a new/different property of the
unibuild JSON file, packages published with older Meteor versions might
try to load an npm package with a "module" field without realizing the
code must be compiled, which would likely cause a syntax error in Meteor
1.8.2, since the "module" field always gets preference over the "main"
field of package.json (in Meteor 1.8.2).
2019-05-05 19:03:30 -04:00
zodern
da323022b1 Do not remove source map url comments in public files (#10525) 2019-05-05 15:23:13 -05:00
Ben Newman
683d23cdee Bump compiler.BUILT_BY and LINKER_CACHE_SALT to force rebuild. 2019-05-04 18:08:49 -04:00
Ben Newman
5d0a1200c7 Allow .npm/package/node_modules to be compiled in Meteor packages.
When I implemented support for the "module" entry point in package.json
files for client code in #10541, I modified PackageSource#_findSources to
include files found in node_modules that need to be compiled, but my
implementation considered only "local" node_modules directories, like the
one in the application root directory, while neglecting the private
.npm/package/node_modules directories that many Meteor packages have.

This commit includes .npm/**/node_modules when _findSources is scanning a
Meteor package, which should solve issues like #10544, where a Meteor
package imports an npm package that was installed with Npm.depends, and
that npm package has a "module" field in its package.json file, pointing
to an ESM entry point module, but the ESM syntax was not appropriately
compiled, leading to parse errors like "Unexpected token export".

Before lazy compilation was introduced in Meteor 1.7 (#9983), including
the node_modules directories of Meteor packages would likely have been a
big problem for build performance, since there would be that many more
modules to compile. It's still worth making sure this change doesn't
regress build performance for other reasons, but I'm reasonably confident
lazy compilation will save us here, unless there are just too many npm
packages installed via Npm.depends that export ESM modules.
2019-05-04 18:08:49 -04:00
Ben Newman
9a4fa16db9 Merge branch 'devel' into release-1.8.2 2019-05-03 14:29:48 -04:00
zodern
eb5c0b5eed Fix checking for a rerender timeout (#10523) 2019-05-02 19:35:44 -04:00
Ben Newman
f166f226d8 Support the "module" field of package.json for client code. (#10541)
Supporting "module" in package.json for server code is not advisable
because Node.js will be adopting the "type":"module" convention instead,
and in the meantime we need to maintain consistency with Node's module
resolution rules, which only currently pay attention to "main":
https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff
2019-05-02 18:30:13 -04:00
Ben Newman
35ca6980dc Use is-reachable to detect child process health in self-test.
On Linux, child processes that have exited may remain as <defunct>
"zombie" processes, which prevents process.kill(childPid, 0) from
throwing, so we need a different trick for detecting whether the child
process is still alive.
2019-05-02 17:10:41 -04:00
Ben Newman
4b0e4f8b0d Add package.json to tools/tests/apps/app-prints-pid.
The SIGKILL self-test in tools/tests/run.js has been failing recently
because @babel/runtime can't be found when the app-prints-pid app starts
up, which prevents the app from polling the parent process correctly.
2019-05-02 15:24:57 -04:00
Ben Newman
e680804ffc Wrap fs.copyFile[Sync] rather than reimplementing it. (#10542)
Should help prevent noYieldsAllowed errors due to the Promise#await call
in the removed copyFileHelper function, which is what caused 1.8.2-beta.0
to fail to publish on Linux (reported in #10540).
2019-05-02 13:48:02 -04:00
Ben Newman
b0a8e1bfaf Increase arbitrary SIGKILL timeout to make self-test more robust. 2019-05-02 13:44:49 -04:00
Ben Newman
114a348bb3 Convert programs/server/debug.js to TypeScript.
Another tiny module (like tools/isobuild/css-modules.ts) that proves we
can use TypeScript in programs/server/* code.
2019-04-26 18:55:08 -04:00
Ben Newman
c9ba0f3a22 Install latest Reify runtime in programs/server/main.js.
Also updated meteor-babel in the dev bundle to depend on reify@0.18.1, to
be consistent with the version used by server code.
2019-04-26 18:55:08 -04:00
Ben Newman
4ff27f8a52 Use Builder#copyTranspiledModules to compile .js and .ts files with Babel. 2019-04-26 18:55:07 -04:00
Ben Newman
59c66baa9b Convert tools/static-assets/server/mini-files.js to module. 2019-04-23 19:21:57 -04:00
Ben Newman
f0192a82d9 Stop using mini-files.js in non-Babel-compiled code. 2019-04-23 19:21:57 -04:00
Ben Newman
154ca31faa Enable compilation of tools/static-assets/server. 2019-04-22 13:50:07 -04:00
Ben Newman
543bed4e0b Convert tools/isobuild/css-modules.js to TypeScript.
Choosing this module first because it's tiny and only imported twice.
2019-04-14 14:00:48 -04:00
Ben Newman
798a155c64 Enable Babel-powered TypeScript compilation of meteor/tools.
These changes pave the way for incrementally converting the implementation
of Meteor's command-line tool to TypeScript, which should have profound
benefits for self-documentation via types, as well as substantially
improving navigability and approachability for community contributors.

Just imagine being able to auto-complete the fields of the various
File-like classes currently floating around the codebase, instead of
having to track down their implementations every time. TypeScript was
designed with large projects like Meteor in mind, and it seems
increasingly irresponsible to forgo the benefits of a type system by
relying on the expertise of a few core contributors who know the codebase
inside and out. I am one of those few people, and I am very excited to
have the assistance of a type system, so I can only imagine how
transformative and empowering it will be for everyone else.

If you've ever wanted to get involved in core Meteor development, picking
a few meteor/tools modules to convert to TypeScript is a great way to get
to know that part of the codebase, while also making things easier for
everyone else who interacts with that code in the future.

Because we already compile meteor/tools using Babel, it makes the most
sense to use Babel's @babel/preset-typescript to compile .ts files:
https://babeljs.io/docs/en/next/babel-preset-typescript.html

Using Babel also means we get to keep all of our current advanced
compilation strategies, such as using Reify to compile module syntax:
https://www.npmjs.com/package/reify

Since we're using Babel, the meteor/tools/tsconfig.json file exists mostly
for the benefit of external tools like VSCode, rather than as a source of
truth for compilation behavior.

Despite our existing convention of including explicit .js file extensions
when importing modules, TypeScript and VSCode strongly encourage omitting
the file extension, so the import can be resolved to a .ts file in
development or a .js file when compiled. Although I find this ambiguity
somewhat unfortunate, it makes sense to follow community norms, at least
until Node.js begins supporting .ts modules by default.
2019-04-14 13:06:49 -04:00
Ben Newman
5e24494e01 Update dynamic import test app to Meteor 1.8.1 and meteor-node-stubs@1.0.0. 2019-04-10 19:18:36 -04:00
Ben Newman
07815583f1 Update modules test app to Meteor 1.8.1 and meteor-node-stubs@1.0.0. 2019-04-10 19:18:36 -04:00
Ben Newman
466cda693e Use wrapYieldingFiberMethods from @wry/context. 2019-04-10 18:48:10 -04:00
Ben Newman
5adb7c64ab Wrap Fiber.prototype.{run,throwInto} as well as Fiber.yield.
ddebed9b8a/fibers.js (L97-L100)
2019-04-10 17:14:26 -04:00
Ben Newman
0383f01c63 Update optimism and use noContext to isolate Fiber contexts.
The optimism package no longer knows anything about Fibers, but it does
export various helpers for managing execution contexts, one of which
(noContext) allows us to censor the current context for the duration of a
function call. By wrapping Fiber.yield with noContext, we keep distinct
Fibers from accidentally registering cache dependencies on one another.
2019-04-10 14:42:34 -04:00
Christian Klaussner
2b21a901a5 Wait until Mongo primary node is writable (#10500)
Using the `isMaster` command instead of checking the replica set member state is more reliable because a node can be a primary without being writable.

Fixes #10381 and #9026.
2019-03-19 19:12:12 -04:00
Ben Newman
038e35357e Apply reasoning from PR #10402 to package code as well.
Follow-up to fb2146cb3b.

Should fix #10481.
2019-03-19 14:02:03 -04:00
Ben Newman
44e293b741 Merge branch 'devel' into release-1.8.1 2019-03-19 13:10:35 -04:00
Ben Newman
55d1ffa3f2 Revert "Skip regenerating main bundle when only a dynamic file changed." (#10497)
This reverts commit 95a1f54cce.

Although at first this commit seemed like a nice optimization, after
digging into #10496 I was reminded that the main bundle includes the paths
and hashes of available dynamic modules, so rebuilding the main bundle is
important even when only dynamic modules have changed.

Many thanks to @arggh for testing 1.8.1-beta.20 and putting together the
https://github.com/arggh/meteor-bundler-issue reproduction.

Should fix #10496 and #10494.
2019-03-19 12:22:54 -04:00
georgyberdyshev
65747fc29f Updated meteor create --list Angular boilerplate name and URL. (#10363) 2019-03-15 11:23:46 -04:00
Jan Dvorak
ae397a3632 Fix #10428 facebook permissions (#10429)
* Fix #10428 facebook permissions 🛂

* Add missing semicolon in tools/upgraders.js
2019-03-15 11:08:01 -04:00
Simon Schick
40e8da227e Added an environment variable to determine if Meteor will restart automatically (#10465) 2019-03-15 11:01:13 -04:00
Ben Newman
642be6dc38 Attempt to fix tests by reverting puppeteer from 1.12.1 to 1.6.2.
Tests have started failing for reasons that may be related to puppeteer's
Meteor process management: https://circleci.com/gh/meteor/meteor/31035

Since I can't identify any other possible causes, using the same version
of puppeteer that other tests use (e.g. modules, dynamic-import) seems
like a reasonable first step.

Also updated puppeteer in tests/apps/app-config/package-lock.json to
version 1.6.2 (was 1.3.0), in an attempt to fix some unhandled promise
rejection warnings: https://circleci.com/gh/meteor/meteor/31063
2019-03-04 14:28:12 -05:00
Ben Newman
bb564dd93f Address my own (minor) review feedback. 2019-02-28 14:55:38 -05:00
zodern
95a1f54cce Skip regenerating main bundle when only a dynamic file changed. 2019-02-28 14:55:38 -05:00
zodern
7b2adcb9da Cache stringified prelinked output for dynamic files. 2019-02-28 14:55:38 -05:00