Commit Graph

180 Commits

Author SHA1 Message Date
zodern
eb5ea5964e Fix handling string value for recompile option 2022-04-29 16:53:50 -05:00
zodern
9840956d22 Fix recompiling npm packages for web arch 2022-04-29 16:45:09 -05:00
zodern
6bd370c8ff Use recursive watchers 2021-10-15 11:13:52 -05:00
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
Renan Castro
31e7cf96fb Inline KNOWN_ISOBUILD_FEATURE_PACKAGES constant. On node 14, we faced an issue while importing this constant, probably related to changes on ES6 implementation in this version. See the changelog here: https://nodejs.org/en/blog/release/v14.0.0/#notable-changes - documentation to avoid errors 2021-05-19 18:28:17 -03:00
Renan Castro
d6aeaf391d Inline KNOWN_ISOBUILD_FEATURE_PACKAGES constant. On node 14, we faced an issue while importing this constant, probably related to changes on ES6 implementation in this version. See the changelog here: https://nodejs.org/en/blog/release/v14.0.0/#notable-changes 2021-05-19 17:56:38 -03:00
Renan Castro
685e321fac User commonjs export 2021-05-19 11:01:00 -03:00
filipenevola
bb42fa8137 Adds the option to cache the build on deploy 2020-07-27 11:23:38 -04:00
Ben Newman
37b1683fbc Centralize legacy arch logic in tools/utils/archinfo.ts. 2019-11-08 11:15:23 -05: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
4334fd4ceb Convert tools/isobuild/resolver.js to TypeScript. 🎉 2019-07-10 12:53:28 -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
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
f61ba60326 Support meteor.nodeModules.recompile package.json configuration option.
Example:

  "meteor": {
    "mainModule": ...,
    "testModule": ...,
    "nodeModules": {
      "recompile": {
        "very-modern-package": ["client", "server"],
        "alternate-notation-for-client-and-server": true,
        "somewhat-modern-package": "legacy",
        "another-package": ["legacy", "server"]
      }
    }
  }

The keys of the meteor.nodeModules.recompile configuration object are npm
package names, and the values specify for which bundles those packages
should be recompiled using the Meteor compiler plugins system, as if the
packages were part of the Meteor application.

For example, if an npm package uses const/let syntax or arrow functions,
that's fine for modern and server code, but you would probably want to
recompile the package when building the legacy bundle. To accomplish this,
specify "legacy" or ["legacy"] as the value of the package's property,
similar to somewhat-modern-package above. These strings and arrays of
strings have the same meaning as the second argument to
api.addFiles(files, where) in a package.js file.

This configuration serves pretty much the same purpose as symlinking an
application directory into node_modules, but without any symlinking:
https://forums.meteor.com/t/litelement-import-litelement-html/45042/8?u=benjamn

The meteor.nodeModules.recompile configuration currently applies to the
application node_modules directory only (not to Npm.depends dependencies
in Meteor packages). Recompiled packages must be direct dependencies of
the application.
2019-07-01 09:15:28 -04:00
Ben Newman
c96278700d Fix compiler plugins self-tests by waiting for lazy compilation to finish. 2018-10-31 10:41:31 -04:00
Ben Newman
4a70b12edd Allow package-name@x.y.z! override syntax in .meteor/packages.
With this commit, if a top-level package version constraint in
.meteor/packages ends with a '!' character, any other (non-!) constraints
on that package elsewhere in the application will be weakened to accept
any version of the package that is not less than the constraint,
regardless of whether the major/minor versions actually match.

This functionality is extremely useful in cases where an unmaintained
package was last published with api.versionsFrom(<some ancient version>),
thus constraining the major version of any Meteor core package it depended
on, but you really want to upgrade that core package anyway. Just put a
'!' after the core package's version constraint in your .meteor/packages
file, and you will almost certainly get your way. The fact that minimum
versions are still enforced is good/fine because the constraints you want
to override are typically ancient, so they easily match any recent version
of the package.

Your only recourse before this @x.y.z! syntax was to find a replacement
for the unmaintained package, or fork and modify it locally, or somehow
persuade the package author to publish a new version with a more
reasonable api.versionsFrom. None of these options were easy.

Many thanks to @GeoffreyBooth, long-time maintainer of the `coffeescript`
package, for originally suggesting a ! syntax similar to this one:
https://github.com/meteor/meteor-feature-requests/issues/208#issuecomment-400154209

