Commit Graph

923 Commits

Author SHA1 Message Date
denyhs
27e6d32e2e - Inserting the word modules in the header part on the function _getClosureHeader
- Testing Safari in the version 11
2020-09-18 09:58:14 -04:00
denyhs
2d93158aa7 Adjusting command to run group test 11 2020-09-16 19:24:44 -04:00
denyhs
745c3971c1 Adding new test group to try to understand why browserstack is crashing to Safari 2020-09-15 17:31:35 -04:00
denyhs
75c86e1249 Reapplying changes from the commit ff0d85d391 leaving just the changes on the file tools/isobuild/linker.js 2020-09-15 16:01:14 -04:00
denyhs
6e2011c011 Revert "Avoid unnecessary Buffer allocations in minifyJs."
This reverts commit ff0d85d391.
2020-09-14 16:34:28 -04:00
abhishek maurya
8947be9ea2 Cleanup. 2020-07-14 08:13:36 +05:30
Filipe Névola
ed985d4c04 Merge pull request #10838 from meteor/realpath-performance 2020-07-09 13:17:41 -04:00
Filipe Névola
94cd41f760 Merge pull request #11114 from meteor/full-rebuild-build-in-place 2020-07-09 13:17:27 -04:00
Filipe Névola
d2998d6e02 Merge pull request #11115 from meteor/faster-load-order-sort
Fix calling pathBasename twice during loadOrderSort
2020-07-08 17:50:34 -04:00
zodern
707c601a39 Fix calling pathBasename twice when sorting 2020-07-08 12:27:41 -05:00
zodern
91708c1e56 Add forceInPlaceBuild option to bundler 2020-07-08 10:02:40 -05:00
Filipe Névola
a383f5d499 Merge pull request #11102 from meteor/reduce-watchers 2020-06-26 10:16:41 -04:00
zodern
2d1b11f6b0 Fix reify cache files being watch 2020-06-24 15:21:48 -05:00
zodern
1bc208fe13 Fix duplicate linker cache
The cache file's contents stored by optimisticReadFile was over 10% of the meteor-tool's memory usage.
2020-06-24 15:19:42 -05:00
Filipe Névola
5ad36c9b8a Merge pull request #10839 from meteor/find-node_module-performance 2020-06-24 11:09:27 -04:00
filipenevola
f315d7f318 Fixes #11043 Update link of installing-prerequisites for mobile apps 2020-05-21 07:32:35 -04:00
Ben Newman
2b8834e92e Stop calling moduleDoesResolve before installing Cordova npm deps.
This fixes the bug where commands like `meteor add-platform ios` would
fail the first time with an error that cordova-lib could not be found,
even though we attempt to install the necessary packages if they have not
already been installed.

To make a very long story short, calling moduleDoesResolve before
installing dependencies like cordova-lib was causing Node.js to cache the
_absence_ of cordova-lib/package.json permanently in the new
packageJsonCache, which cannot be invalidated or cleared by user code:
f8f20892e9/lib/internal/modules/cjs/loader.js (L245-L255)

Although we could potentially propose a change to Node to allow the
packageJsonCache to be invalidated, a more immediate solution is simply to
avoid calling moduleDoesResolve when there's any chance the module will
not resolve. Because we still want to avoid repeatedly installing Cordova
dependencies every time we run a Cordova command, we instead check whether
the necessary dependencies are installed by examining the file system.
2020-03-11 18:01:33 -04:00
zodern
b287a1ab41 Clean up _readAndWatchDirectory 2020-02-28 22:33:46 -06:00
zodern
3a736233b4 Merge remote-tracking branch 'origin/devel' into find-node_module-performance 2020-02-25 07:10:22 -06:00
zodern
9421e76075 Remove optimisticRealpath 2020-02-24 22:03:18 -06:00
zodern
a5fdd1a150 Reduce calls to realpath for bin files
On Windows npm doesn't use symlinks for bin files, so the file's real path was never used.
2020-02-24 20:27:09 -06:00
zodern
b7c7e329d0 Fix variable name 2020-02-24 19:36:58 -06:00
Ben Newman
150d387b44 Merge branch 'master' into devel 2020-02-20 11:24:20 -05:00
Ben Newman
924c748ecc Avoid bailing out with module.useNode() for ESM modules.
On the server, Meteor attempts to avoid bundling node_modules code by
replacing entry point modules with a stub that calls module.useNode() (see
packages/modules-runtime/server.js). This trick allows evaluating server
node_modules natively in Node.js, faithfully preserving all Node-specific
behaviors, such as module.id being an absolute file system path, the
__dirname and __filename variables, the ability to import binary .node
modules, and so on.

However, starting in Node.js 12.16.0 (Meteor 1.9.1+), modules evaluated
natively by Node are considered ECMAScript modules (ESM) if the closest
package.json file has "type": "module" (or has an .mjs file extension).
This poses a problem for the module.useNode() trick, because ESM modules
cannot be imported synchronously using require (which is currently how
module.useNode() works).

To work around this new error, this commit checks package.json for "type":
"module" in ImportScanner#shouldUseNode to determine whether it's safe to
use the module.useNode() trick.

The good news is that ESM modules don't have access to nearly as many
Node.js-specific quirks: no module, require, or exports variables; no
__dirname, no __filename; no ability to import JSON or other non-ESM file
types (at least right now). So it seems somewhat less important for ESM
code (compared to CommonJS code) to bail out into native Node.js execution
using module.useNode(). In other words, bundling server code should not
affect its execution in nearly as many cases, if that code is ESM rather
than legacy CommonJS.

