...
 
Commits (8)
  • wincent's avatar
    Make template.js flow strict · 71e16942
    wincent authored
    We need to suppress a lint here. I could extract this into a function
    but then I'd just be moving the suppression somewhere else. I think the
    only way to get rid of this without casts is to find a why to express it
    as an `instanceof` check.
    71e16942
  • wincent's avatar
    Remove duck-typing of streams in template.js · ecd52ee4
    wincent authored
    This enables us to satisfy Flow strict mode without having to use a
    cast.
    ecd52ee4
  • wincent's avatar
    Prettify · 4d01667e
    wincent authored
    4d01667e
  • wincent's avatar
    Change noflow to flow in routes · ff35c9c5
    wincent authored
    Exposed (another) bug in my use of `makeNotFound`, which means that my
    fix in d8809093 was incomplete.
    ff35c9c5
  • wincent's avatar
    b4854659
  • wincent's avatar
    Add --trace-deprecation to `yarn start` invocation · dafbde88
    wincent authored
    To make it easier to track down deprecation warnings.
    dafbde88
  • wincent's avatar
    Silence deprecation warning about `new Buffer()` · b83ef92c
    wincent authored
    ```
    [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and
    usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(),
    or Buffer.from() methods instead.
        at showFlaggedDeprecation (buffer.js:152:11)
        at new Buffer (buffer.js:167:3)
        at base64 ($SRCROOT/masochist/src/common/toGlobalId.js:12:12)
        at base64 ($SRCROOT/masochist/src/common/toGlobalId.js:21:10)
        at getCacheKey ($SRCROOT/masochist/src/server/loadContent.js:35:10)
        at getCacheKey ($SRCROOT/masochist/src/server/loadContent.js:54:20)
        at process.internalTickCallback (internal/process/next_tick.js:77:7)
    ```
    b83ef92c
  • wincent's avatar
    Avoid deprecated Webpack API in server/main.js · 14e34ab4
    wincent authored
    ```
     DeprecationWarning: Tapable.plugin is deprecated. Use new API on
     `.hooks` instead
        at Object.plugin ($SRCROOT/masochist/src/server/main.js:222:12)
        at Module._compile (internal/modules/cjs/loader.js:722:30)
        at Module._compile ($SRCROOT/masochist/node_modules/pirates/lib/index.js:83:24)
        at Module._extensions..js (internal/modules/cjs/loader.js:733:10)
        at Object.newLoader [as .js] ($SRCROOT/masochist/node_modules/pirates/lib/index.js:88:7)
        at Module.load (internal/modules/cjs/loader.js:620:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
        at Function.Module._load (internal/modules/cjs/loader.js:552:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
        at Object.<anonymous> ($SRCROOT/masochist/node_modules/@babel/node/lib/_babel-node.js:234:23)
    ```
    14e34ab4
