Commit Graph

86 Commits

Author SHA1 Message Date
Jan Dvorak
b6e127cfc9 Minor tools update
Replace underscore where easy and feasible & other minor modernization that I came across.
2021-06-25 00:36:03 +02:00
Jan Dvorak
456d62eb91 Merge pull request #11411 from meteor/update-meteor-babel
Meteor Babel 7.11.0
2021-05-10 22:15:22 +09:00
Jan Dvorak
3abb6f1512 Fix old import 2021-05-08 14:00:59 +02:00
Jan Dvorak
8ec9f0b7be meteor-babel => @meteorjs/babel 2021-05-07 19:43:37 +02:00
zodern
b0fed062ae Fix env var name 2021-04-26 14:33:19 -05:00
zodern
6038bd5c59 Add cache for reify runtime compiler 2021-04-26 13:57:12 -05:00
Brian Mulhall
c68757a52c remove the xmlbuilder isopack and all references to it in the code 2020-02-25 15:44:44 -05:00
Ben Newman
4fe8af4193 Use require("meteor-babel/register").excludeFile.
The excludeFile API was introduced in meteor-babel@7.8.1:
bfded57377

Modules that are evaluated before meteor-babel/register is configured
should not be transformed by meteor-babel, even if they are imported again
later, after meteor-babel/register has been configured.

If my analysis is correct, this change should prevent the dreaded

  Must export a default export when using ES6 modules.

error, as seen most recently in
https://travis-ci.org/meteor/meteor/builds/638030190
and https://circleci.com/gh/meteor/meteor/40863.
2020-01-16 12:33:54 -05:00
Ben Newman
407b2d17cb Remove eslint and pre-commit hook to fix npm security warnings. 2019-11-14 17:34:29 -05:00
Ben Newman
1cf59867b2 Remove no-longer-necessary noYieldsAllowed wrapper from loadIsopackage. 2019-10-24 19:36:32 -04:00
Paulo Mogollón
2ae2690f3a Convert tools/utils/archinfo.js to TypeScript. (#10624)
* Updated code to use modern JS
* Added types
* Stopped using 2 underscore functions (1 remaining)
2019-07-21 12:01:24 -04:00
Ben Newman
769337551e Convert tools/tool-env/profile.js to TypeScript.
Unfortunately, this conversion triggered an error due to one of the
shortcomings of the Babel implementation of TypeScript:

SyntaxError: /tools/tool-env/profile.ts: Namespace not marked type-only declare. Non-declarative namespaces are only supported experimentally in Babel. To enable and review caveats see: https://babeljs.io/docs/en/babel-plugin-transform-typescript
  278 | }
  279 |
