Commit Graph

7280 Commits

Author SHA1 Message Date
Ben Newman
a102e5fe37 Use optimisticStatOrNull in readAndStatDirectory.
This drastically (by more than half) cuts down the number of calls to
files.stat that occur during PackageSource#_findSources scanning.
2019-09-23 12:02:32 -04:00
Ben Newman
48d27202e7 Skip watching output files without absPath or sourcePath properties.
https://github.com/meteor/meteor/pull/10522#issuecomment-533393100
2019-09-22 11:50:52 -04:00
Ben Newman
9cba123401 Restore CLI progress messages by revisiting progress.ts conversion.
I noticed recently that progress messages were no longer displayed (though
the ASCII spinner was still animating). I bisected the problem to the
progress.ts conversion in #10650, and I attempted to reproduce the
conversion, step by step. The problem ended up being the renaming of
._title to .title, which was a mistake because external code accesses
progress._title. Once I updated those invasive access points, progress
messages began displaying once again.
2019-09-19 19:01:33 -04:00
Ben Newman
df3fac2e1f Sanitize risky whitespace characters to recover from failed JSON.parse.
Partial alternative to using json5, which we tried in commit
5124cb495c, which was recently reverted due
to performance concerns: 0e19c365a8.

Should solve the specific problem reported in #10688.
2019-09-19 16:14:56 -04:00
Ben Newman
0e19c365a8 Revert "Use json5 for optimisticReadJsonOrNull."
This reverts commit 5124cb495c.

Perhaps unsurprisingly, JSON5 is much slower than JSON, so much so that
"other optimisticReadJsonOrNull" has become the single most expensive leaf
when building one of our internal applications. We will have to find
another solution.
2019-09-19 15:15:47 -04:00
Ben Newman
d0781233e8 Install typescript in devDependencies of skel-typescript.
This is important so that tools like VSCode will pick up the correct
version of the TypeScript SDK, rather than whatever default version was
installed with VSCode.
2019-09-19 13:22:22 -04:00
Ben Newman
2468d17fec Allow creating Meteor apps with --typescript skeleton.
Just as developers can run

  meteor create --react my-react-app
  meteor create --minimal my-minimal-app
  meteor create --bare my-bare-app
  meteor create --full my-full-app

they can now run

  meteor create --typescript my-typescript-app

to produce a new TypeScript application, based on the --react application,
configured using a recommended tsconfig.json file.

This app represents the current best/simplest-known way to set up a
Meteor-compatible TypeScript application, but it is still very much a work
in progress. Please feel free to submit pull requests to improve it, or
create issues to discuss how it should work.

