Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

CommonJS formatted import resulting in build errors #464

Closed
@denver-HJS

Description

@denver-HJS

Hi, first off I'm very happy with this project and thank you for continuing to support it!

The issue I'm having is trying to import the Angular Datatables library as a web component. I am using Browserify in my Gulp build, which relies on CommonJS style module imports/exports. That being said, my Angular module is defined like so:

const angular = require('angular');

  var requires = [
    require('angular-material'),
    require('angular-ui-router'),
    require('angular-material-icons'),
    require('angular-datatables')];

  const igAppModule = angular.module('igApp', requires);

This has worked thus far with all of the other NPM packages included in the requires array. However, with the addition of the 'angular-datatables' dependency my Gulp build will only print out this nondescript error message

gulp-notify: [Compile Error] Unexpected token

The actual bundling of the modules occurs here (Note: I've taken off both the ngAnnotate and babelify transforms, but the error still persists):

var bundler = browserify({
    entries: entryPoint,
    debug: true,
    cache: {},
    packageCache: {},
    fullPaths: !isProd
  });

  var transforms = [
    { 'name':babelify, 'options': {}},
    { 'name':ngAnnotate, 'options': {}}
  ];

  transforms.forEach(function(transform) {
    bundler.transform(transform.name, transform.options);
  });

    var stream = bundler.bundle();

    return stream.on('error', errorHandler)
      .pipe(source(file))
      .pipe(gulpif(isProd, buffer()))
      .pipe(gulpif(isProd, srcMaps.init()))
      .pipe(gulpif(isProd, streamify(uglify({
        compress: { drop_console: true }
      }))))
      .pipe(gulpif(isProd, srcMaps.write('./')))
      .pipe(gulp.dest("./dist/"))
      .pipe(browserSync.stream({ once: true }));
  }

If you have any ideas on where I could be going wrong please advise.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions