Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SamHwang1990
Copy link
Contributor

  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.

Fix the autonumeric external config
1. depend `autonumeric` as `autonumeric` in amd or commonjs environment.
2. depend `autonumeric` as `AutoNumeric` in global script environment.
SamHwang1990 referenced this pull request Nov 30, 2017
Complete the documentation on how to install and use the component
Add a link to the examples page and its source in the Readme
Fix the example script imports by removing the unneeded AutoNumeric link

Signed-off-by: Alexandre Bonneau <[email protected]>
@AlexandreBonneau
Copy link
Member

AlexandreBonneau commented Nov 30, 2017

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 AlexandreBonneau self-assigned this Nov 30, 2017
@adriandmitroca
Copy link

I just faced exact same issue with Ubuntu based machine.

@AlexandreBonneau
Copy link
Member

AlexandreBonneau commented Feb 20, 2018

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!

@GitzJoey
Copy link

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

@AlexandreBonneau
Copy link
Member

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?

@djereg
Copy link

djereg commented Mar 7, 2019

@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.

@shrpne
Copy link
Contributor

shrpne commented Oct 2, 2019

@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

@midzer
Copy link

midzer commented Sep 25, 2020

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"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants