Commit Graph

41 Commits

Author SHA1 Message Date
Ben Newman
5bbcaedc01 Allow source processors to be registered for .js files.
We now fall back to hardcoded JS support only when no source processor is
registered, instead of simply ignoring .js source processors.
2015-07-16 18:02:07 -04:00
David Glasser
bdf1968ceb Change less heuristic back to default-process
In addition to the old `*.lessimport` and `*.import.less` mechanisms for
telling the `less` package that a file isn't a root, you can also put it
in an `import` subdirectory or pass `{isImport: true}` to
`api.addFiles`. We no longer will need to rename every less file when we
upgrade.

Next commit will revert the changes to examples and docs.
2015-07-16 00:29:19 -07:00
David Glasser
5a17a2064b Mostly tweak comments
Replace "XXX BBP" with more specific #BBPFoo
2015-07-15 13:33:51 -07:00
David Glasser
53038bf544 test getExtension() === null 2015-07-15 00:30:29 -07:00
David Glasser
19177cd778 mostly comments 2015-07-15 00:20:17 -07:00
David Glasser
bb0880c381 Fix and test registerCompiler addAsset 2015-07-14 23:55:49 -07:00
David Glasser
95b4b8f0b0 clean up error handling around linters
There were a few problems here:

- compiler.lint actually did things that could seriously fail (eg loading
  plugins) but used its buildmessage context to return *linter
  warnings*. So actual errors got lumped in with warnings and didn't
  prevent builds.  Fixed this by changing compiler.lint to return linter
  warnings as a return value and use its implicit buildmessage context
  only for build errors

- We weren't checking for errors after compiler.getMinifiers even though
  that loaded plugins and could fail

- We were using _.isEmpty(app.sourceProcessors.linter) to decide in
  lintBundle if we should say "no linter warnings" or "no linters were
  run", but this is a SourceProcessorSet now, not a dictionary, so we
  should have used the isEmpty method instead (so we were getting
  unnecessary "No linting errors" messages when there were no linters)

- compiler.compile still tried to run getSourcesFunc even if
  initializing the SourceProcessorSets failed

- Printing linter warnings in the runner looked different depending on
  whether it was right after doing a client refresh or not

- We were doing a temporary log of "Linting your app" and immediately
  logging "Linted your app". The point of temporary logs is to display
  while long processes run, but since linting is integrated, this didn't
  really make sense.  (Really we need to better integrate the progress
  bar and runlog, since progress fulfills most of the needs formerly
  done by the runlog.)
2015-07-14 23:28:23 -07:00
David Glasser
8684c2afbe use getActivePluginPackages more 2015-07-09 14:51:14 -07:00
David Glasser
ea45e6a9f1 Allow plugins to register specific filenames
This is in addition to registering for extensions. Note that only the
new SourceProcessor APIs allow this, not registerSourceHandler.

The filename in question is the basename of the file.  The file can be
found in any directory in any package.  If you want to be more picky,
you can just ignore other ones in your processFilesForTarget.

This introduces the SourceProcessorSet abstraction, which simplifies a
lot of repeated code around matching filenames with processors and
avoiding duplicates.

Missing tests.

See also #3985.
2015-07-08 17:23:31 -07:00
Slava Kim
9d610e8d26 Prefer source-maps in memory in a parsed JSON form 2015-07-06 15:25:11 -07:00
David Glasser
ef04a21dfd better error if published source has no handler 2015-06-30 01:38:37 -07:00
David Glasser
05366ab5c2 fix duplicate compiler extension errors
There are a few different times when we detect duplicate compiler
extensions.
(a) We detect them in Plugin.registerCompiler if a single
    isopack itself registers duplicate extensions.
(b) When compiling a unibuild in compiler.compile, we check to see if a unibuild's
    plugin-providing dependencies overlap.
(c) When preparing a unibuild for bundle-time source processing, we
    check the same condition.

(Why do we need to re-check in (c)? If a unibuild was published and
passed (b) at publish time but is being bundled with different versions
of dependencies, it might fail (c).)

There were a few fixes here:

- In compiler.js (b), if we detected a duplicate extension, the code to get
  the name of the conflict package was wrong and could throw.
- In compiler-plugin (c), we just weren't using buildmessage.