The limitation of this syntax to .meteor/packages is deliberate, since
overriding package version constraints is a power-tool that should be used
sparingly by application developers, and never abused by package authors.
Also, limiting the scope of this syntax reduces the risk of an arms race
between overrides, a la the infamous CSS !important modifier.
2018-08-14 20:27:23 -04:00
Ben Newman
aade180d46 Build web.browser.legacy bundle after startup on rebuilds. 2018-07-04 12:26:23 -04:00
Ben Newman
7baaf19020 Report an error when meteor.mainModule cannot be resolved.
https://github.com/meteor/meteor/pull/9826#issuecomment-387172568
2018-05-07 18:48:38 -04:00
Ben Newman
f14d50538e Merge branch 'devel' into release-1.6.2 2018-03-01 18:02:08 -05:00
Ben Newman
a212d9f515 Also support meteor.testModule to configure test entry points.
Setting meteor.testModule is a great way to specify test entry points
explicitly, rather than relying on Meteor's isTestFilePath heuristics:
https://github.com/meteor/meteor/blob/devel/tools/isobuild/test-files.js

The syntax is identical to meteor.mainModule, so you can set an explicit
meteor.testModule.{client,server,...} for each platform. If a testModule
is not specified for a platform, then Meteor's existing rules about test
file paths apply for that platform, as before.

If a testModule is specified, that module will always be loaded eagerly
when running `meteor test`, in addition to any other modules that load
eagerly because of meteor.mainModule or other rules regarding module
loading. If you run `meteor test` without the `--full-app` option, then no
application JS modules other than the testModule (and any modules imported
by it) will be loaded eagerly.
2018-03-01 14:27:30 -05:00
Ben Newman
8dd2402f76 Allow meteor.mainModule.{client,server} === false for no entry point.
If meteor.mainModule.{client,server,...} === false, no modules will be
loaded eagerly for that architecture. This is useful if you have an app
with no special app/{client,server} directory structure and you want to
specify an entry point for just the client (or just the server), without
accidentally loading everything on the other architecture.
2018-03-01 14:27:30 -05:00
Ben Newman
c28d813745 Merge branch 'devel' into release-1.6.2 2018-02-23 18:39:06 -05:00
Ben Newman
31c39f0e6f Resolve mainModule strings using Node module resolution rules. 2018-02-23 12:45:24 -05:00
Ben Newman
ae3ad3b2df Support a meteor.mainModule section in application package.json files.
https://github.com/meteor/meteor-feature-requests/issues/135

This change allows applications to specify specific entry points for each
architecture, without relying on `imports` directories to determine the
eagerness/laziness of modules. In other words, it will finally be possible
to build a Meteor app without a special `imports` directory.

Specifically, if `packageJson.meteor.mainModule[architecture]` is defined,
all modules for that architecture will be lazy except for the specified
module, which will be loaded eagerly.

Possible values for `architecture` include "client", "server", "web",
"web.browser", "web.cordova", "os", and so on, just like the second
argument to `api.mainModule(file, where)` in Meteor packages.

In order to match existing behavior, a Meteor application might include
the following in its `package.json` file:

  "meteor": {
    "mainModule": {
      "client": "client/main.js",
      "server": "server/main.js"
    }
  }

These architectures are handled independently, so omitting the "client" or
"server" property would cause that architecture to revert to standard
Meteor loading semantics. In other words, Meteor developers must opt into
this functionality, which is crucial for backwards compatibility.

Note that this functionality applies only to application modules, since
modules in Meteor packages are already lazy by default, and Meteor
packages can already specify entry points by calling `api.mainModule` in
their `package.js` files.

Also note that the loading behavior of non-JavaScript resources is *not*
affected by `packageJson.meteor.mainModule`. Only resources added by
compiler plugins via `addJavaScript` are subject to the new configuration
option. If a compiler plugin calls `addStylesheet` or `addHtml`, those
resources will still be included unconditionally in the HTML document
rendered by the web server. While you could try to import these resources
from JavaScript, you would only be importing any JavaScript resources the
compiler plugin registered using `addJavaScript`, and not the actual HTML
or CSS resources. I welcome feedback on this decision, but if there's no
meaningful way to import a resource, making it lazy just means it won't be
loaded at all.

An ulterior motive for this feature is to enable Meteor apps to have
directory layouts that developers who are not familiar with Meteor can
immediately understand. The special meaning of the `imports` directory and
the surprising eagerness of modules outside of `imports` have always
required some explanation, so this change should reduce that surprise.

Because Meteor strives to be a zero-configuration tool, this is currently
the only supported option in the "meteor" section of `package.json`,
though the available options may be expanded in the future if that's the
best/only way to solve important problems. This would involve adding
additional methods to the `MeteorConfig` class in `project-context.js`,
and then using those methods elsewhere in the `meteor/tools` codebase.
2018-02-23 12:44:56 -05:00
Ben Newman
ed28140071 Support a new web.browser.legacy platform. 2018-01-22 17:54:42 -05:00
Hugh Willson
27ed9bc2e8 Allow scoped Cordova packages to be installed
Fixes an issue preventing the installation of scoped Cordova
packages. For example,
`meteor add cordova:@somescope/some-cordova-plugin@1.0.0`
will now work properly.

Fixes https://github.com/meteor/meteor/issues/7336.
2017-11-17 01:58:54 +02:00
Jack Kavanagh
dd5ea2b950 can resolve private npm package when adding cordova plugin 2017-11-17 01:57:48 +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
0bf08a5f99 Merge branch 'release-1.5.2' into release-1.6 2017-08-08 18:40:46 -04:00
Ben Newman
cfdc69bf71 Support @~ version constraints and use them for core packages. (#8991) 2017-08-08 18:01:30 -04:00
Ben Newman
f52b1726a5 Scan packages/non-core packages as local packages.
Fixes #8961 and #8962.
2017-08-02 13:40:38 -04:00
Ben Newman
943c6a4d83 Merge branch 'release-1.5.1' into release-1.6 2017-06-21 14:40:01 -04:00
Michał Powaga
4c236dd69e --extra-packages now overrides .meteor/packages constraints 2017-06-08 16:21:09 +01:00
Michał Powaga
dd19865a1e Add --extra-packages option 2017-06-06 23:24:42 +01: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
Ben Newman
8e62f31ef1 Ensure appIdentifier is a legal Cordova package name.
This fixes intermittent failures of the cordova-platforms tests, which
would sometimes fail when one of the app identifier components happened to
start with a number instead of a letter.

The text of the exception was:

  Error validating package name. Package name must look like: com.company.Name

For example:

  https://circleci.com/gh/meteor/meteor/3710#tests/containers/2
2017-04-06 19:16:06 -04:00
Ben Newman
868a52829f Register package@version constraints for current release.
Package version unpinning (#7084) removed all exact package@=version
constraints derived from the current release.

As we discovered with Meteor 1.4.2.4 (#8306), this meant releases no
longer had any power to enforce package upgrades, which is why the
follow-up Meteor 1.4.2.5 release (#8311) was necessary.

This commit has the same effect as putting package@version in your
.meteor/packages file for every local/core package that your app uses.
2017-02-07 14:52:49 -05:00
Jesse Rosenberger
815e32e68b Add METEOR_PACKAGE_DIRS support and deprecate PACKAGE_DIRS
This is a refactor/finishing-move of @c9s's original PR meteor/meteor#7586.

This maintains backward compatibility with PACKAGE_DIRS using the original separator that it expected (':').  Users of the new METEOR_PACKAGE_DIRS variable should use the correct path separator for their platform (`:` on BSD/Linux and `;` on Windows).

Fixes meteor/meteor#7585
Fixes meteor/meteor#4204
2016-10-13 14:26:23 +03:00
c9s
3c5059b72a Add METEOR_PACKAGE_DIRS support
- Use path.delimiter to support windows platform
- Add console.warn message when PACAKGE_DIRS is defined
2016-10-12 18:52:58 +03: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
7600571717 Revert "Make sure .meteor/.gitignore ignores .meteor/dev_bundle."
This reverts commit 9e6ebde836.

Now that the `dev_bundle` link is called `.meteor/local/dev_bundle`, and
`.meteor/local` is already ignored, we don't need to ignore
`.meteor/dev_bundle` anymore.
2016-07-19 11:52:31 -04:00
Ben Newman
00c05facde Merge branch 'devel' into release-1.4 2016-07-18 14:52:14 -04:00
Ben Newman
576468eae8 Handle more errors in ensureDevBundleLink.
If a developer tried to `meteor update` a project whose `.meteor/release`
file corresponded to a version of `meteor-tool` that no longer exists in
`~/.meteor/packages/meteor-tool`, this code would throw an ENOENT error.
This could be fixed by running `meteor update --release <old release>`
first, but that kind of workaround shouldn't be necessary when updating
Meteor to the latest version.
2016-07-17 12:50:20 -04:00
Ben Newman
57ccaa27f9 Return an OS path for .meteor/local/dev_bundle. 2016-07-15 18:29:44 -04:00
Ben Newman
73e44a3c9c Use .meteor/local/dev_bundle instead of .meteor/dev_bundle.
I'm deliberately leaving in the code to ensure .meteor/.gitignore contains
dev_bundle for now, so that the old file won't get accidentally checked
into anyone's app repository.
2016-07-14 11:47:30 -04:00
Ben Newman
69b100d21a Save .meteor/local/resolver-result-cache.json to improve startup performance. 2016-07-14 11:27:56 -04:00
Ben Newman
78fcabbd58 Always link .meteor/dev_bundle to release specified in .meteor/release.
I was mistaken to think that files.getDevBundle() would be called after
springboarding to the appropriate release.
2016-07-14 11:27:53 -04:00