Skip to content

Commit b57360d

Browse files
committed
2.9.0
2.9.0 - 2017-10-17 ----------------------------------------------- ## Building * Fixes static building via `npm run build-static`, by replacing broken `chunk-manifest-webpack-plugin` (closes #55) ## Webpack * Adds `src` to modules path, to avoid `src/` prefixes at the start of userland imports (closes #69) * Fixes stats configuration to work with the latest Webpack versions * Adds CORS config to webpack_dev_server, to enable LAN-wide browser hot-code reloading (closes #99) * Removes leading `/` in asset output, to allow defining a `<base>` tag in userland via React Helmet (closes #102) ## ESLint * Refactors rules, to be grouped by plugin * Adds `jsx-a11y/anchor-is-valid` rule to avoid 'href' on React Router `<Link>` attributes * Adds `function-paren-newline` rule to enforce consistent parenthesis * Adds `object-curly-newline` rule to allow one-line / multi-line object definitions * Fixes various kit and src files to conform to new rules ## React * Bumps to React v16 - officially out of RC! ## Config * Adds `.disableKoaHelmet()` for disabling [koa-helmet](https://www.npmjs.com/package/koa-helmet) on the server (closes #79) * Adds `.setKoaHelmetOptions()` for passing options to Koa Helmet * Sets `.koaHelmetOptions` and `.bodyParserOptions` to null by default ## App * Disables SSL by default ## Server * Removes leading `/` in bundled assets (along with Webpack) to allow for a `<base>` tag to define the load path ## Testing (Jest) * Fixes Jest testing to be compatible with Babel and React (closes #81, merges #84 - thanks @Nate0001) ## General * Fixes 'local' typo (merges #89 - thanks @kane-c) * Fixes misspelled `browserslist` file (merges #95 - thanks @klarstrup) * Adds idiomatic [React Helmet](https://github.com/nfl/react-helmet) `<head>` tags, adds missing html/body attributes, base, link, style, script and noscript, uses new `Helmet.renderStatic()` call (closes #101 & #94 - thanks @klarstrup) * Adds default `<base href="/" />` tag, when none is defined with React Helmet ## Docker * Adds Alpine-based `Dockerfile` to reduce Docker image size from 943mb -> 323mb (closes #98, merges #97 - thanks @kane-c) * Adds `docker-compose.yml` for production (closes #98) * Adds `docker-compose.dev.yml` for local development. Removes the local `node_modules` to ensure Alpine-compatible Linux binaries are being referenced by local code changes. Supports hot code reloading in-browser and via SSR ## NPM * Bumps packages: "babel-eslint": "^8.0.1" "copy-webpack-plugin": "^4.1.1", "cross-env": "^5.1.0", "eslint": "^4.9.0", "eslint-config-airbnb": "^16.1.0", "eslint-plugin-compat": "^2.0.1", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0", "extract-text-webpack-plugin": "^3.0.1", "file-loader": "^1.1.5", "graphql-tag": "^2.5.0", "iltorb": "^2.0.1" "jest": "^21.2.1", "less": "^3.0.0-alpha.3", "postcss-loader": "^2.0.8", "resolve-url-loader": "^2.1.1", "rimraf": "^2.6.2", "serve": "^6.2.0", "style-loader": "^0.19.0", "webpack": "^3.8.0", "webpack-chunk-hash": "^0.5.0", "webpack-config": "^7.5.0", "webpack-dev-server": "^2.9.2", "webpack-manifest-plugin": "^1.3.2", "apollo-server-koa": "^1.1.7", "graphql": "^0.11.7", "koa-send": "^4.1.1", "prop-types": "^15.6.0", "react": "^16.0.0", "react-apollo": "^1.4.16", "react-dom": "^16.0.0", "react-hot-loader": "^3.1.1"
2 parents ff243c7 + f6262c7 commit b57360d

File tree

17 files changed

+379
-158
lines changed

17 files changed