......@@ -20,7 +20,7 @@
"pretty": "babel-node scripts/pretty.js",
"pretty-check": "babel-node scripts/pretty.js --check",
"relay": "babel-node scripts/compile.js",
"start": "MASOCHIST_CONTENT_REPO=$npm_package_config_content_repo babel-node src/server/main.js",
"start": "MASOCHIST_CONTENT_REPO=$npm_package_config_content_repo babel-node --trace-deprecation src/server/main.js",
"start-prod": "MASOCHIST_CONTENT_REPO=$npm_package_config_content_repo NODE_ENV=production node dist/server/main.js",
"test": "jest --forceExit",
"update-indices": "MASOCHIST_CONTENT_REPO=$npm_package_config_content_repo babel-node src/bin/updateIndices.js",
......
......@@ -40,7 +40,7 @@ export default class App extends React.Component<Props> {
* relative one that should be handled by the router, and if so, we hand it
* off to the router; otherwise, the browser handles it.
*/
_handleClick = (event: SyntheticMouseEvent<HTMLDivElement>) => {
_handleClick = (event: SyntheticMouseEvent<HTMLDivElement>) => {
let href = null;
let element = event.target;
if (!(element instanceof HTMLElement)) {
......
/**
* @noflow
* @flow
*/
import React from 'react';
......
/**
* @noflow
* @flow
*/
import React from 'react';
......
/**
* @noflow
* @flow
*/
import React from 'react';
......@@ -7,7 +7,7 @@ import {graphql} from 'react-relay';
import Link from '../../client/components/Link';
import Post from '../../client/components/Post';
import makeNotFound from '../NotFoundError';
import {makeNotFound} from '../NotFoundError';
import buildRoute from '../buildRoute';
export default buildRoute(
......
/**
* @noflow
* @flow
*/
import React from 'react';
......
/**
* @noflow
* @flow
*/
import React from 'react';
......
/**
* @noflow
* @flow
*/
import React from 'react';
......
......@@ -9,7 +9,7 @@ function base64(string: string) {
if (inBrowser) {
return btoa(string);
} else {
return new Buffer(string, 'utf8').toString('base64');
return Buffer.from(string, 'utf8').toString('base64');
}
}
......
......@@ -9,7 +9,10 @@ import React from 'react';
*/
export default function withContext(context, component) {
class ContextProvider extends React.Component {
static childContextTypes = {};
static childContextTypes = Object.keys(context).reduce((acc, key) => {
acc[key] = PropTypes.any.isRequired;
return acc;
}, {});
getChildContext() {
return context;
......@@ -20,9 +23,5 @@ export default function withContext(context, component) {
}
}
Object.keys(context).forEach(key => {
ContextProvider.childContextTypes[key] = PropTypes.any.isRequired;
});
return <ContextProvider>{component}</ContextProvider>;
}
......@@ -10,7 +10,9 @@ type RouteConfig = $ReadOnlyArray<{
* Parses a RouteConfig object and returns a list of Express-style path
* patterns ("/", "/blog", "/blog/*" etc).
*/
export default function gatherPaths(config: RouteConfig): $ReadOnlyArray<string> {
export default function gatherPaths(
config: RouteConfig,
): $ReadOnlyArray<string> {
const paths = [];
config.forEach(route => {
if (route.path === '*') {
......
......@@ -219,11 +219,11 @@ if (__DEV__) {
const proxy = httpProxy.createProxyServer();
const compiler = webpack(webpackConfig);
let bundleStart = null;
compiler.plugin('compile', () => {
compiler.hooks.compilation.tap('compilation-started', () => {
console.log('Starting bundle...');
bundleStart = Date.now();
});
compiler.plugin('done', () => {
compiler.hooks.done.tap('compilation-completed', () => {
console.log('Bundle finished in ' + (Date.now() - bundleStart) + 'ms.');
});
const bundler = new WebpackDevServer(compiler, {
......
/**
* @flow
* @flow strict
*/
import {Readable} from 'stream';
......@@ -71,14 +71,9 @@ export default function template(
process.nextTick(() => this.emit('error', err));
});
return;
} else if (
typeof item.on === 'function' &&
typeof item.pipe === 'function'
) {
// Quacks like a stream.
const stream: stream$Stream = (item: any);
} else if (item instanceof Readable) {
waiting = true;
stream.on('data', data => {
item.on('data', data => {
const string = data.toString();
if (buffering) {
chunks.push(string);
......@@ -88,13 +83,13 @@ export default function template(
}
}
});
stream.on('end', () => {
item.on('end', () => {
waiting = false;
if (!buffering) {
process.nextTick(tick);
}
});
stream.on('err', err => {
item.on('err', err => {
process.nextTick(() => this.emit('error', err));
});
return;
......
......@@ -14,7 +14,8 @@ const BUILDS = [
filename: 'bundle-[hash].js',
targets: '> 0.5%, last 2 versions, Firefox ESR, not dead',
terserOptions: {},
}, {
},
{
name: 'mjs',
filename: 'bundle-[hash].mjs',
targets: {esmodules: true},
......@@ -140,11 +141,7 @@ module.exports = BUILDS.map(({name, filename, targets, terserOptions}) => {
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
],
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
},
{
test: /\.svg$/,
......