Commit Graph

68 Commits

Author SHA1 Message Date
zodern
8babb0c8de Use features to configure async-await plugin 2023-03-03 17:09:19 -06:00
Matheus Castro
0ebbe9de51 Remove Fibers from meteor-tools:
- Fix watchSet issue when restarting the server because of file changes.
- Remove Fiber usage from tinytest_server.js
2022-12-30 15:15:04 -03:00
Matheus Castro
d243419d3c Remove Fibers from meteor-tools:
- Don't use forkJoin when downloading missing packages.
2022-12-29 18:19:04 -03:00
Matheus Castro
810cc8b0e5 Remove Fibers from meteor-tools:
- Add missing await to generate file name, since when using builder.enter we "proxy" those methods and they are async.
2022-12-22 14:18:17 -03:00
Matheus Castro
170e5d3f6d Remove Fibers from meteor-tools:
- Adapt forkJoin and other files functions to correctly be awaited.
2022-12-22 14:09:27 -03:00
Matheus Castro
ee304af590 Merge branch 'release-3.0' into release-3.0-tools
# Conflicts:
#	packages/babel-compiler/.npm/package/npm-shrinkwrap.json
#	packages/ddp-client/common/livedata_connection.js
#	packages/ddp-server/writefence.js
#	tools/cli/commands-packages.js
#	tools/meteor-services/service-connection.js
#	tools/static-assets/server/boot.js
2022-12-14 22:12:13 -03:00
Matheus Castro
b1a6cc0761 Remove Fibers for meteor tools: turns out the package building is still not done. Still need to check why it's failing to require node_modules when evaluating/loading the plugin. 2022-12-04 00:27:50 -03:00
Matheus Castro
4b31d2b352 Remove Fibers for meteor tools:
- Package building is done, at least I hope so!
2022-11-26 00:09:33 -03:00
Matheus Castro
022a7e9303 Remove Fibers for meteor tools:
- Changing package/compile steps to use async/await.
2022-11-25 20:15:37 -03:00
Dirk Stolle
088e52f386 fix a few typos in tools directory 2022-11-03 17:42:40 +01:00
Jan Dvorak
8ec9f0b7be meteor-babel => @meteorjs/babel 2021-05-07 19:43:37 +02:00
Filipe Névola
479c4de87a Merge pull request #10663 from jamesmillerburgess/npm-discards-ts 2021-01-15 14:53:54 -04:00
zodern
9421e76075 Remove optimisticRealpath 2020-02-24 22:03:18 -06:00
zodern
d734481abd Use optimisticRealpath when copying node_modules 2019-12-23 10:31:03 -06: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
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
James Miller Burgess
ac24d0067d Convert npm-discards.js to TypeScript 2019-08-04 15:32:29 +09: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
528b549460 Convert tools/fs/optimistic.js to TypeScript. 2019-07-05 12:29:19 -04:00
Ben Newman
5ed64fb1db Remove explicit .js extension from tools/fs/files imports. 2019-07-04 10:32:09 -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
01f515e6b2 Inconsequential style tweaks. 2019-02-28 14:02:59 -05:00
zodern
aadbbfbd2b Clean up code. 2019-02-28 14:02:57 -05:00
zodern
29b6ca6483 Avoid unnecessary work if the file was already written. 2019-02-28 14:02:48 -05:00
zodern
ead0a6de1f Fix indentation 2019-01-17 16:12:15 -06:00
zodern
285e1b50c3 Clean up code 2019-01-16 22:16:51 -06:00
zodern
65bc2b0100 Fix reusing symlinks from initial build 2019-01-16 20:21:00 -06:00
zodern
e04c87adfe Clean up old symlinks 2019-01-01 12:08:35 -06:00
zodern
92f84293b5 Add caching to _copyDirectory
This is most noticible in copyNodeModulesDirectory, which is called many times during each server build.
2018-12-31 22:01:36 -06:00
zodern
e14ce5b908 Do not atomicallyRewriteFile when not building in place 2018-12-31 21:38:26 -06:00
Ben Newman
1a472a4161 Simplify external symlink handling in Builder#copyDirectory.
Follow-up to af51b816, which fixed #8005 by copying symlinks to external
directories as directories rather than trying to preserve the symlinks.

Issue #10177 revealed a flaw in this strategy: the filter function that we
use to strip development npm packages always rejects external paths, even
if the original symlink was found in a valid production npm package, and
thus its contents should be included in the production bundle.

In the process of fixing this problem, I realized that the only important
part of af51b816 was this code:

  // Update fileStatus to match the actual file rather than the
  // symbolic link, thus forcing the file to be copied below.
  fileStatus = optimisticLStatOrNull(externalPath);

and the code for manipulating thisAbsFrom and _currentRealRootDirectory
could be removed.
2018-09-05 21:30:27 -04:00
Ben Newman
f8c76b90dc Force .meteor/local/build to be rebuilt in-place on Windows.
Because in-place rebuilds are disabled by default on Windows, we were
losing .meteor/local/build/programs/web.browser.legacy every time we
rebuilt .meteor/local/build as part of writeSiteArchive, as reported by
@lmachens in this comment: https://github.com/meteor/meteor/pull/9942#issuecomment-406656741

In-place rewriting of .meteor/local/build seems essential for the new
strategy of writing different targets at different times, though I have
attempted to limit the risk of overwriting open files on Windows by
continuing to build the individual target directories from scratch (that
is, by writing a fresh temporary directory and then renaming it over the
existing directory).

Though I don't have any specific ideas in this direction, it may be worth
noting: if we could find a way to make in-place builds safer on Windows
(as they are on Linux and Mac), Windows rebuilds would be significantly
faster than they are with the current strategy of rewriting everything
from scratch every time.
2018-07-20 19:10:18 -04:00
Ben Newman
1b17025cd4 Tolerate missing files in Builder#_ensureDirectory.
Fixes #9882.
2018-05-12 11:40:01 -04:00
Ben Newman
c6c92255e5 Relax options.from precondition in Builder#copyNodeModulesDirectory. 2018-03-26 12:04:12 -04:00
Ben Newman
e7ad5d2a42 Call files.cp_r with { preserveSymlinks: true } in more places.
Now that symlinks can be used to enable selective compilation of
node_modules, it's important to preserve them.
2018-03-26 12:04:12 -04:00
Ben Newman
22e3f99565 Fix copying/symlinking of node_modules directories during build.
The bulk of this commit implements `builder.copyNodeModulesDirectory` to
allow more than one `node_modules` directory to be copied to the same
destination with as much safe symlinking as possible.

However, the crux of the fix for #9738 is the removal of the call to
`builder.generateFilename`, which deserves additional explanation.

If multiple directories are copied to the same output path by the builder,
in some cases it makes sense to ensure distinct directory names by adding
numeric suffixes to some of the directories.

In general, `builder.generateFilename` can get away with this renaming
only if the exact names of the directories are an implementation detail.

However, the code changed by this commit was altering the names of
`node_modules` directories whenever a package had both an `Npm.depends`
and a local `node_modules` directory.

Not only is it totally invalid to change the name of a `node_modules`
directory, but there is also no harm in copying the contents of multiple
`node_modules` directories into one final directory called `node_modules`.

Should fix #9738.
2018-03-23 18:59:32 -04:00
Ben Newman
352b319646 Allow Builder#copyDirectory to re-create symlinks again.
Commit 86ec7eb5db broke tests because we
rely on symlinks even when the symlink option is false.
2017-10-16 14:59:01 -04:00
Ben Newman
eded323039 Avoid calling files.stat(source) in symlinkWithOverwrite.
This was dangerous because source is often a path relative to the old
target file, whereas files.stat was interpreting source as a path relative
to process.cwd().

Fixes #9203.
2017-10-16 14:07:11 -04:00
Ben Newman
86ec7eb5db Avoid creating symlinks in Builder#copyDirectory when forbidden. 2017-10-16 14:07:07 -04:00
Ben Newman
6f925b0103 Merge branch 'devel' into release-1.6 2017-06-06 12:51:50 -04:00
Ben Newman
a2f26cbe6e Fix #8761 in three different ways.
The root of the problem was that the es5-ext npm package contains
directories called '#', e.g.
https://github.com/medikoo/es5-ext/tree/master/array/%23

These directory names were being sanitized to '' and thus ignored when
reserving paths in the Builder, which led to reservation conflicts later.

This commit fixes the problem in three different and independently
sufficient ways:

* Use files.mkdir_p instead of files.mkdir when creating parent
  directories of written files.

* Replace illegal characters in sanitized paths with '_' instead of ''.

* Allow '#' in sanitized paths (only needs to be escaped in the shell, not
  actually forbidden in paths).
2017-06-06 12:25:33 -04:00
Ben Newman
b3b464b614 Miscellaneous updates due to changes between Node 5 and 7.
https://github.com/nodejs/node/wiki/Breaking-changes-between-v5-and-v6
https://github.com/nodejs/node/wiki/Breaking-changes-between-v6-and-v7
2017-06-05 18:57:52 -04:00
Ben Newman
6418026e15 Update all new Buffer usage to Buffer.from for Node 6+.
https://github.com/nodejs/node/wiki/Breaking-changes-between-v5-and-v6
2017-06-05 18:16:03 -04:00
Hugh Willson
39748d82f1 Updated the builder whitelist to allow "@" in filenames. 2017-03-20 13:33:57 -04:00
Ben Newman
f42c137f55 Always copy node_modules/.bin into bundle/programs/server/npm.
Fixes #8136.
2016-12-06 10:16:43 -05:00
Ben Newman
a7ac32e00a Tolerate ENOENT errors in Builder#copyDirectory. 2016-11-08 13:33:20 -05:00
Ben Newman
ad460e0d7d Tolerate files.realpath throwing ELOOP exceptions. 2016-11-04 18:45:51 -04:00
Ben Newman
7f35e94713 Tolerate files.realpath throwing ENOENT exceptions. 2016-11-04 18:14:09 -04:00
Ben Newman
af51b8160c Use absolute paths for external symlinks in Builder#copyDirectory.
Thanks to @worldsayshi for reporting this issue with a reproduction.

Fixes #8005.
Fixes #2876.
Fixes #7154.
2016-11-04 17:44:42 -04:00