+379
-158
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"presets": [
3+
"react",
34
["env", {
45
"targets": {
56
"node": true

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ module.exports = {
1515
env: {
1616
node: true,
1717
browser: true,
18+
'jest/globals': true,
1819
},
1920
plugins: [
2021
'babel',
2122
'import',
2223
'jsx-a11y',
2324
'compat',
25+
'jest',
2426
],
2527
rules: {
2628
// General
@@ -67,6 +69,7 @@ module.exports = {
6769
'import/resolver': {
6870
node: {
6971
paths: [
72+
PATHS.src,
7073
PATHS.root,
7174
'node_modules',
7275
],

CHANGELOG.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
UNVERSIONED - 2017-10-17
1+
2.9.0 - 2017-10-17
22
-----------------------------------------------
33

44
## Building
55
* Fixes static building via `npm run build-static`, by replacing broken `chunk-manifest-webpack-plugin` (closes #55)
66

77
## Webpack
8+
* Adds `src` to modules path, to avoid `src/` prefixes at the start of userland imports (closes #69)
89
* Fixes stats configuration to work with the latest Webpack versions
910
* Adds CORS config to webpack_dev_server, to enable LAN-wide browser hot-code reloading (closes #99)
11+
* Removes leading `/` in asset output, to allow defining a `<base>` tag in userland via React Helmet (closes #102)
1012

1113
## ESLint
1214
* Refactors rules, to be grouped by plugin
@@ -26,13 +28,24 @@ UNVERSIONED - 2017-10-17
2628
## App
2729
* Disables SSL by default
2830

31+
## Server
32+
* Removes leading `/` in bundled assets (along with Webpack) to allow for a `<base>` tag to define the load path
33+
34+
## Testing (Jest)
35+
* Fixes Jest testing to be compatible with Babel and React (closes #81, merges #84 - thanks @nate0001)
36+
2937
## General
3038
* Fixes 'local' typo (merges #89 - thanks @kane-c)
3139
* Fixes misspelled `browserslist` file (merges #95 - thanks @klarstrup)
32-
* Adds idiomatic [React Helmet](https://github.com/nfl/react-helmet) `<head>` tags, adds missing html/body attributes, link, style, script and noscript, uses new `Helmet.renderStatic()` call (closes #101 & #94 - thanks @klarstrup)
40+
* Adds idiomatic [React Helmet](https://github.com/nfl/react-helmet) `<head>` tags, adds missing html/body attributes, base, link, style, script and noscript, uses new `Helmet.renderStatic()` call (closes #101 & #94 - thanks @klarstrup)
41+
* Adds default `<base href="/" />` tag, when none is defined with React Helmet
3342

34-
## NPM
43+
## Docker
44+
* Adds Alpine-based `Dockerfile` to reduce Docker image size from 943mb -> 323mb (closes #98, merges #97 - thanks @kane-c)
45+
* Adds `docker-compose.yml` for production (closes #98)
46+
* Adds `docker-compose.dev.yml` for local development. Removes the local `node_modules` to ensure Alpine-compatible Linux binaries are being referenced by local code changes. Supports hot code reloading in-browser and via SSR
3547

48+
## NPM
3649
* Bumps packages:
3750
"babel-eslint": "^8.0.1"
3851
"copy-webpack-plugin": "^4.1.1",

Dockerfile

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
1-
FROM debian:jessie-slim
1+
FROM node:8-alpine
22

3-
ENV EPHIMERAL_PACKAGES "build-essential dh-autoreconf curl xz-utils python"
4-
ENV PACKAGES "libpng-dev"
5-
6-
# Add `package.json` to build Debian compatible NPM packages
73
WORKDIR /src
8-
ADD package.json .
9-
10-
# install everything (and clean up afterwards)
11-
RUN apt-get update \
12-
&& apt-get install -y apt-utils \
13-
&& apt-get install -y ${EPHIMERAL_PACKAGES} ${PACKAGES} \
14-
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
15-
&& apt-get install -y nodejs \
16-
&& cd /src \
4+
5+
# Add NPM package config
6+
ADD package*.json ./
7+
8+
# The official image has verbose logging; change it to npm's default
9+
ENV NPM_CONFIG_LOGLEVEL notice
10+
11+
# Install everything (and clean up afterwards)
12+
RUN apk add --no-cache --virtual .gyp \
13+
autoconf \
14+
automake \
15+
g++ \
16+
libpng-dev \
17+
libtool \
18+
make \
19+
nasm \
20+
python \
1721
&& npm i \
18-
; apt-get remove --purge -y ${EPHIMERAL_PACKAGES} \
19-
; apt-get autoremove -y ${EPHIMERAL_PACKAGES} \
20-
; apt-get clean \
21-
; apt-get autoclean \
22-
; echo -n > /var/lib/apt/extended_states \
23-
; rm -rf /var/lib/apt/lists/* \
24-
; rm -rf /usr/share/man/?? \
25-
; rm -rf /usr/share/man/??_*
22+
&& apk del .gyp
2623

2724
# Add the remaining project files
2825
ADD . .
2926

30-
# Build distribution
31-
RUN npm run build
32-
3327
# Set the default host/port
3428
ENV HOST 0.0.0.0
3529
ENV PORT 4000
3630

31+
# Build distribution
32+
RUN npm run build
33+
3734
# Start the server by default
3835
CMD npm run server

docker-compose.dev.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Note: This is intended for use in local development
2+
version: '3.3'
3+
services:
4+
reactql-dev:
5+
build: .
6+
volumes:
7+
- .:/src
8+
- /src/node_modules
9+
ports:
10+
- 8080:8080
11+
- 8081:8081
12+
environment:
13+
HOST: "0.0.0.0"
14+
BROWSER_HOST: "0.0.0.0"
15+
PORT: "8081"
16+
command: npm start

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Note: For production. For development, use `docker-compose.dev.yml`
2+
version: '3.3'
3+
services:
4+
reactql-dev:
5+
build: .
6+
volumes:
7+
- .:/src
8+
- /src/node_modules
9+
ports:
10+
- 4000:4000
11+
environment:
12+
HOST: "0.0.0.0"
13+
BROWSER_HOST: "0.0.0.0"

jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
coverageReporters: ['text'],
3+
collectCoverageFrom: [
4+
'src/**/*.js(x)',
5+
],
6+
transform: {
7+
'^.+\\.js(x)$': '<rootDir>/jest.transform.js',
8+
},
9+
};

jest.transform.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
const babel = require('babel-jest');
3+
4+
module.exports = babel.createTransformer({
5+
presets: [
6+
'react',
7+
['env', {
8+
targets: {
9+
node: true,
10+
},
11+
}],
12+
],
13+
plugins: [
14+
['module-resolver', {
15+
root: ['.'],
16+
alias: {
17+
src: './src',
18+
},
19+
}],
20+
'transform-object-rest-spread',
21+
'syntax-dynamic-import',
22+
'transform-regenerator',
23+
'transform-class-properties',
24+
'transform-decorators-legacy',
25+
],
26+
});

kit/entry/server_dev.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ import server, { createReactHandler, staticMiddleware } from './server';
2121
// ----------------------
2222

2323
// Get manifest values
24-
const css = '/assets/css/style.css';
25-
const scripts = [
26-
'vendor.js',
27-
'browser.js'].map(key => `/${key}`);
24+
const css = 'assets/css/style.css';
25+
const scripts = ['vendor.js', 'browser.js'];
2826

2927
// Spawn the development server.
3028
// Runs inside an immediate `async` block, to await listening on ports

kit/views/ssr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Html = ({ helmet, scripts, window, css, children }) => (
1818
<meta httpEquiv="Content-Language" content="en" />
1919
<meta name="viewport" content="width=device-width, initial-scale=1" />
2020
{helmet.meta.toComponent()}
21+
{helmet.base.toString() ? helmet.base.toComponent() : <base href="/" />}
2122
<link rel="stylesheet" href={css} />
2223
{helmet.link.toComponent()}
2324
{helmet.style.toComponent()}

0 commit comments

Comments
 (0)