Got "Module build failed" out of the blue
dharmax opened this issue · comments
Summary:
A day old project which worked, suddenly stopped working. Code didn't change between the sweet spot to the failure.
Dependencies
"dependencies": {
"riot": "^4.0.0-rc.2",
"faye": "^1.2.4"
},
"devDependencies": {
"@riotjs/compiler": "^4.0.0",
"@riotjs/hot-reload": "^4.0.0-beta.1",
"@riotjs/webpack-loader": "^4.0.0",
"@types/typescript": "^2.0.0",
"ts-loader": "^5.4.3",
"typescript": "^3.4.4"
}
The error
Uncaught Error: Module build failed (from ./node_modules/@riotjs/webpack-loader/dist/riot-webpack-loader.cjs.js):
Error: Line 15: Unexpected token >
at ErrorHandler.constructError (:8000/opt/work-files/work/milestonePod2/fe/node_modules/esprima/dist/esprima.js:5012)
at ErrorHandler.createError (:8000/opt/work-files/work/milestonePod2/fe/node_modules/esprima/dist/esprima.js:5028)
at Parser.unexpectedTokenError (:8000/opt/work-files/work/milestonePod2/fe/node_modules/esprima/dist/esprima.js:1985)
at Parser.throwUnexpectedToken (:8000/opt/work-files/work/milestonePod2/fe/node_modules/esprima/dist/esprima.js:1995)
at Parser.parsePrimaryExpression (:8000/opt/work-files/work/milestonePod2/fe/node_modules/esprima/dist/esprima.js:2366)
at Parser.inheritCoverGrammar (:8000/opt/work-files/work/milestonePod2/fe/node_modules/esprima/dist/esprima.js:2
The unexpected token is of course not the real problem. Even when I removed parts of the code it keeps pointing as something as wrong].
Workaround
not found yet.
i tried to delete the dist directory for no avail.
webpack.config.js
const path = require('path')
module.exports = {
mode: 'development',
entry: [
path.resolve(__dirname, 'src/main.ts')
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
libraryTarget: 'umd',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: [{
loader: 'ts-loader'
}],
exclude: /node_modules/,
},
{
test: /\.riot$/,
exclude: /node_modules/,
use: [{
loader: '@riotjs/webpack-loader',
options: {
hot: false, // set it to true if you are using hmr
// add here all the other @riotjs/compiler options riot.js.org/compiler
// template: 'pug' for example
}
}]
},
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
}
@dharmax you configuration looks good except for the extenstions
key, shuldn't .riot
be listed as well?
It worked before without it. i added it now and still get the same failure.
can you set up a repo or a zip file to show me the issue? I guess the issue is somewhere else not in the webpack plugin.
How can i send it to you in private?
my email is available via github profile
you had syntax error in your login-box.riot
component:
<form ()=class="form" onsubmit={>true }>
the line above is not valid html nor riot syntax.
webpack dispatched the error on the proper line:
Line 9: Unexpected token >
Good luck