Commit Graph

211 Commits

Author SHA1 Message Date
Jan Dvorak
8a08a65290 Merge branch 'release-2.3' into remove-compat-bellow-1.0 2021-05-21 15:18:18 +02:00
Filipe Névola
cb00f74cd2 Merge branch 'release-2.3' into release-node-14 2021-05-19 17:34:55 -04:00
Jan Dvorak
e404ab2330 More TS fixes 2021-05-17 19:53:31 +02:00
Jan Dvorak
628397ad78 More TS fixes 2021-05-17 18:54:01 +02:00
Jan Dvorak
351aff785c Fix Typescript type issues 2021-05-17 18:07:39 +02:00
Jan Dvorak
8ec9f0b7be meteor-babel => @meteorjs/babel 2021-05-07 19:43:37 +02:00
Jan Dvorak
87340709b4 Fix bundle and build tests 2021-04-23 17:57:26 +02:00
Jan Dvorak
91ecb1b8c0 Return bundle command & unipackage-pre2 handling 2021-04-23 17:57:01 +02:00
Jan Dvorak
b5b7306bed Remove deprecated code from before v1.0
Remove deprecated code from before Meteor 1.0 that  was documented via XXX COMPAT in comments. Move deprecated packages into the deprecated folder (deps, livedata, srp).
2021-04-23 17:56:05 +02:00
filipenevola
5ed26e96b2 fix BigIntStats error on TypeScript
ignore Operator '&' cannot be applied to types 'number | bigint' and 'number'.
2021-02-23 20:47:20 -04:00
filipenevola
82932230d9 fix BigIntStats error on TypeScript
ignore Operator '&' cannot be applied to types 'number | bigint' and 'number'.
2021-02-23 20:46:38 -04:00
Renan Castro
60b41c357b Update Typescript to 4.1.2 - fix breaking changes 2020-11-26 18:04:06 -03:00
Renan Castro
dbd79ed5ea Update Typescript to 4.1.2 - fix breaking changes 2020-11-26 17:59:50 -03:00
filipenevola
0bcf0f9ec6 Fixes TS2783 on treeHash 2020-10-28 17:38:34 -04:00
filipenevola
fbb62ca9cf Merge branch 'release-1.10.3' into cache-build-before-deploy 2020-07-27 13:27:53 -04:00
filipenevola
bb42fa8137 Adds the option to cache the build on deploy 2020-07-27 11:23:38 -04:00
filipenevola
5ea682449e fixes ts error on files.ts 2020-07-27 11:22:25 -04:00
filipenevola
d01c859cd3 fixes ts error on files.ts 2020-07-24 07:43:35 -04:00
zodern
5e79e56fb7 Fix typescript error 2020-06-24 15:30:35 -05:00
zodern
cbb23cca5a Disable deduplicating watchers by ino on Windows 2020-06-24 15:23:34 -05:00
zodern
cf92ff886b Reduce stats in readAndStatDirectory 2020-06-24 15:19:04 -05:00
zodern
d7b3d2e398 Add files.readdirWithTypes 2020-06-24 15:18:01 -05:00
Ben Newman
9c852da695 Make optimisticLookupPackageJson return array of package.json objects.
Commit 646fa4e3ee fixed #10547 by
restricting optimisticLookupPackageJson to package.json files with a
"name" property, which effectively skipped over intermediate package.json
files with additional properties.

However, in Node.js 12.16.0 (Meteor 1.9.1+), modules evaluated natively by
Node are considered ECMAScript modules if the closest package.json file
has "type": "module" (or has an .mjs file extension). This poses a problem
for the module.useNode() trick (see packages/modules-runtime/server.js),
because ESM modules cannot be imported using require.

For example, recent versions of the @babel/runtime package have a
@babel/runtime/helpers/esm/package.json file for the ESM versions of its
helpers (which specifies "type": "module"), but that package.json file
does not have a "name" property, because it is not the root package.json
file representing the entire @babel/runtime package.

I considered making the "name" restriction configurable, but that would
have fragmented the caching of optimisticLookupPackageJson. Instead, I
made it return an array of all potentially relevant package.json objects,
which can be safely cached.

