Commit Graph

337 Commits

Author SHA1 Message Date
Ben Newman
c19f4ead0d Implement inputFile.readAndWatchFile.
This only works for files contained within the source root of the current
app or package.
2016-05-20 12:59:08 -04:00
Ben Newman
49a60f155b Support .babelrc presets and plugins.
In addition to package.json files with "babel" sections, BabelCompiler now
supports .babelrc files, though in both cases only the "presets" and
"plugins" fields are respected. If a .babelrc file is found, package.json
files are ignored.

Additional presets and plugins are now *prepended* to the original
babelOptions.{presets,plugins} lists, so that the custom plugins have a
chance to handle syntax differently than babel-preset-meteor would.

The inputFile.getPackageJson method has been replaced by a more general
method, inputFile.findControlFile.

Fixes #6351.
2016-05-20 12:59:08 -04:00
Ben Newman
fd0275f540 More tolerant path comparison in inputFile.require. 2016-05-20 12:59:07 -04:00
Ben Newman
7c208b355b Continue using Babel's CommonJS modules compiler for packages.
Switching immediately to module.import and module.export for package code
would make it difficult for package authors to use Meteor 1.3.3 to publish
packages that still work in apps using older versions of Meteor. There's
nothing wrong with compiling import/export statements to module.import and
module.export in application code, however, because apps only need to work
with one version of Meteor.
2016-05-19 17:48:39 -04:00
Ben Newman
e6951f18c4 Teach findImportedModuleIdentifiers about module.import(id, setters). 2016-05-19 17:04:09 -04:00
Ben Newman
b16e8d5019 Implement inputFile.{getPackageJson,resolve,require} for use by plugins.
These changes allow Package.registerCompiler-style compiler plugins to
extract package.json and npm package information at compile time from the
files that the plugin processes.

This information was accessible before, but it certainly wasn't easy to
obtain it. These convenience methods should satisfy the motivation behind
2016-05-18 16:37:37 -04:00
Ben Newman
3f9b8c2566 Watch package.json files in addition to package.js files. 2016-05-18 16:37:36 -04:00
Ben Newman
650fd81521 Add profiling for meteorNpm.{runNpmCommand,rebuildIfNonPortable}. 2016-05-18 15:17:51 -04:00
Ben Newman
f6b75305b3 Pay attention to unibuild.arch when determining usesModules.
Fixes #6877.
2016-05-17 14:27:56 -04:00
Ben Newman
8253e5862d Fix linter unibuild.arch matching.
Fixes #6843.
2016-05-17 13:05:15 -04:00
Ben Newman
aadb252b93 Clearly mark empty stub CSS modules so that they can be overridden.
Fixes #6881.
2016-05-16 22:13:24 -04:00
Ben Newman
7574f74481 Avoid copying devDependencies from local node_modules directories.
Fixes #6750.
2016-05-16 20:49:02 -04:00
Ben Newman
861880b882 Rebuild binary npm packages whenever process.versions differs.
Recording process.versions allows us to be much more aggressive about
rebuilding binary dependencies whenever the version of Node/V8 might have
changed, even if the package was not just downloaded.
2016-05-16 18:21:12 -04:00
Ben Newman
80b66b13ba Make sure prelinkFile.sourceMap is a string. 2016-05-16 18:21:10 -04:00
Ben Newman
d060ae9a2d Decompose a helper for cloning process.env for npm-related commands. 2016-05-16 18:21:09 -04:00
Ben Newman
2d2f21f7d5 Use env vars instead of $PATH to select python.exe and MSVS version. 2016-05-16 18:21:08 -04:00
Ben Newman
81756d9833 Make sure python.exe is in $PATH when running npm on Windows. 2016-05-16 18:21:08 -04:00
Ben Newman
de5411e8fd Allow importing from app node_modules when running test-packages.
Fixes #6827.
2016-05-16 18:21:08 -04:00
Ben Newman
ff621a88fe Rebuild non-portable Meteor packages when downloaded.
Together with c18c1f5278, this commit is a
big step towards liberating Meteor from Node 0.10.

