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

Goog.Module: multiple entry points don't work properly #52

@samilyak

Description

@samilyak

Hi guys,

I have an issue with a multi-module build (I'm talking about output modules here related to code splitting and --module flag).

Here's my webpack config:

var path = require('path');
var webpack = require('webpack');
var ClosurePlugin = require("closure-webpack-plugin");

module.exports = {

  context: path.resolve(__dirname),

  entry: {
    'module1': './module1.js',
    'module2': './module2.js',
  },

  output: {
    filename: '[name].build.js',
    path: path.resolve(__dirname, '../www/js')
  },

  plugins: [
    new ClosurePlugin({
      mode: 'AGGRESSIVE_BUNDLE',
      closureLibraryBase: require.resolve('google-closure-library/closure/goog/base'),
      deps: [
        path.resolve(__dirname, './my-deps.js')
      ]
    }, {
      compilation_level: 'WHITESPACE_ONLY',
    }),

    new webpack.optimize.CommonsChunkPlugin({
      name: 'module1',
      minChunks: 2
    })
  ]

};

module1.js:

goog.provide('module1');

console.info('module1');

module2.js:

goog.provide('module2');
goog.require('module1');

console.info('module2');

Here's the output generated into module2.build.js:

webpackJsonp([0], function(__wpcc){'use strict';goog.provide("module2");goog.require("module1");console.info("module2");});

The problem is the inner function is never called.

When both module1.build.js and module2.build.js are linked to the page, I only see module1 string in the console output.
There's no module2 string.

This behaviour is reproducible for any number of modules more than 1 and any compilation_level.


On the other hand, if I comment out ClosurePlugin in the config, both modules run when loaded.
Here's module2.build.js in this case:

webpackJsonp([1],[
/* 0 */,
/* 1 */
/***/ (function(module, exports) {

goog.provide('module2');
goog.require('module1');

console.info('module2');

/***/ })
],[1]);

For this one I see both module1 and module2 strings in the console output.

This example covers only a case with 1 output module.


I feel like it's not an intended behaviour, that's why opened this issue.

I have node v8.9.4 on OSX 10.12.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions