1. 16 Dec, 2018 3 commits
    • wincent's avatar
      Tighten up Flow annotations in a bunch of places · d8809093
      wincent authored
      Includes a bug fix discovered while doing the pass (misuse of
      `makeNotFound` helper), and inserting `noflow` annotations in the files
      I don't want to deal with yet, so I have an easy-to-grep-for marker that
      I can find again later.
    • wincent's avatar
      Add Flow annotations to <App /> component · 92c7548e
      wincent authored
    • wincent's avatar
      Make ES modules bundle as well · ba7fdb91
      wincent authored
      Reduces bundle size for modern browsers from about 483,477 bytes
      (uncompressed) to 392,782 bytes (uncompressed). After gzip, it's 121,228
      bytes down to 100,848 bytes.
      Discovered that ExtractTextPlugin is deprecated for recent Webpack, so
      switched to MiniCssExtractPlugin. Also, switched to contenthash for
      better caching and because otherwise I end up writing the same extracted
      CSS twice under two different hashes (I'm still writing it twice, but at
      least it's idempotent now).
      Closes: https://github.com/wincent/masochist/issues/133
  2. 14 Dec, 2018 11 commits
    • wincent's avatar
    • wincent's avatar
      Update flow-typed definitions · 2500b7e5
      wincent authored
      npm install -g flow-typed
      flow-typed install
    • wincent's avatar
      Suppress some new errors brought by the new version of Flow · e4137b27
      wincent authored
      Going to see if I can make these better than `any` at some point.
    • wincent's avatar
      Add @Flow to main app entry point · 35008a88
      wincent authored
    • wincent's avatar
      Don't use "defaults" as browserslist target for @babel/preset-env · 883dab00
      wincent authored
      Despite what the docs (https://babeljs.io/docs/en/babel-preset-env) say,
      it appears that not all the target queries supported by browserslist
      (https://github.com/browserslist/browserslist) can be used here.
      "default" is supposedly equivalent to "> 0.5%, last 2 versions, Firefox
      ESR, not dead", but when I add a `debug: true` flag, I see that it
      treats `targets` as `{}` and ends up producing a bundle which is a few
      KB larger (pre-gzip, I don't know about post-gzip). It looks to be the
      whole kaboodle. Disappointing that the list of included polyfills ends
      up being so large; a nice chunk gets trimmed off if you use a more
      aggressive target like "last 2 Chrome versions" (that's obviously not
      viable though). Over time, the bundle should get smaller though as more
      browsers drop off the list.
      Closes: https://github.com/wincent/masochist/issues/127
    • wincent's avatar
      Try to force useBuiltIns transform to work · 5d9210b3
      wincent authored
      Inspecting the dist/ folder shows no transform happening at all, so I
      wondered if it was being skipped on entry files and moved the `import`
      into the main app file instead. Of course, that's pointless because the
      main app file is also an entry point... As an experiment, I moved it
      into a non-entry file, with the same result. My next step is going to be
      to try tweaking the @babel/preset-env targets to see if I can force a
    • wincent's avatar
      Switch from useBuiltIns "usage" -> "entry" · 38f49dd4
      wincent authored
      Prior to this change:
      - Bundle size 490626 bytes (124504 bytes gzipped)
      - Bundle size 487306 bytes (122293 bytes gzipped)
      A little surprised it isn't more, to be honest. When I double-check
      this in source-map-explorer I don't see much difference in the core-js
      Incidentally, I think this *should* obviate the need for the workaround
      implemented in aa401def, but when I look at the build
      dist/client/polyfill.js it looks untransformed to me... May have to do
      some further digging.
    • wincent's avatar
      Work around @babel/polyfill accessing non-existent `global` · aa401def
      wincent authored
      Seeing as I am using useBuiltins = 'usage' in my @babel/preset-env
      config, in theory I could just remove the polyfill from the entry
      section, but I am a bit wary of doing that due to its experimental
      status. Also, the docs (https://babeljs.io/docs/en/babel-preset-env)
      don't make it clear whether items like 'regenerator-runtime/runtime' get
      handled adequately or not, so I might just wait this one out.
      It seems certainly true that much of what is in the polyfill could be
      skipped as I am pretty sure I am not using all of it:
      All of this prompted because of this check in the polyfill:
        if (global._babelPolyfill && typeof console !== "undefined" && console.warn) {
          console.warn("@babel/polyfill is loaded more than once...");
        global._babelPolyfill = true;
      Which is causing this in prod (only, for some reason):
        Uncaught ReferenceError: global is not defined
    • wincent's avatar
      Create pipeline string up front before mutating invocations array · 3fa7aae7
      wincent authored
      Because we mutate the array as we go, this code was not necessarily
      producing full error messages.
    • wincent's avatar
      Fix <When> display · 8656eb51
      wincent authored
      I was obviously a bit tired when I rolled out the "N minute read" stuff
      and didn't sufficiently test this. There were pages using <When> without
      <Metadata> which lost their formatting, and the spacing looked off.
      Also, we had an unwanted trailing mid-dot, and an orphan CSS class that
      did nothing.
    • wincent's avatar
      Update Flow 0.87.0 -> 0.89.0 · e75d1868
      wincent authored
  3. 10 Dec, 2018 1 commit
  4. 09 Dec, 2018 5 commits
  5. 08 Dec, 2018 4 commits
  6. 28 Nov, 2018 4 commits
    • wincent's avatar
      Update some deps · d48bc00e
      wincent authored
    • wincent's avatar
      Unbreak `yarn gulp babel` · ec6d1807
      wincent authored
      Previously had only tested `yarn gulp webpack`. Simple configuration
      changes required by the move from v6 to v7.
    • wincent's avatar
      Switch from .babelrc to babel.config.js for all the wrong reasons · a3cd0ea6
      wincent authored
      Namely, to have something that prettier can format, and to have
      something that I can add comments to if I want.
    • wincent's avatar
      Add invariant() and use it to squelch a Flow complaint in server/search.js · 85fd6821
      wincent authored
      Flow is hard-coded to grok that `invariant()` will throw an error if the
      conditional expression fails, so let's use it. Following the somewhat
      standard approach that `invariant()` gets Babel transformed so as to
      avoid the function call and evaluation of the arguments unless the
      condition is falsy.
      In dev, we include a full message; in prod, we just explode because the
      message is basically useless at that point (any user advanced enough to
      see the console is also capable of see the stack trace).
      Instead of putting an environment check in the output of the transform
      as is often done, just have our prod and dev configs toggle the
      stripping behavior. This makes the transform simpler. Instead of making
      something like:
        if (!condition) {
          if (/* some kind of environment check */) {
            invariant(false, ...args);
          } else {
      and then relying on the build process to constantize the env check and
      then minify the dead branch away, we directly produce either:
        if (!condition) {
          invariant(false, ...args);
        if (!condition) {
           throw ...;
      In playing with astexplorer.net I also noted that changing the
      CallExpression itself was not doing what I wanted (Babel will make the
      `if` "statement" safe to use in expression position by either wrapping
      it in an IIFE or turning it into a ternary). If the CallExpression is in
      a statement, as it often, but won't always, will be, then substitute the
      entire statement instead.
      One final observation: about that `map` over the arguments; this is
      `__DEV__` only and that whole branch gets dead-code stripped in prod,
      and O(n) of tiny n is tiny. I'm actually a little surprised that Flow is
      cool with the conditional assignment of the `invariant()` definition,
      but just going to *shrug* and move on for now...
  7. 25 Nov, 2018 4 commits
  8. 24 Nov, 2018 8 commits