coreprocess / babel-plugin-js-logger Goto Github PK
View Code? Open in Web Editor NEWBabel plugin to enable js-logger in your entire project efficiently.
Babel plugin to enable js-logger in your entire project efficiently.
Hello. How I can add hightlight library in Webstorm correctly?
If I use global Logger - when all work prefectly. if I use logger, when I has IDEA notificication what logger not imported.
Using babel 7 and webpack 4, the excludes defined for babel-loader already filter out files before running them through this plugin. However, the plugin does not honor that and instead uses its own exclude
option.
My example webpack rule:
{
test: /\.js$/,
exclude: [/node_modules\/(?!(some-module-that-needs-logger)\/).*/],
use: [
{
loader: 'babel-loader',
},
],
},
My babel.config.js plugin
[
'js-logger',
{
// TODO: The next line should not be needed, but because of this bug, all node-modules are excluded instead of honoring the exclusions defined for the babel-loader
exclude: [/node_modules\/(?!(some-module-that-needs-logger)\/).*/],
format: {
// some js-logger config
},
},
],
Basically with the latest babel and webpack, the exclusion checking code in this plugin can be removed. Maybe it wasn't needed in the first place, but I don't know.
I'm using this plugin on windows and I get the following output when I use level: 0
[hello-world:src\main\webapp\app\page\newClassType.container] Testing
I am importing the plugin to babel using the webpack babel-loader with the following:
['js-logger', { format: { level: 0}}]
When I use the default level of -1, I only get [hello-world] because this path is interpreted as a depth of 1, rather than the correct depth of 6.
Looking at the source code, it appears to only look for forward slash in the directory name and is not normalizing a Windows backslash before doing so:
line 33,34:
// adjust path length
modName = modName.split('/').filter(function(i) { return i.length > 0; });
I would suggest that you use the following code instead:
modName = modName.split(path.sep).filter(function(i) { return i.length > 0; });
The reference for path.sep is here: path.sep
Hello,
I try to use your plugin with a basic Webpack/Babel Configuration, but i never be able to use logger.info
, there is no error, but no logs too.
Can you help me ?
My confing :
.babelrc
{
"presets": [
["env", {
"targets": {
"browsers": ["> 1%", "last 2 versions", "Firefox ESR"]
},
"production": {
"presets": ["babili"]
}
}],
"stage-0"
],
"plugins": [ "transform-runtime", [ "js-logger", { "format": { "separator": "::", "project": true } } ] ]
}
webpack.config.babel.js
const configWebpackDev = {
devtool: '#eval',
context: path.resolve(__dirname, 'app'),
entry: './app.js',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('developpement')
})
],
resolve: {
modules: ['node_modules'],
extensions: ['.js']
}
}
package.json
"devDependencies": {
"babel-core": "^6.25.0",
"babel-jest": "^20.0.3",
"babel-loader": "^7.0.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.5.2",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"babili": "^0.1.2",
"cross-env": "^5.0.1",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"babel-runtime": "^6.23.0"
}
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.