Closed SimonDegraeve closed 9 years ago
This is a quick workaround for anybody having the same issue:
var regexp = function(pattern) {
pattern = new RegExp(pattern);
this.test = function(str) {
return pattern.test(str);
};
};
new regexp('\.scss$') // will not throw an error
An example of the error would be helpful here. Even better would be example code that is failing.
Any value that is a RegExp
in the Confidence object
will throw the error because of this line. So it is not really a bug but I am wondering why RegExp are not allowed.
I suspect that it's due to JSON not supporting regexs. @hueniverse is this the case?
I agree that this is detrimental for users who are using JS literals or ALCE to parse the confidence file as both of those situations supoprt RegEx literals
I need to see an actual config where you want to use Regex. The referenced line is there to prevent invalid nodes.
ping @SimonDegraeve
Hi sorry for the delay. I am not using confidence anymore. Feel free to close the issue. I will be back with a full example when I have a chance to use this library again.
ho about something like this?
var store = new Confidence.Store({
webpack: {
$filter: 'env',
production: {
entry: constants.src.js,
output: {
path: constants.dest.js.prod,
filename: '[name].js' // Template based on keys in entry above
},
module: {
loaders: [{
test: /\.jsx$/,
loader: 'jsx-loader'
}]
}
},
$default: {
watch: true,
entry: constants.src.js,
output: {
path: constants.dest.js.dev,
filename: '[name].js' // Template based on keys in entry above
},
module: {
loaders: [{
test: /\.jsx$/,
loader: 'jsx-loader'
},
{
test: /\.css/,
loader: 'css-loader'
}]
}
}
}
});
I'm also trying to create a Webpack plugin, and need to pass a Webpack config object to it that uses the test
RegExp property:
// webpack.config.js
module.exports = {
module: {
loaders: [{
test: /\.jsx?/,
loaders: ['babel'],
presets: ['react', 'es2015']
}]
}
};
// manifest.js
// using the latest Glue syntax
const manifest = {
registrations: [
{
plugin: {
register: './my-plugin',
options: {
config: require('./webpack.config.js')
}
}
}
]
};
Confidence 1.4.2 throws me this error:
Error: Invalid node object type
at error (/Users/user/project/node_modules/confidence/lib/store.js:211:22)
@patrickkettner I have the same problem as @prashaantt. Any idea?
@danielbayerlein have you tried the above workaround?
@patrickkettner The workaround does not work well with webpack v2.1.0-beta because the webpack default configuration used RegEx. See https://github.com/webpack/webpack/blob/6b0c20a53ad7b04d4282a8a5c334ea0982fd364c/lib/WebpackOptionsDefaulter.js#L25
@patrickkettner Can we add a support for RegEx?
@hueniverse do you recall the original reason for marking regexp as an invalid type?
No idea.
Any fix for this? still getting it
I have the same issue.
{
plugin: 'hapi-pagination',
options: {
meta: {
location: 'body'
},
reply: {
paginate: 'hapiPaginate'
},
routes: {
exclude: [
new RegExp('/documentation*'), // or /\/documentation*/,
new RegExp('/swaggerui*') // or /\/swaggerui*/,
]
}
}
}
Hi,
I use Confidence to build my webpack configuration. So I need to use a Regexp in the "loaders" part of webpack configuration but this is throwing an error.
Any suggestion how I can use Regexp? And why they are forbidden in Confidence?
Thanks