Commit Graph

116 Commits

Author SHA1 Message Date
Ben Newman
4fb26259b8 Unify file.emptyStub and file.imported === "implicit" as file.implicit.
Note that there was a typo in ResourceSlot#addStylesheet, so
file.emptyStub was never === true before.
2017-01-04 13:00:24 -05:00
Jesse Rosenberger
487b41fd75 Improve compiler error when asset is added with empty contents
While not a Meteor bug, this makes the error message more helpful when a compiler tries adding an asset without data, as demonstrated in meteor/meteor#8034.

Thanks to suggestion by @sdarnell for this.

Closes meteor/meteor#8034
2016-11-24 16:20:46 +02:00
Ben Newman
1b855047ae Limit InputFile#findControlFile to package source root directory.
This is an improvement that I noticed while investigating the
feasibility of fixing #8068.
2016-11-17 13:17:49 -05:00
Ben Newman
fc9c56a73e Improve InputFile#resolve. 2016-11-17 13:12:27 -05:00
Ben Newman
4cf06c37a6 Avoid global/method name ambiguity in InputFile#require. 2016-11-17 13:12:27 -05:00
Ben Newman
24b0ea9fdd Bump compiler/linker/bundler salts to trigger fresh builds. 2016-11-14 21:18:03 -05:00
Ben Newman
911f25bbf4 Allow lazy api.mainModule modules.
If you call api.mainModule(path, where, { lazy: true }), that main
module will not be evaluated until other code imports it at runtime, and
won't even be bundled if no other code imports it.

Closes #6132.
2016-11-14 12:51:00 -05:00
Ben Newman
4ada5c8a17 Bump LINKER_CACHE_SALT and compiler.BUILT_BY for good measure.
This will trigger recompilation and relinking, which should help prevent
various stale caching issues, e.g. #7977.
2016-11-08 13:50:32 -05:00
Ben Newman
f0355276a5 Remove babel-runtime-specific logic from compiler-plugin.js. 2016-11-02 12:05:33 -04:00
Ben Newman
739890d955 Bump compiler.BUILT_BY and LINKER_CACHE_SALT. 2016-10-23 18:17:26 -04:00
Ben Newman
5df8f89f7b Warn about babel-runtime helpers not provided by the Meteor package. 2016-10-21 17:56:01 -04:00
Ben Newman
7a18012975 Consult babel-runtime package when discarding helper modules.
The most fool-proof way to tell if a module is provided by babel-runtime
is to load babel-runtime as an isopacket and ask it.

This should fix any remaining issues like this one:
https://github.com/meteor/meteor/pull/7668#pullrequestreview-4379559
2016-10-16 16:40:11 -04:00
Ben Newman
8d4ef3f1f7 Only filter out node_modules/babel-runtime/{helpers,regenerator} modules.
This is a refinement of my previous commit 56c041c858.

