GithubHelp home page GithubHelp logo

Comments (10)

sourenaraya avatar sourenaraya commented on June 8, 2024 2

I have no idea how webpack works, lol.
Note, that i am using
AutoNumeric : 'autonumeric/dist/autoNumeric.min'
not the
AutoNumeric : 'node_modules/autonumeric/dist/autoNumeric.min'

and it works.

Dont know why alias in vue-autonumeric's webpack.base.js not being used and\or working.

from vue-autonumeric.

SamHwang1990 avatar SamHwang1990 commented on June 8, 2024 2

I think there has two ways to fix this issue:

1. Do not use externals option in build/webpack.base.js
Generally, webpack does not bundle the dependencies in externals, which are expected to provided by repository which require current module.
If remove the externals option, the bundle file in vue-autoNumeric will include the source of autonumeric. Maybe this is not a good choice.

2. Keep the externals option, and add autonumeric to peerDependencies.
If this way works, it will be the better choice.
The autonumeric will be auto installed by outside repository, and the bundle file in vue-autoNumeric will be simplify.

from vue-autonumeric.

SamHwang1990 avatar SamHwang1990 commented on June 8, 2024 1

I'm sorry to suggest add autonumeric to peerDependencies because it does'n work.

I had created a pr and try to solve the problem: #5

I am not sure why you want to use AutoNumeric instead of autonumeric as the module name depended on. 😅😅😅

from vue-autonumeric.

sourenaraya avatar sourenaraya commented on June 8, 2024

adding this to webpack.conf.js resolves the problem. This should be in documentation.
resolve: { alias: { AutoNumeric : 'autonumeric/dist/autoNumeric.min', } },

from vue-autonumeric.

AlexandreBonneau avatar AlexandreBonneau commented on June 8, 2024

I created a test project using:

mkdir vueAutonum && cd vueAutonum
npm init # say yes to all
yarn add autonumeric vue-autonumeric webpack@2

...to compile vue-autonumeric with the old webpack version 2 with the files:

src/vueAutonumericTest.js:

import VueAutonumeric from '../node_modules/vue-autonumeric/dist/vue-autonumeric.min.js';

console.log(VueAutonumeric);

webpack.config.js:

module.exports = {
  entry : "src/vueAutonumericTest.js",
  output: {
    filename: "dist/bundle.js"
  },
  resolve: {
    alias: {
      AutoNumeric: 'node_modules/autonumeric/dist/autoNumeric.min',
    },
  },
};

Now, when I run ./node_modules/.bin/webpack, I get the error you mentioned:

Hash: 470e79379d7394141898
Version: webpack 2.7.0
Time: 135ms
           Asset     Size  Chunks             Chunk Names
./dist/bundle.js  12.7 kB       0  [emitted]  main
   [0] ./~/vue-autonumeric/dist/vue-autonumeric.min.js 9.29 kB {0} [built]
   [1] ./src/vueAutonumericTest.js 120 bytes {0} [built]

ERROR in ./~/vue-autonumeric/dist/vue-autonumeric.min.js
Module not found: Error: Can't resolve 'AutoNumeric' in '/home/user/vueAutonum/node_modules/vue-autonumeric/dist'
 @ ./~/vue-autonumeric/dist/vue-autonumeric.min.js 1:82-104
 @ ./src/vueAutonumericTest.js

How did you fix that exactly?

Note: the current version of vue-autonumeric already has the correct alias in build/webpack.base.js: AutoNumeric: 'node_modules/autonumeric/dist/autoNumeric.min',.

from vue-autonumeric.

AlexandreBonneau avatar AlexandreBonneau commented on June 8, 2024

Removing the AutoNumeric dependency from the externals is a no-no, since it would then generate a pretty big Vue component.

I'll try your second suggestions and use peerDependencies.

from vue-autonumeric.

AlexandreBonneau avatar AlexandreBonneau commented on June 8, 2024

Ok so I modified the AutoNumeric dependency to a peerDependencies...and the webpack build step (yarn build:release) output the exact same file.
This unfortunately does not solve the problem :/

from vue-autonumeric.

AlexandreBonneau avatar AlexandreBonneau commented on June 8, 2024

Thank you for the fix @SamHwang1990!
This now works with Webpack version 3 and 2.

from vue-autonumeric.

SamHwang1990 avatar SamHwang1990 commented on June 8, 2024

However, I think you had made something wrong in new commit a4a27ab.

1. autonumeric was bundled with when you change the module name depended on
Because the key autonumeric doesn't match the AutoNumeric in wepack config:

externals: {
     // This prevent bundling the AutoNumeric library inside the vue-autonumeric component
    // cf. https://webpack.js.org/configuration/externals/
    AutoNumeric: 'autonumeric'
}

2. With webpack, User no need to install autonumeric manually
In vue-autonumeric, you have specify autonumeric as dependency, which mean when npm or yarn run install phase, it will install the autonumeric automatically.

More details, npm will install the autonumeric in the node_modules/autonumeric, and yarn will install in the node_modules/vue-autonumeric/node_modules/autonumeric.

from vue-autonumeric.

AlexandreBonneau avatar AlexandreBonneau commented on June 8, 2024

Yes, this is fixed (for real this time) in v1.0.4.
@sourenaraya comment helped me define how to bundle the AutoNumeric library, thanks!

from vue-autonumeric.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.