vue-autoNumeric icon indicating copy to clipboard operation
vue-autoNumeric copied to clipboard

Fix issue #4 Error when building with webpack 2 on linux

Open SamHwang1990 opened this issue 6 years ago • 8 comments

  1. Fix the autonumeric external config
  • depend autonumeric as autonumeric in amd or commonjs2 environment.
  • depend autonumeric as AutoNumeric in global script environment.

  1. The bundle of examples page is okay to include autonumeric

  1. Still has error in commonjs 1.0 module system. autonumeric export itself as a sub property of exports object:
exports["AutoNumeric"] = factory();

In commonjs 1.0 module system, maybe we shall import autonumeric like:

const AutoNumeric = require('autonumeric').AutoNumeric;

But we can ignore this error because both node.js and webpack are base on commonjs 1.1.

SamHwang1990 avatar Nov 30 '17 15:11 SamHwang1990

Hey @SamHwang1990 , thanks for the PR! Do you have tests that fails with the current setup?

On my end I have 3 build tests: the examples (with webpack 3), and 2 dummy projects with webpack 2 and webpack 3 respectively. (I need to push those dummy projects in the tests directory!)

About commonjs 1.0, the STATUS: SUPERSEDED BY 1.1 message shown in the link you pasted indeed points me to not support that old version. Is 1.0 used by any major piece of code though?

AlexandreBonneau avatar Nov 30 '17 18:11 AlexandreBonneau

I just faced exact same issue with Ubuntu based machine.

adriandmitroca avatar Feb 19 '18 14:02 adriandmitroca

I cannot reproduce that bug.

As I said, I created 2 small projects, one with webpack 2 and one with webpack 3, and both correctly compile the bundle.

The build log:

~/tests/vueAutonum|» webpack
Hash: 4d26f276b95c1addf194
Version: webpack 2.7.0
Time: 299ms
           Asset    Size  Chunks             Chunk Names
./dist/bundle.js  199 kB       0  [emitted]  main
   [0] ./~/vue-autonumeric/dist/vue-autonumeric.min.js 9.34 kB {0} [built]
   [1] ./~/autonumeric/dist/autoNumeric.min.js 186 kB {0} [built]
   [2] ./src/vueAutonumericTest.js 199 bytes {0} [built]


~/tests/vueAutonum3|» webpack
Hash: 9ec0e459cde1fa820c8e
Version: webpack 3.11.0
Time: 313ms
           Asset    Size  Chunks             Chunk Names
./dist/bundle.js  199 kB       0  [emitted]  main
   [0] ./src/vueAutonumericTest.js 199 bytes {0} [built]
    + 2 hidden modules

Could you please provide a test case where the build fail with webpack 2? Ideally, the fix should not break the webpack 3 build process.

Thanks!

AlexandreBonneau avatar Feb 20 '18 10:02 AlexandreBonneau

i've encounter this error also in centOS 7 something to do with the camelCasing of autoNumeric in the import

GitzJoey avatar May 17 '18 01:05 GitzJoey

Is this still relevant, now that Webpack 4.18+ is out? On my end, I still cannot reproduce the bug somehow, and everything gets compiled cleanly.

Shouldn't we close this?

AlexandreBonneau avatar Sep 14 '18 19:09 AlexandreBonneau

@AlexandreBonneau Yes, I thinks it is still relevant.

Running with gitlab-runner 10.8.0 (079aad9e)
  on gitlab 4693c154
Using Docker executor with image node:slim ...
Pulling docker image node:slim ...
Using docker image sha256:3c705b11a720f91d4e549849fa526a5ef250f25d79a0fcfdc2766f433a06bb5c for node:slim ...
Running on runner-4693c154-project-1-concurrent-0 via gitlab...

.
.
.
.
.

ERROR in ./node_modules/vue-autonumeric/dist/vue-autonumeric.min.js
Module not found: Error: Can't resolve 'AutoNumeric' in '/builds/xxxxxx/xxxxxx/node_modules/vue-autonumeric/dist'
 @ ./node_modules/vue-autonumeric/dist/vue-autonumeric.min.js 1:82-104
 @ ./node_modules/ts-loader??ref--22!./node_modules/vue-loader/lib??vue-loader-options!./resources/assets/js/components/I___E___Modal.vue?vue&type=script&lang=ts&
 @ ./resources/assets/js/components/I___E___Modal.vue?vue&type=script&lang=ts&
 @ ./resources/assets/js/components/I___E___Modal.vue
 @ ./node_modules/ts-loader??ref--22!./node_modules/vue-loader/lib??vue-loader-options!./resources/assets/js/components/I___V___Page.vue?vue&type=script&lang=ts&
 @ ./resources/assets/js/components/I___V___Page.vue?vue&type=script&lang=ts&
 @ ./resources/assets/js/components/I___V___Page.vue
 @ ./resources/assets/js/app.ts
 @ multi ./resources/assets/js/app.ts ./resources/assets/sass/app.scss ./resources/assets/sass/pdf.scss ./resources/assets/sass/aszf.scss ./resources/assets/sass/mail.scss ./resources/assets/sass/custom.scss ./resources/assets/sass/bootstrap.scss ./resources/assets/sass/themes/theme-a.scss ./resources/assets/sass/themes/theme-b.scss ./resources/assets/sass/themes/theme-c.scss ./resources/assets/sass/themes/theme-d.scss ./resources/assets/sass/themes/theme-e.scss ./resources/assets/sass/themes/theme-f.scss ./resources/assets/sass/themes/theme-g.scss ./resources/assets/sass/themes/theme-h.scss
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Job failed: exit code 1

webpack 3.12.0

Here on my Windows machine everything is OK. Builds prod without errors.

djereg avatar Mar 07 '19 00:03 djereg

@AlexandreBonneau have you tested in the linux environment? Because linux systems are case sensitive while macos and windows are not.

I guess the problem here is that npm on linux can't resolve package with the name AutoNumeric because it is not the same as autonumeric

shrpne avatar Oct 02 '19 16:10 shrpne

This is still an issue for me on linux environment.

Right now I have to manually fix in dist/vue-autonumeric.min.js module.exports=n(require("AutoNumeric")) to module.exports=n(require("autonumeric"))

midzer avatar Sep 25 '20 14:09 midzer