question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Babel loader with ngAnnotate plugin

See original GitHub issue

Hey there. Loving your project!

Small Issue I currently have:

I want to use Babel with ngAnnotate to annotate my old AngularJS files after they have been bundled by angular-cli/webpack. I want use an Angular hybrid app.

Since ‘ng eject’ isn’t working anymore I wanted to use this library to include babel into my build.

I managed to get my custom webpack config loaded, but it doesn’t seem to pickup the files and transpile them.

This is how my configs are looking like:

angular.json

        "build": {
          "builder": "angular-cli-builders:custom-webpack-browser",
          "options": {
            "customWebpackConfig": {
              "path": "./webpack.config.js",
              "replaceDuplicatePlugins": true,
              "mergeStrategies": { "externals": "replace" }
            }

webpack.config.js

  module: {
    rules: [{
      test   : /\.js$/,
      exclude: /(node_modules|bower_components)/,
      use    : [{
        loader : 'babel-loader',
        options: {
          presets: [ 'es2015' ],
          plugins: [ require('babel-plugin-angularjs-annotate') ]
        }
      }]
    }]
  }
};

Do you have an idea what might be the problem here?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
just-jebcommented, Jun 11, 2019

If it’s not working you are welcome to create a reproduction repo and we’ll figure it out. I can reopen this issue or you can create a brand new one.

0reactions
tommckcommented, Jan 29, 2020

For the mean time, this is what my webpack.partial.ts file looks like:

import { CustomWebpackBrowserSchema } from '@angular-builders/custom-webpack';
import * as webpack from 'webpack';
import * as merge from 'webpack-merge';

export default (config: webpack.Configuration, _options: CustomWebpackBrowserSchema) => {

  const customConfig: webpack.Configuration = {
    module: {
      rules: [
        {
          test: /\.[j|t]s$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env'],
              plugins: ['@babel/plugin-proposal-object-rest-spread', 'angularjs-annotate', 'lodash']
            }
          }
        }
      ]
    }
  };

  return merge.strategy({
    'module.rules': 'prepend'
  })(config, customConfig);
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Babel loader with ngAnnotate plugin · Issue #12
I want to use Babel with ngAnnotate to annotate my old AngularJS files after they have been bundled by angular-cli/webpack.
Read more >
babel-plugin-angularjs-annotate
This plugin currently supports matching and transforming all of the patterns currently recognized by ng-annotate (explicit and implicit), and ...
Read more >
ng-annotate-loader v0.7.0
ng-annotate -loader Build Status. Webpack loader to annotate angular applications. Generates a sourcemaps as well. Installation.
Read more >
How to use ng-annotate with hybrid app based on angular-cli
Installing babel and babel-plugin-angularjs-annotate; Executing babel, which takes the files from src , adds the annotations, and puts the ...
Read more >
babel-loader
See the docs for more information. NOTE: You must run npm install -D @babel/plugin-transform-runtime to include this in your project and @babel ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found