Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flow typechecking as a webpack plugin #1854

Closed
wants to merge 33 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8e15dc2
Watch test files (so they retrigger webpack)
rricard Dec 6, 2016
19f86d1
Structure where to put upcoming module addition
rricard Dec 6, 2016
e0d373b
Create some sub compilations for tests
rricard Dec 8, 2016
e332fe5
Setup a plugin to run a flow checking lifecycle
rricard Dec 4, 2016
eddd11b
Make flow fail on CI builds
rricard Dec 4, 2016
097d7d9
Run flow as a server and check with status
rricard Dec 4, 2016
8ce4c6f
Add flow ignore comment to the start hints
rricard Dec 4, 2016
79911f8
Add flow-typed resolution at start
rricard Dec 4, 2016
e4b915c
Reset server stderr on restart
rricard Dec 4, 2016
d724efe
Move options as explicit props of the plugin
rricard Dec 4, 2016
a4e5632
Use arrow functions
rricard Dec 4, 2016
64f36ec
Refactor using promises and no class attrs
rricard Dec 4, 2016
bf66320
Add documentation for out-of-the-box flow
rricard Dec 5, 2016
7e65c5d
Schedule project init to complete before 1st check
rricard Dec 5, 2016
c001833
Process code-based flow checks
rricard Dec 5, 2016
aa76ae5
Get flow version internally without config
rricard Dec 5, 2016
3fc87ca
Check global flow version
rricard Dec 5, 2016
251bd9b
Add flow-typed to gitignore automatically
rricard Dec 5, 2016
4ed28fd
Add optional flow to end to end testing
rricard Dec 5, 2016
911bf6d
Run flow even if init failed
rricard Dec 5, 2016
3b06bf1
Remove fbjs ignores now that it's fixed
rricard Dec 5, 2016
52e207a
Remove flow-typed lib import (known by default!)
rricard Dec 5, 2016
c0188d9
Remove info about the .flowconfig in the docs
rricard Dec 5, 2016
be43c83
In e2e: assert flow is correctly showing errors
rricard Dec 5, 2016
46829e3
Only change gitignore if we create a flowconfig
rricard Dec 8, 2016
494b392
Merge branch 'tests-in-webpack'
rricard Dec 8, 2016
74705ff
Only consider src tests
rricard Dec 8, 2016
7489f54
Ignore directories in test glob
rricard Dec 9, 2016
58e8287
Ignore directories in test glob
rricard Dec 9, 2016
3639147
Don't reinit flow in a child compilation
rricard Dec 9, 2016
07a556e
Refine globbing
rricard Dec 9, 2016
42fcb3c
Merge branch 'tests-in-webpack' into rricard-master
rricard Dec 9, 2016
1e21de7
Don't put flow-typed on gitignore
Gregoor Mar 18, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Watch test files (so they retrigger webpack)
This will not process them for now...
rricard committed Dec 8, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8e15dc2072220828ce9a1c8a98be6610180b72a2
39 changes: 39 additions & 0 deletions packages/react-dev-utils/WatchTestFilesPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var glob = require('glob');
var path = require('path');

function computeGlob(pattern, options) {
return new Promise((resolve, reject) => {
glob(pattern, options || {}, (err, matches) => {
if (err) {
return reject(err);
}
resolve(matches);
});
});
}

function WatchTestFilesPlugin(testGlobs) {
this.testGlobs = testGlobs || [];
}

WatchTestFilesPlugin.prototype.apply = function(compiler) {
compiler.plugin('emit', (compilation, callback) => {
console.log()
Promise.all(this.testGlobs.map(globPattern =>
computeGlob(globPattern, {
cwd: compiler.options.context,
ignore: 'node_modules/**',
})
))
.then(globLists => [].concat.apply([], globLists))
.then(testFiles => {
testFiles.forEach(testFile => {
compilation.fileDependencies.push(path.join(compiler.options.context, testFile));
});
})
.then(callback)
.catch(console.error);
});
};

module.exports = WatchTestFilesPlugin;
2 changes: 2 additions & 0 deletions packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
@@ -20,12 +20,14 @@
"openBrowser.js",
"prompt.js",
"WatchMissingNodeModulesPlugin.js",
"WatchTestFilesPlugin.js",
"webpackHotDevClient.js"
],
"dependencies": {
"ansi-html": "0.0.5",
"chalk": "1.1.3",
"escape-string-regexp": "1.0.5",
"glob": "^7.1.1",
"html-entities": "1.2.0",
"opn": "4.0.2",
"sockjs-client": "1.0.3",
10 changes: 9 additions & 1 deletion packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
var WatchTestFilesPlugin = require('react-dev-utils/WatchTestFilesPlugin');
var getClientEnvironment = require('./env');
var paths = require('./paths');

@@ -226,7 +227,14 @@ module.exports = {
// to restart the development server for Webpack to discover it. This plugin
// makes the discovery automatic so you don't have to restart.
// See https://github.com/facebookincubator/create-react-app/issues/186
new WatchMissingNodeModulesPlugin(paths.appNodeModules)
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
// Tests won't have any linting unless they go through webpack.
// This plugin makes webpack aware of them without emitting them.
// See https://github.com/facebookincubator/create-react-app/issues/1169
new WatchTestFilesPlugin([
'**/__tests__/**',
'**/*.test.js',
]),
],
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.