With just those fixes, we would actually see *both* kind of errors show
up if the error was in the app rather than a package, because
bundler.bundle didn't actually bail out on error after compiler.compile!
So we added that fix too, with a relatively conservative WatchSet.
2015-06-30 01:18:05 -07:00
David Glasser
dd548edd72 less: better error for unknown @import
also, fix coffee/less self-test
2015-06-30 00:09:42 -07:00
David Glasser
74e53700ff In-memory caching for linker 2015-06-29 20:02:05 -07:00
David Glasser
b033fb4e9f Even more Profile calls 2015-06-29 12:19:25 -07:00
Slava Kim
3857aa3312 Fix incorrect string concat 2015-06-26 11:22:20 -07:00
Slava Kim
120209e0af Specify which target was building when a build error occurs 2015-06-24 18:39:06 -07:00
Slava Kim
fe9d69a9f7 wip linting packages 2015-06-16 19:51:52 -07:00
Slava Kim
b59b73d34f Add addHtml method to compiler inputFile proto 2015-06-16 14:55:03 -07:00
David Glasser
cd173f9438 caching comment 2015-06-12 16:50:51 -07:00
David Glasser
44c815a955 coffee uses on-disk cache
Also combine the two coffee registerCompiler calls into one

it's a bad on-disk cache that should be improved to not write out all
the unchanged files every time too.  but the tests do show that it skips
the unnecessary recompile

less doesn't use an on-disk cache yet
2015-06-09 12:33:46 -07:00
David Glasser
bca7f0c23f cache coffeescript compilation in memory 2015-06-04 11:17:19 -07:00
David Glasser
722706beef Simplify SourceProcessor
Combine BuildPluginDefinition/CompilerPlugin into SourceProcessor.  We
don't actually need to ever regenerate the userPlugin objects unless
we're re-loading the Isopack that contains the plugin.

This should allow for in-memory caching in your compiler plugin.
2015-06-04 01:19:14 -07:00
David Glasser
6110c2aea3 Clean up some references to build plugins
Differentiate BuildPluginDefinition and CompilerPlugin better
2015-06-04 01:19:14 -07:00
David Glasser
8c89cfa175 Don't always set noLineNumbers
@benjamn convinced me that line numbers are still nice, and especially
so with the changes that let them come from original source files.  And
due to
b556e62262 (commitcomment-11437623)
noLineNumbers currently totally disables source maps, which is silly.
2015-06-04 01:19:13 -07:00
Slava Kim
dc89eb47ea Move and document getDeclaredExports 2015-06-04 01:19:13 -07:00
Slava Kim
77e592c9e3 Fix bugs in BBP Coffeescript implementation 2015-06-04 01:19:13 -07:00
Slava Kim
b167d6446f Checkpoint: coffeescript ported to BBP 2015-06-04 01:19:13 -07:00
David Glasser
623b6442fd apps appear to run!
we have not done the legacy-isopack work for js yet though
2015-06-04 01:19:12 -07:00
David Glasser
edcb5d5846 checkpoint: isopackets seem to build
apps don't run

and we didn't do the back-compat prelink stuff
2015-06-04 01:19:12 -07:00
David Glasser
c7b175b414 Checkpoint: write new format of isopack unibuilds
This has "declaredExports" instead of "packageVariables" and doesn't
contain prelink resources.

The backwards-compatibility mode knows how to read prelink resources and
packageVariables but doesn't write the prelink resource yet.
2015-06-04 01:19:12 -07:00
David Glasser
b7e70d000e Checkpoint: saving JS in packages
... but still making empty prelink and not reading the JS
2015-06-04 01:19:12 -07:00
Slava Kim
a8dd5031bf WIP for more Batch Plugins docs 2015-06-04 01:19:12 -07:00
David Glasser
73fcd11254 "source" resources require isopack-2 format
(Specifically, the isopack-2-unibuild unibuild format which only lives
in isopack-2 isopacks.)

When saving an isopack, we always save as isopack-2, and if the only
"source"s are CSS and JS we also try to make an isopack-1 version if
we're publishing the package (or saving it to our tropohouse).  If we're
just saving it to an app-specific IsopackCache, we don't bother to
create the old version (if an old version of the tool sees this app's
IsopackCache it will have a non-matching BUILT_BY and rebuild the
isopack).

This commit only implements the CSS side of things; the JS side will be
harder (we'll be putting multiple JS sources into the new isopack but
one prelink resource into the old one).
2015-06-04 01:19:12 -07:00
Slava Kim
ce77532fc1 Remove temp xxx APIs of batch plugin 2015-06-04 01:19:11 -07:00
David Glasser
bf04ffa169 CSS source maps for compiler plugins 2015-06-04 01:19:10 -07:00
David Glasser
7d7a64e921 support errors from compiler plugins 2015-06-04 01:19:09 -07:00
Slava Kim
ee4bd65fa7 Reduce the amount of shared code between CompilerPlugin's and LinterPlugin's 2015-06-04 01:19:09 -07:00
Slava Kim
66c1f6d621 Base for Linting plugins 2015-06-04 01:19:09 -07:00
Slava Kim
fceacf9ed2 Extract big part of the compiler-plugin.js into build-plugin.js 2015-06-04 01:19:08 -07:00
David Glasser
3d9a23834f re-work with no phases, and fix other things 2015-06-04 01:19:08 -07:00