happylynx / flow-webpack-plugin Goto Github PK
View Code? Open in Web Editor NEWA webpack plugin allowing to call Flow type checker.
A webpack plugin allowing to call Flow type checker.
When there are flow errors coming from flowOutput I always get extra errors following webpack bundle stats. These particular errors should have been resolved by mapping 'less' in .flowconfig
but for some reason I still get them here. If I fix all flow errors I don't get these extra errors. If run flow status
there are only the regular error messages.
Webpack is still running and the plugin is not failing but I should scroll my terminal every single time to check what I need to see.
#.flowconfig
[ignore]
<PROJECT_ROOT>/www/.*
<PROJECT_ROOT>/gulp/.*
<PROJECT_ROOT>/tests/.*
[include]
<PROJECT_ROOT>/src/.*
[libs]
flow-typed
[options]
module.file_ext=.js
server.max_workers=3
module.name_mapper.extension='less' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'
module.name_mapper.extension='sass' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'
module.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'
module.name_mapper.extension='png' -> '<PROJECT_ROOT>/flow/WebpackAsset.js.flow'
module.name_mapper.extension='jpg' -> '<PROJECT_ROOT>/flow/WebpackAsset.js.flow'
module.name_mapper.extension='jpeg' -> '<PROJECT_ROOT>/flow/WebpackAsset.js.flow'
module.name_mapper.extension='gif' -> '<PROJECT_ROOT>/flow/WebpackAsset.js.flow'
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
at the moment I receive a warning on Webpack4
DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
.../flow-webpack-plugin/dist/index.js:24
let errorToReport = undefined
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
So it works fine if I manually add use strict
, is there way around this?
Thanks!
It would be great if there is a boolean option, when we set it, it runs the flow after webpack compilation.
In this case, we have the options to run it on the bundles.
I do not have my config in the root because it stalls out looking in the node modules folder. would like to point it if possible
Hello,
I am unable to run this plugin. I followed the step process on readme, and after starting webpack it crashes immediately
/path/to/app/node_modules/flow-webpack-plugin/dist/index.js:22
let errorToReport = undefined
^^^SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Module._extensions..js (module.js:422:10)
at Object.require.extensions.(anonymous function) [as .js] (/path/to/app/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object. (/path/to/app/webpack/dev.js:8:1)
at Module._compile (module.js:413:34)
at loader (/path/to/app/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/path/to/app/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
My current dependencies are listed bellow
"devDependencies": {
...
"flow-bin": "^0.40.0",
"flow-webpack-plugin": "^0.3.6",
"webpack": "^2.2.1",
}
If you set flowPath
to a globally installed flow
without any local flow
, this plugin still throws an error like:
Error: `flow` can't be found. Please either install it (`npm install --save-dev flow-bin`) or set `flowPath` option
at FlowWebpackPluginError (.../flow-webpack-plugin/dist/index.js:262:1)
at getLocalFlowPath (.../flow-webpack-plugin/dist/index.js:200:28)
at applyOptionsDefaults (.../flow-webpack-plugin/dist/index.js:254:19)
at new FlowWebpackPlugin (.../flow-webpack-plugin/dist/index.js:27:20)
...
.
I'd expect to be able to direct the plugin to my global flow and for this to all work without any local flow
install.
I think the reason that it fails is that applyOptionDefaults
calls getLocalFlowPath
too eagerly. That function throws the exception but is always called---even when a flowPath
is provided. Instead, it should be a thunk or something analogous and only called if flowPath
is missing.
With a configuration like
new FlowWebpackPlugin({
failOnError: true
})
and running webpack -w
the webpack process is termintated when Flow errors exist with:
Flow validation failed.
Error: path/to/source.js:42
... more flow error details
I think this is due to the implementation of afterUserCallback
in https://github.com/happylynx/flow-webpack-plugin/blob/master/src/index.js#L156-L168. There even is a comment stating
/*
* argument passed to callback() causes webpack to immediately stop, even in watch mode,
* don't emit assets, and set return code to 1
*/
There is only a check for plugin.options.failOnError. IMO the code would need to check if it is running in watch mode and just continue by calling webpackCallback()
without arguments to avoid stopping the process.
Note: The behaviour is the same, even when explicitly specifying:
new FlowWebpackPlugin({
failOnError: true,
failOnErrorWatch: false
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.