This means that the caller has to iterate over the array, but there is
only one call site for this function (in tools/isobuild/package-source.js)
right now, so that wasn't too much work.
2020-02-19 15:24:42 -04:00
seke
830b8a40cb Update source-map to 0.7.3
source-map 0.7.0+ has a much faster Rust WASM implementation.
Because this needs to be loaded, the constructor is now asynchronous.
The consumer should also be destroyed after it's no longer needed.
2019-11-26 14:15:33 -05:00
Ben Newman
c24077e65f Allow relative --test-app-path arguments when running test-packages.
https://github.com/meteor/meteor/pull/10772#issuecomment-553517459

The assertion in tools/fs/optimistic.ts was failing if I passed a relative
path for --test-app-path, and passing the path as a second argument when
calling assert made it easier to tell what was going on, so I decided to
keep that change.
2019-11-13 12:43:42 -05:00
Ben Newman
faeab6c7d4 Revert "Temporarily wrap files.rename on non-Windows platforms to validate safety."
This reverts commit 52d4809aeb, as promised
in the previous commit message.
2019-11-12 17:22:33 -05:00
Ben Newman
52d4809aeb Temporarily wrap files.rename on non-Windows platforms to validate safety.
Now that files.rename uses Promise.prototype.await on Windows, it's
important to be sure it never gets called outside of a Fiber. Though we
don't run our full test suite on Windows, we can validate this expectation
by wrapping files.rename on all platforms. This commit should be reverted
once the validation is complete.
2019-11-12 17:12:02 -05:00
Ben Newman
c4e05dfffe Rewrite files.rename on Windows to retry after 50ms intervals.
Falling back to a full recursive copy was MUCH more expensive than waiting
a short amount of time before retrying the rename.

This aligns with the way graceful-fs handles EPERM and EACCES errors on
Windows: https://www.npmjs.com/package/graceful-fs#improvements-over-fs-module
2019-11-12 15:06:41 -05:00
Ben Newman
926cba9a77 Revert "Merge pull request #10771 from meteor/copy-directories-asynchronously"
This reverts commit 77a9784929, reversing
changes made to e0ddae2cc7.
2019-11-11 19:35:16 -05:00
Ben Newman
c7cc817d69 Use wrapDestructiveFsFunc for files.promises.writeFile. 2019-11-11 17:39:35 -05:00
Ben Newman
cf04e051e3 Write files in Builder#_copyDirectory asynchronously.
Using fs.writeFileSync in a serial style becomes especially costly when
we're writing a lot of files. In a recent profiling exercise I did on
Windows, nearly 80% of the time taken by Builder#_copyDirectory was spent
just closing the written files. By using the asynchronous fs.writeFile
function, we should be able to parallelize at least some of this work, and
await all the promises at the very end of copying the directory.
2019-11-11 17:26:03 -05:00
Ben Newman
dea305ca4a Set a higher LRU cache size for makeCheapPathFunction entries.
In PR #10720, we introduced the makeCheapPathFunction in an effort to
reduce the caching overhead for very frequently called (and already pretty
quick) operations like files.stat.

However, the default maximum LRU cache size of Math.pow(2, 16) can cause
quite a bit of cache eviction churn for large applications, which @veered
has identified as a potential source of build performance problems.

By setting the maximum cache size to Math.pow(2, 20) instead, I am no
longer seeing any files.stat calls in the profiling output for rebuilding
a large internal app, saving several seconds of rebuild time. The obvious
downside is that this cache might accumulate more memory over time, which
is why I didn't just set the max to Infinity, though that might be a
viable option if the total set of paths ever stat'd is small enough to fit
into the available memory.

In the future, I hope to find ways of managing LRU cache size that respond
to actual memory pressure (relative to available memory), rather than
pruning the cache after an arbitrary numeric threshold is reached.
2019-11-05 11:19:43 -05:00
Ben Newman
7fb7fcdd6d Work around incorrect fs.statSync type inference. 2019-10-24 19:36:32 -04:00
Ben Newman
56c21a9796 Attempt to make optimisticStatOrNull less expensive. (#10720) 2019-10-24 18:55:12 -04:00
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
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
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
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
Chiciuc Nicușor
a6d454b760 Convert func-utils.js to TypeScript (#10631) 2019-07-26 09:21:23 -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
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