Giter Site home page Giter Site logo

coreprocess / babel-plugin-js-logger Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 4.0 15 KB

Babel plugin to enable js-logger in your entire project efficiently.

JavaScript 100.00%
babeljs browser configurable javascript log-all logger named-logger nodejs plugin

babel-plugin-js-logger's Introduction

Hi there ๐Ÿ‘‹

Niklas Salmoukas' GitHub Stats

babel-plugin-js-logger's People

Contributors

coreprocess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

babel-plugin-js-logger's Issues

Webstorm highlight

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.

babel-loader excludes ignored

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.

Windows paths are not handled correctly

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

Doesn't work with Webpack2, Babel 6.24

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"
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.