parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.39k stars 2.26k forks source link

`alias` doesn't seem to do anything at all #4534

Open RichardJECooke opened 4 years ago

RichardJECooke commented 4 years ago

🐛 bug report

Summary: parcel does not seem to be using the alias field in package.json to point to the correct version of vue, nor give any errors if the field is nonsense.

runtime command: node ./node_modules/.bin/parcel src/index.html

package.json:

  "alias": {
    "vue" : "../node_modules/vue/dist/vue.common.js"
  },

app.js:

import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
import Vue from 'vue'

Expected:

Actual:

Tests:

🎛 Configuration (.babelrc, package.json, cli command)

package.json:

{
  "name": "celi",
  "version": "0.1.0",
  "dependencies": {
    "bootstrap-vue": "^2.11.0",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "http-server": "^0.12.1",
    "parcel-bundler": "^1.12.4",
    "@vue/cli": "^4.3.1"
  },
  "alias": {
    "vue" : "../node_modules/vue/dist/vue.common.js"
  },
}

🔦 Context

If I try to set the vue path manually in my app.js file, like: import Vue from '../../node_modules/vue/dist/vue.common' then the website warns me it is using multiple instances of vue. So I'm trying to use this alias thing as described in your documentation page - https://parceljs.org/module_resolution.html. But it seems to be ignored entirely.

🌍 Your Environment

Software Version(s)
Parcel 1.12.4
Node 12.16.2
npm/Yarn 6.14.4
Operating System Latest Ubuntu through Windows Subsystem for Linux
RichardJECooke commented 4 years ago

Aha! My alias path was incorrect. I'd like to change this bug to Please make parcel.js throw a warning or error if an alias path cannot be found when compiling.

I had to change my alias to "vue": "/../node_modules/vue/dist/vue.common.js". and now it works.