> 280 | export namespace Profile {
      |                  ^
  281 |   export let enabled = !! process.env.METEOR_PROFILE;
  282 |
  283 |   export function time<TResult>(bucket: string, f: () => TResult) {
    at File.buildCodeFrameError (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/core/lib/transformation/file/file.js:261:12)
    at transpileNamespace (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/plugin-transform-typescript/lib/namespace.js:25:25)
    at PluginPass.TSModuleDeclaration (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/plugin-transform-typescript/lib/index.js:271:32)
    at newFn (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitMultiple (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/context.js:85:17)
    at TraversalContext.visit (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/context.js:144:19)
2019-07-06 09:18:35 -04:00
Ben Newman
8958cbc5e9 Convert tools/fs/watch.js to TypeScript. 2019-07-05 17:50:20 -04:00
Ben Newman
5ed64fb1db Remove explicit .js extension from tools/fs/files imports. 2019-07-04 10:32:09 -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
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
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
Ben Newman
3a18f67ac2 Rely on native Node.js Promise implementation.
There's no reason to use a Promise polyfill in Node.js at this point.
2018-11-03 13:58:48 -04:00
Ben Newman
4a688d7ca9 Show web.browser.legacy rebuild time only when METEOR_PROFILE enabled.
In theory, these delayed rebuilds should not even be noticed, so it
doesn't make sense to draw attention to them.
2018-09-05 17:56:57 -04:00
Ben Newman
09950c403b Update reify npm package to version 0.17.2. 2018-07-31 20:48:25 -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
6407e4dafb Update meteor-babel to version 7.0.0-beta.49-1.
Also switching from babelOptions.sourceMap to babelOptions.sourceMaps,
finally: https://babeljs.io/docs/usage/api/#options
2018-05-25 18:43:13 -04:00
Ben Newman
a8b6accb11 Set .babel-cache directory correctly for command-line tool.
This depends on new functionality in meteor-babel@7.0.0-beta.46-3:
d5d2bbf81e
dea6465daf
2018-05-09 16:16:05 -04:00
Jesse Rosenberger
6f01d18252 Change tool "cleanup" module to use ESM format and remove Underscore. 2017-12-12 17:19:42 +02:00
Ben Newman
1a8efdc31f Merge branch 'devel' into release-1.6 2017-10-02 13:44:25 -04:00
Ben Newman
e85c69680d Combine all isopackets to share transitive dependencies. (#9168)
By my calculations, the sum of the sizes of the individual isopackets was
152MB, and the size of the combined isopacket is now just 36MB. That
remarkable difference goes to show how much duplication of transitive
dependencies was happening before this change.

That's a savings of 116MB for the (uncompressed) size of the meteor-tool
package. In Meteor 1.5.x, the meteor-tool package is about 544MB, but in
Meteor 1.6 it's considerably smaller: 373MB. In other words, this change
should reduce those sizes to 428MB (-21%) and 257MB (-31%), respectively.
2017-10-02 13:41:39 -04:00
Ben Newman
cbacc31dde Fix inline source maps in meteor/tools code. 2017-07-22 10:38:15 -04:00
Ben Newman
bd5370dda9 Fix mistaken usage of require(reify/lib/runtime).enable.
Related fix in meteor-babel@0.24.4:
786194734c
2017-07-22 09:17:05 -04:00
Ben Newman
2ae406a61f Enable the Reify runtime API even if meteor-babel/register does not. 2017-07-21 18:59:16 -04:00
Ben Newman
2ca9e322d9 Use Babel options appropriate for Node 8 to compile meteor/tools.
Related to https://github.com/meteor/meteor/pull/8728#issue-232369984,
though these changes apply only to the meteor/tools codebase. We still
need to make similar changes to the babel-compiler package so that
application code will benefit.

The assumption that we're using Node 8 also allows some simplifications to
the runtime polyfills that we use.
2017-07-21 14:07:28 -04:00
Ben Newman
42c41901c5 Call module.runSetters() after any meteor/tools modules load. 2017-05-09 21:23:41 -04:00
Ben Newman
f0355276a5 Remove babel-runtime-specific logic from compiler-plugin.js. 2016-11-02 12:05:33 -04:00
Ben Newman
0993eb664a Preserve own properties from Profile-wrapped functions. 2016-10-24 18:18:03 -07:00
Ben Newman
8e9896cfcf Include server startup timings in METEOR_PROFILE output.
Meteor 1.4.2 has been mostly focused on improving rebuild times, but what
ultimately matters is the time from changing a file to being able to make
requests against the restarted server, and any code that runs before
server startup should be considered part of that critical path.

If you have a lot of packages, and they do non-trivial work on startup,
this commit should give you much better insight into where time is spent.

Credit to @stubailo for pushing me to provide Meteor developers with
better profiling tools, and thanks to @veered for this specific idea.

Note: because tools/tool-env/profile.js is now loaded as-is by boot.js,
certain ECMAScript features are off-limits, e.g. ...rest params.
2016-10-23 16:36:23 -04:00
Ben Newman
7a18012975 Consult babel-runtime package when discarding helper modules.
The most fool-proof way to tell if a module is provided by babel-runtime
is to load babel-runtime as an isopacket and ask it.

This should fix any remaining issues like this one:
https://github.com/meteor/meteor/pull/7668#pullrequestreview-4379559
2016-10-16 16:40:11 -04:00
Ben Newman
17f79c66ce Search packages/non-core/*/packages for local packages.
Currently this finds only Blaze-related packages, but it does so without
hard-coding "blaze" in tools code.
2016-09-09 13:28:16 -04:00
Ben Newman
c6a54546c2 Avoid hard-coding packages/non-core/blaze in tools code.
Now that the blaze submodule is mounted inside the packages/non-core/
directory, it appears that we no longer have to mention it explicitly in
the localPackageSearchDirs array.
2016-09-09 12:12:43 -04:00
Ben Newman
9001b75f44 Move packages-for-isopackets/blaze to packages/non-core/blaze. 2016-09-09 11:17:43 -04:00
Tom Coleman
edf40c430b Use isopacket packages for self-test also 2016-08-25 13:24:40 +10:00
Tom Coleman
f01653e690 Use submodules for isopacket loading 2016-08-25 12:23:33 +10:00
Ben Newman
36afd7f5c3 Defend global.Promise against misbehaving polyfills. 2016-08-03 15:25:13 -04:00
Ben Newman
c3e73c264c Prevent archinfo.host() from yielding by forcing its result to be cached. 2016-07-14 11:27:55 -04:00
Ben Newman
a9e8cbe267 Move Promise runtime setup into its own module.
Test code was requiring the install-runtime.js module without requiring
the index.js module, so global.Promise was not defined.
2016-07-07 17:01:11 -04:00
Ben Newman
eadb6e65cc Ensure only one Promise constructor is ever used by tools code. 2016-07-07 11:04:18 -04:00
Ben Newman
a5b34af583 Fix babel-runtime/regenerator import in tools runtime setup.
Fixes #7181.
2016-06-16 16:59:58 -04:00
Ben Newman
6aec3603c8 Separate install-runtime.js from install-babel.js. 2016-05-19 17:04:08 -04:00
Ben Newman
d94e7d812d Upgrade dev bundle meteor-promise to 0.7.1. 2016-05-16 18:21:11 -04:00
Ben Newman
cf98e285ac Fix imports of tools/tool-env/isopackets.js.
Fixes #6778.
2016-04-11 12:33:16 -04:00