For example, the community-maintained @types/meteor package covers all the
core packages used by this starter application, but it has not been
updated in a while, so there will no doubt be meteor/* packages with
missing types. In future versions, Meteor should ideally generate the
appropriate .d.ts files from TypeScript package source code, so that no
separate @types/meteor/* declarations need to be maintained.
2019-09-19 09:27:23 -04:00
Ben Newman
f9c498adb8 Improve the shouldWatch function in tools/fs/optimistic.ts. (#10693)
This function determines whether the optimistic caching system should
subscribe to file change notifications for a given path.

Note that Meteor has other ways of watching for file changes (e.g. the
WatchSet abstraction), as well as other mechanisms for invalidating cached
results, so time and resources can often be saved by returning false here,
if we know that the path will be watched in other ways.

Improvements:

- Add METEOR_PROFILE instrumentation to the shouldWatch implementation.

- Stop exporting shouldWatch, since it is no longer used anywhere else in
  the codebase.

- Return false early to avoid watching files inside the .meteor directory,
  a significant shortcut.

- Allow watching files in application node_modules directories that are
  not located directly in the root application directory (closes #10664).
2019-09-18 16:19:02 -04:00
Ben Newman
7bc5b5b061 Use dep API from optimism instead of wrap in a few places.
Background: https://github.com/benjamn/optimism/pull/50
2019-09-18 12:08:30 -04:00
Ben Newman
5124cb495c Use json5 for optimisticReadJsonOrNull.
Because json5 is more tolerant of non-standards-compliant input, it has no
trouble with \t tab characters outside of string literals, so this change
should fix issue #10688.

Note that json5 is already installed in dev_bundle/lib/node_modules/json5,
because it is a dependency of @babel/core, so we don't need to rebuild the
dev bundle immediately, though it would be a good idea to do so before the
next beta/RC release.
2019-09-07 21:04:29 -04:00
Ben Newman
7bf1b3cbc5 Update 'meteor create --react' react[-dom] versions to 16.9.0. 2019-09-06 18:45:04 -04:00
Ben Newman
cf5db3626e Update meteor-babel to version 7.6.0. 2019-09-06 18:40:50 -04:00
Ben Newman
e4101e1f0a Go back to using LRU cache for findImportedModuleIdentifiers.
Should fix #10674.
May help with #10608.

cc @houshuang @klaussner
2019-09-06 18:29:14 -04:00
Ben Newman
7155feaaa1 Test dependency-tree-based client refresh detection.
Part of #10686.
2019-09-06 17:21:57 -04:00
Ben Newman
b3d88944ae Explicitly track potentially unused WatchSet files.
The previous implementation simply avoided calling watchSet.addFile for
potentially unused files, trusting that addFile would be called later if
the file was eventually used. However, this strategy left the contents of
watchSet.files incomplete for tasks such as IsopackCache._checkUpToDate,
which require full information about all files, even the ones that might
not be used by the bundle. The new strategy maintains metadata about
potentially unused files in a separate data structure, which will be
merged/cloned/serialized/deserialized along with other WatchSet data.
2019-09-06 16:24:41 -04:00
Ben Newman
4084848d2f Add files to unibuild.watchSet only if needed by unibuild.arch.
Most importantly, this change means that changes to files not used by the
server bundle will not trigger a server restart.

Fixes #10449 by implementing the strategy I described in this comment:
https://github.com/meteor/meteor/pull/10414#issuecomment-481293530
2019-09-05 18:44:19 -04:00
Ben Newman
5957e046fb Prevent cordova-lib from using its own copy of graceful-fs. 2019-09-05 15:22:52 -04:00
Ben Newman
e497085474 Update meteor-babel and @babel/{runtime,parser} to latest versions.
Among other benefits, this should address #10622.
2019-07-30 14:03:58 -04:00
Michael Newman
26c0d5cf16 Convert tools/console/progress.js to TypeScript (#10650) 2019-07-26 09:22:19 -04:00
Chiciuc Nicușor
a6d454b760 Convert func-utils.js to TypeScript (#10631) 2019-07-26 09:21:23 -04:00
Michael Newman
e0eb210194 Convert tools/utils/processes.js to tools/utils/processes.ts (#10627) 2019-07-25 17:34:13 -04:00
Michael Newman
f8ba7a96fe Convert tools/utils/mongo-exit-codes to TypeScript (#10625) 2019-07-21 12:02:29 -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
a811d1255b Convert tools/isobuild/import-scanner.js to TypeScript. (#10635) 2019-07-19 18:34:03 -04:00
afrokick
2db8d07791 Convert tools/shell-client.js to TypeScript (#10619) 2019-07-16 11:10:17 -04:00
Chiciuc Nicușor
a1184bdea3 Add @types/semver@5.4.0 to dev-bundle. (#10633) 2019-07-16 11:07:40 -04:00
Ben Newman
23b67d9a47 Revert "Temporarily disable SIGKILL self-test on devel branch."
This reverts commit 5c32331591.

This test is passing reliably on the release-1.8.2 branch, so we should
keep running it there.
2019-07-15 12:42:03 -04:00
Ben Newman
7e82cf57a8 Merge branch 'devel' into release-1.8.2 2019-07-15 12:41:44 -04:00
Ben Newman
5c32331591 Temporarily disable SIGKILL self-test on devel branch. 2019-07-15 12:41:18 -04:00
Ben Newman
e299c86ecf Assume npx (as in meteor npx ...) is a valid command.
Sometimes, before dev_bundle/bin/.meteor-commands.json has been written, a
command like `./meteor npx tsc` can fail because `npx` is not blessed in
the same way `node` and `npm` are. Since `npx` is a core tool that we want
folks to be able to use without confusion, I think it makes sense to
include it in the list of known subcommands.
2019-07-15 12:32:49 -04:00
Ben Newman
122f7e4d2d Update underscore to v1.9.1 and install @types/underscore. 2019-07-15 11:39:35 -04:00
Michael Newman
8af53f97d6 Convert tools/utils/eachline.js to TypeScript (#10614)
Thanks to @menewman for tackling this small but important module!
2019-07-15 11:34:45 -04:00
Ben Newman
06b5f32215 Make meteor npx tsc run without errors, and test it.
This makes type checking possible without an external tool like VSCode.
2019-07-15 11:16:58 -04:00
Ben Newman
4334fd4ceb Convert tools/isobuild/resolver.js to TypeScript. 🎉 2019-07-10 12:53:28 -04:00
Ben Newman
4e894663f5 Add basic test of TypeScript support to modules test app. 2019-07-07 19:29:34 -04:00
Ben Newman
01fb509fff Implement an official typescript compiler plugin. 2019-07-07 19:29:34 -04:00
Ben Newman
d24a2dbb52 Abort _emitResources if buildmessage.jobHasMessages(). 2019-07-07 17:35:26 -04:00
Ben Newman
c926e9ebd7 Fix importing of unanticipated .mjs modules in ImportScanner.
Should fix this problem reported by @arggh:
https://github.com/meteor/meteor/pull/10522#issuecomment-508908306
2019-07-06 12:38:04 -04:00
Ben Newman
df4e54a80d Test that the ganalytics npm package is importable.
As reported by @arggh in this comment:
https://github.com/meteor/meteor/pull/10522#issuecomment-508908306
2019-07-06 12:38:04 -04:00
Ben Newman
cdafcb8ebc Avoid transpiling .d.ts files when bundling meteor-tool. 2019-07-06 12:38:04 -04:00
Ben Newman
88b085d8e1 Fix type errors now that Profile(name, fn) returns typeof fn. 2019-07-06 09:19:14 -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
d8436bb635 Convert tools/fs/safe-watcher.js to TypeScript.
This completes the TypeScript conversion of the tools/fs directory. 🎉
2019-07-05 18:58:18 -04:00
Ben Newman
85d8db7f1d Fix return types of fs.{watchFile,unwatchFile}.
These methods return a StatWatcher object with various useful methods, but
@types/node apparently gets this completely wrong, assuming void.
2019-07-05 18:48:16 -04:00
Ben Newman
8958cbc5e9 Convert tools/fs/watch.js to TypeScript. 2019-07-05 17:50:20 -04:00
Ben Newman
528b549460 Convert tools/fs/optimistic.js to TypeScript. 2019-07-05 12:29:19 -04:00
Ben Newman
55bde8acb8 Improve generic types in tools/fs/files.ts. 2019-07-05 12:28:57 -04:00
Ben Newman
8259c75421 Tweaks to pacify TypeScript in tools/fs/files.ts. 2019-07-04 17:25:41 -04:00
Ben Newman
101eea015f Update meteor-node-stubs npm dependency to v1.0.0. 2019-07-04 16:36:27 -04:00
Ben Newman
6979b55dfc Update @babel/runtime to latest version in remaining test apps. 2019-07-04 16:23:12 -04:00