If this good news turns out to be overly optimistic, we can consider using
a different kind of bailout stub that's capable of importing ESM using
dynamic import(). For now, making sure we avoid bailing out for ESM code
like @babel/runtime/helpers/esm/* is the priority.
2020-02-19 15:24:42 -04: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
Ben Newman
87bc54fb9f Avoid bailing out with module.useNode() for ESM modules.
On the server, Meteor attempts to avoid bundling node_modules code by
replacing entry point modules with a stub that calls module.useNode() (see
packages/modules-runtime/server.js). This trick allows evaluating server
node_modules natively in Node.js, faithfully preserving all Node-specific
behaviors, such as module.id being an absolute file system path, the
__dirname and __filename variables, the ability to import binary .node
modules, and so on.

However, starting in Node.js 12.16.0 (Meteor 1.9.1+), modules evaluated
natively by Node are considered ECMAScript modules (ESM) if the closest
package.json file has "type": "module" (or has an .mjs file extension).
This poses a problem for the module.useNode() trick, because ESM modules
cannot be imported synchronously using require (which is currently how
module.useNode() works).

To work around this new error, this commit checks package.json for "type":
"module" in ImportScanner#shouldUseNode to determine whether it's safe to
use the module.useNode() trick.

The good news is that ESM modules don't have access to nearly as many
Node.js-specific quirks: no module, require, or exports variables; no
__dirname, no __filename; no ability to import JSON or other non-ESM file
types (at least right now). So it seems somewhat less important for ESM
code (compared to CommonJS code) to bail out into native Node.js execution
using module.useNode(). In other words, bundling server code should not
affect its execution in nearly as many cases, if that code is ESM rather
than legacy CommonJS.

If this good news turns out to be overly optimistic, we can consider using
a different kind of bailout stub that's capable of importing ESM using
dynamic import(). For now, making sure we avoid bailing out for ESM code
like @babel/runtime/helpers/esm/* is the priority.
2020-02-19 13:25:22 -05:00
Ben Newman
290e084cab 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 13:14:47 -05:00
claudiosdc
924b5e8c3c Improve Node.js built-in modules detection to fix #10892 (#10896) 2020-02-07 17:45:20 -05:00
Ben Newman
b3b5fee25f Add missing lazyFinalizer parameter to InputFile#addHtml.
Fixes #10883.
2020-02-01 13:47:47 -05:00
Christian Klaussner
daa8e98923 Make sure source map consumer exists before destroying it. (#10874) 2020-01-17 10:32:15 -05:00
filipenevola
8bf018f19b Merge branch 'devel' into release-1.9 2020-01-07 10:52:48 -05:00
zodern
952422053f Cache each node_modules folder once 2019-12-23 14:26:09 -06:00
zodern
18629d25ae Show arch name in profile for _findSources 2019-12-23 13:01:59 -06:00
zodern
9355787040 Do not watch node_modules in _findSources 2019-12-23 13:01:37 -06:00
zodern
e763d9598e Allow cache keys to be shared between archs 2019-12-23 12:54:43 -06:00
zodern
8c9251b9ac Reduce realpath in SymlinkLoopChecker 2019-12-23 11:42:02 -06:00
zodern
d734481abd Use optimisticRealpath when copying node_modules 2019-12-23 10:31:03 -06:00
Ben Newman
811a56a83f Differentiate initFromPackageDir by package name in METEOR_PROFILE output.
Might help with debugging this SQLite performance problem reported by
@heschong: https://github.com/meteor/meteor/issues/10800#issuecomment-567599306
2019-12-19 13:39:12 -05:00
Ben Newman
aee0092f64 Merge branch 'release-1.8.3' into release-1.9 2019-12-18 13:19:31 -05:00
filipenevola
1a5d6fb5b6 - MDG => Meteor Software
- updates CONTRIBUTING.md
2019-12-13 08:05:14 -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
Seba Kerckhof
a72c92c852 Fix comment in resolver
Between 1.3 and 1.3.1 the modules.js file got moved from modules to modules-runtime
2019-11-21 20:53:37 +01:00
Ben Newman
edbaeae98b Merge branch 'release-1.8.2' into release-1.9 2019-11-12 19:47:30 -05:00
Ben Newman
d52c9cc82f Avoid calling writeFileAtomically outside Fiber. 2019-11-12 16:58:05 -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
b71ab5bec5 Bump compiler.BUILT_BY and LINKER_CACHE_SALT to force rebuild. 2019-11-11 19:12:11 -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
f8de4127da Merge branch 'release-1.8.2' into release-1.9 2019-11-08 20:07:59 -05:00
Ben Newman
bd9043db20 Prefer "main" field of package.json over "module" in legacy bundle.
https://github.com/meteor/meteor/issues/10658#issuecomment-550456095
https://github.com/meteor/meteor/issues/10658#issuecomment-551870115

As usual, changes to module resolution logic need to happen in parallel in
tools/isobuild/resolver.ts and in packages/modules-runtime. However,
thanks to the modern/legacy system, it's easy to make the modules-runtime
package behave exactly the way(s) we want in the server, modern client,
and legacy client bundles.
2019-11-08 11:15:23 -05:00
Ben Newman
37b1683fbc Centralize legacy arch logic in tools/utils/archinfo.ts. 2019-11-08 11:15:23 -05:00