The Meteor babel-runtime package does not provide substitutes for
babel-runtime/core-js/* modules, so we should not be discarding them from
the client bundle.

Fixes #7930.
2016-10-15 12:01:02 -04:00
Ben Newman
56c041c858 Filter out node_modules/babel-runtime/* when Meteor provides babel-runtime.
Should fix #7872 and others (e.g. #7833).
2016-10-13 19:24:34 -04:00
Ben Newman
6a66368e09 Cache optimistic stat objects in InputFile#findControlFile. 2016-10-10 15:22:53 -04:00
Ben Newman
1d149a0ed7 Keep Resolver.getOrCreate cache results distinct by caller.
The options.statOrNull function is not included in the JSON.stringify key,
but it affects the results because the implementation provided by the
ImportScanner relies on scanner._getFile to return fakeFileStat for
make-believe files created by the ImportScanner.

This becomes a problem if PackageSourceBatch#getResolver accidentally uses
a Resolver created initially for the ImportScanner, or vice-versa.

In particular, when a compiler plugin calls addJavaScript with a path
different from the original file path, the ImportScanner generates two
different modules, one of which imports the other. Only one of the files
exists on disk, though, so a special implementation of statOrNull is
necessary to keep the Resolver from having to share implementation details
with the ImportScanner.

When this system fails, users of compiler plugins see errors like this:
https://github.com/meteor/meteor/pull/7668#issuecomment-251976739
2016-10-06 12:43:37 -04:00
Ben Newman
2ec570251a Stop generating identity source maps for files without actual source maps.
This speeds up both getPrelinkedOutput (because we don't spend any time
generating the identity source map) and toStringWithSourceMap (because we
don't have to combine those source maps).

We still generate line number comments for files without source maps, so
it's relatively easy to find the source line for a stack trace.
2016-10-05 17:54:34 -04:00
Ben Newman
21b4c664f4 Cache Resolver objects by their constructor arguments.
This is critical because it means Resolver objects can now survive
development server restarts, which means the optimistic Resolver#resolve
method can remember results indefinitely. Thanks to this change, the
Resolver#resolve method has practically disappeared from rebuild
performance profiles.
2016-10-04 13:08:13 -04:00
Ben Newman
3ef7a08297 Eliminate the onMissing callback from the Resolver API. 2016-10-03 22:06:50 -04:00
Ben Newman
97ca5f1836 Don't pass watchSet when instantiating Resolver objects.
We used the watchSet only when reading package.json files, and I think we
can add package.json files to the watchSet in the ImportScanner instead.
2016-10-03 21:45:36 -04:00
Ben Newman
0c183c42b1 Bump compiler.BUILT_BY and LINKER_CACHE_SALT for good measure. 2016-07-25 11:51:29 -04:00
Ben Newman
817187bfc9 Bump LINKER_CACHE_SALT to trigger relinking. 2016-07-07 17:01:12 -04:00
Ben Newman
9d0c4b9cfa Bump LINKER_CACHE_SALT to trigger relinking. 2016-06-10 14:33:47 -04:00
Ben Newman
dc9941bfa6 Return {path,id,stat} from Resolver.prototype.resolve.
The id property is an absolute module identifer, suitable for passing to a
native Node require function.
2016-06-01 13:39:57 -04:00
Ben Newman
8a82a7af90 Use Resolver class to implement inputFile.resolve(id). 2016-06-01 01:39:23 -04:00
Ben Newman
64bbd70c1a Implement InputFile.prototype.readAndWatchFileWithHash.
Note that a module identifier is an acceptable input path, and will be
automatically converted to an OS-specific absolute path if necessary.
2016-06-01 01:39:22 -04:00
Ben Newman
b1df82ac0a Merge branch 'devel' into release-1.3.3 2016-05-31 14:09:46 -04:00
Gadi Cohen
dfee72792f Proper import chain for Meteor packages (closes #6907)
Don't include the ", false" for install() on traditional packages

add tests
2016-05-28 20:30:34 +02:00
Ben Newman
8395c7b832 Fix InputFile.prototype.require on Windows.
Fixes #7098.
2016-05-22 21:30:48 -04:00
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
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
f6b75305b3 Pay attention to unibuild.arch when determining usesModules.
Fixes #6877.
2016-05-17 14:27:56 -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
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
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
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
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
b4fe0d5c85 Allow importing .css files from node_modules directories.
Fixes #6037.
2016-04-07 13:05:49 -04:00
Ben Newman
5fc2e0c043 Use IsopackCache#uses to determine useMeteorInstall. 2016-04-01 21:39:31 -04:00
Ben Newman
be986fd709 Report compilation errors for lazy files at import time. 2016-03-31 20:09:53 -04:00
Ben Newman
85047f9d3f Improve wording of missing modules warnings. 2016-03-31 16:17:50 -04:00
Ben Newman
77f2fdf426 Silence missing module warnings generated by Meteor packages.
A better way to verify package dependencies is coming: #6322.
2016-03-31 16:17:49 -04:00
Ben Newman
a86c61eb9b Don't warn about unresolved modules in Browserify/Webpack bundle files.
Fixes https://github.com/practicalmeteor/meteor-mocha/issues/19
Related: https://github.com/meteor/todos/issues/90
See also: 62c41b2ef5
2016-03-31 16:17:49 -04:00
Ben Newman
151e8fa295 Silence some noisy missing module warnings.
Follow-up to #6562.
2016-03-24 20:35:37 -04:00
Ben Newman
a1a30891be Don't be fooled by absolute-looking relative paths.
Fixes https://github.com/meteor/meteor/issues/6586#issuecomment-201066077
2016-03-24 19:45:53 -04:00