Amplitude-JavaScript icon indicating copy to clipboard operation
Amplitude-JavaScript copied to clipboard

Incorrect configuration for `nocompat` build target

Open BendingBender opened this issue 5 years ago • 0 comments

Currently (v5.9.0), the nocompat build target generates code that contains unshadowed module references. This leads to ReferenceError: module is not defined kind of error messages when the amplitude.nocompat.js is being used without a bundler like WebPack.

The problem lies in the configuration for this target (rollup.nocompat.js), it contains the following lines for the rollup-plugin-commonjs:

    commonjs({
      include: [
        'node_modules/query-string/**',
        'node_modules/@amplitude/ua-parser-js/**',
        'node_modules/blueimp-md5/**',
      ],
    }),

This transforms commonjs modules only for direct dependencies, all transitive dependencies are left untouched by this. This seems to depend on which npm frontend is used, I suppose that it will work correctly on older versions of npm and possibly yarn. In my opinion, this should be changed to the following (like it is right now in rollup.config.js) to cover all npm frontend versions:

    commonjs(),

BendingBender avatar Feb 21 '20 21:02 BendingBender