Part of #5124.
2016-05-16 18:21:07 -04:00
Tom Coleman
01a745a99d Ensure that test files for both kinds of tests.
Fixes #6901 by ensuring that we short circuit laziness detection for test files in both modes.
2016-05-10 16:58:59 -07:00
Ben Newman
12d2d4229d When testing, load test files in imports directories eagerly.
Fixes #6831.
2016-04-18 10:34:10 -04:00
Ben Newman
6e792a7cf2 Normalize .sourcePath and .targetPath before comparing them.
Fixes https://github.com/meteor/meteor/issues/6806#issuecomment-210365603,
which was also affecting the todos example app.
2016-04-15 16:58:05 -04:00
Ben Newman
f616b6bc81 Let multiple files have the same .sourcePath in the ImportScanner.
Importantly, the files can now differ with respect to their .lazy
properties, which fixes #6806 and related issues. Note that the files must
have different .targetPath values if they have the same .sourcePath.

This is a minor breaking change for code that relied on module.id being
based on the .sourcePath instead of the .targetPath.
2016-04-13 19:49:29 -04:00
Ben Newman
3a5e8da935 Make sure JS resources have a .targetPath property.
This path can be specified by calling addJavaScript({ path: ... }), and
defaults to being identical to the .sourcePath if no options.path is
provided.  The .targetPath may be different from the .sourcePath when a
compiler plugin calls addJavaScript multiple times for the same file,
using a different options.path each time, e.g. when a JSON configuration
file turns into multiple JS resources.
2016-04-13 19:26:33 -04:00
Ben Newman
8e9d0ab7ba Let ImportScanner resolve input files not on disk.
If we pass a file to ImportScanner#addInputFiles, and a module identifier
resolves to that file, it shouldn't matter if the file actually exists on
disk. A common example is a new file generated by a compiler plugin.
2016-04-13 16:34:58 -04:00
Ben Newman
1d31896564 Normalize node_modules directory names when cross-building.
Really fixes #6765.
2016-04-12 12:19:06 -04:00
Ben Newman
984e27e372 Better error message for _combineFiles lazy/bare mismatch. 2016-04-11 18:26:37 -04:00
Ben Newman
d287681868 Don't interfere with explicit sourceReadOptions.names.
Fixes #6787.
2016-04-11 17:02:10 -04:00
Ben Newman
865735a436 Tolerate malformed .meteor-portable files. 2016-04-11 17:02:10 -04:00
Ben Newman
cf98e285ac Fix imports of tools/tool-env/isopackets.js.
Fixes #6778.
2016-04-11 12:33:16 -04:00
Ben Newman
5c7e6065ac Keep quiet about legacy registerBuildPlugin errors in lazy files.
Fixes #6767.

This is essentially the same treatment we give to compilation errors in
lazy files processed by Package.registerCompiler-style plugins, which
fixed a similar issue: #5998. Here are the relevant commits:

be986fd709
ce4fda3783
2016-04-10 12:02:10 -04:00
Ben Newman
c0b64865ab Don't try to use CSS source maps for CommonJS-ified CSS modules.
Part of #6037.
2016-04-08 19:37:47 -04:00
Ben Newman
911b4aa4cb Simplify CSS-to-CommonJS conversion by not handling @import rules.
We can revisit this conversion if it turns out anyone really wants to use
@import rules in CSS files instead of using something like LESS.

Part of #6037.
2016-04-08 19:02:33 -04:00
Ben Newman
a073280e3f Ignore nested node_modules directories if parent contains no sources.
This in important optimization for #6037, and it also fixes #6627, since
we are now registering watchSet dependencies on the contents of
node_modules directories.
2016-04-08 11:11:01 -04:00
Ben Newman
43659ff561 Search local node_modules directories for non-.js(on) source files.
Part of #6037.
2016-04-08 11:11:01 -04:00
Ben Newman
eb18d59faa Make all files in imports and node_modules directories lazy.
The most notable change here is that we now treat files in app imports
directories as lazy even before we know whether the app is using modules.
This could be a breaking change for some 1.3 apps that do not use modules
but have imports directories containing eager .js files. That (very minor)
level of backwards incompatibility seems acceptable in the context of
upgrading to Meteor ~1.3, however.
2016-04-08 11:10:52 -04:00
Ben Newman
6849b93fd2 Add trailing newline to bundle/programs/server/package.json. 2016-04-07 14:13:33 -04:00
Ben Newman
7c3014302c Add install script to programs/server/package.json when bundling.
This package.json file is used at times when npm-rebuild.js is not
available, such as when we're building the dev bundle.
2016-04-07 13:05:53 -04:00
Ben Newman
a7c3aa6a50 Tolerate (and prevent) missing file.deps in the ImportScanner.
Fixes #6724.
2016-04-07 13:05:52 -04:00
Ben Newman
b3a83bd118 Install reliable stubs for all Package[name] objects.
If a Meteor package had a file called index.js, the runtime module system
would resolve "meteor/<name>" to "/node_modules/meteor/<name>/index.js",
instead of falling back to Package[<name>] as expected.

Installing a stub for Package[<name>] at /node_modules/meteor/<name>.js
means the runtime module system no longer needs the fallback, and will no
longer be confused by index.js files.

Fixes #6590.
2016-04-07 13:05:52 -04:00
Ben Newman
179225f7f8 Construct identity source maps for unmapped files.
This is a partial reversion of ad3f56a0bf,
but hopefully less time intensive than the original.

Fixes #6639.
2016-04-07 13:05:52 -04:00
Ben Newman
b1c3f22ff4 Make quiet symlink loop checking the default.
Fixes #6665.
2016-04-07 13:05:52 -04:00
Ben Newman
a36c204d7d Allow importing files with unknown extensions if they parse as JS.
Fixes #6699.
2016-04-07 13:05:51 -04:00
Ben Newman
c18c1f5278 Replace setup.sh with npm-rebuild.js, and run it on npm install.
Implements https://github.com/meteor/meteor/issues/6537#issuecomment-205954797

The setup.sh script was only sometimes written previously, so no existing
deployment logic should rely on it existing.

On the other hand, all apps built by `meteor build` require running
`npm install` in the programs/server/ directory, so the install hook I
added to programs/server/package.json will ensure npm-rebuild.js is
invoked reliably.

Using a pure Node script means this code will work just as well on Windows
as on Linux or Darwin, though Linux is by far the most common deployment
platform for Meteor apps.

TODO Remember to rebuild the dev bundle before the next release!
2016-04-07 13:05:50 -04:00
Ben Newman
2dd511ff11 Remove logic for writing package.json files for binary npm packages.
We're going to be using programs/server/setup.sh to run `npm rebuild` in
these packages, which is a much cleaner solution for #6537.
2016-04-07 13:05:50 -04:00
Ben Newman
91244f36c3 Run npm rebuild in programs/server/setup.sh.
Part of #6537.
2016-04-07 13:05:49 -04:00
Ben Newman
b4fe0d5c85 Allow importing .css files from node_modules directories.
Fixes #6037.
2016-04-07 13:05:49 -04:00
Ben Newman
d7f87b00bf Don't colonConverter.convert(name) again. 2016-04-03 13:26:45 -04:00
Ben Newman
aeb2b6b0ed Avoid unnecessarily long node_modules paths for plugin isopacks.
Long paths pose real problems on Windows, and may have exacerbatd the
consequences of #6609.
2016-04-02 20:25:21 -04:00
Ben Newman
5fc2e0c043 Use IsopackCache#uses to determine useMeteorInstall. 2016-04-01 21:39:31 -04:00