risen228 / craco-alias

A craco plugin for automatic aliases generation for Webpack and Jest
MIT License
109 stars 11 forks source link

Error if paths are already absolute #31

Closed kdziamura closed 3 years ago

kdziamura commented 3 years ago

https://github.com/risenforces/craco-alias/blob/12071df5ce0d726adb4adb41162c6cd7e95117bb/plugin/extract-aliases/normalize-aliases.js#L10-L11

path.join doesn't work if there're already absolute paths in the aliases option. Maybe it's better to use path.resolve?

Example debug output:

Initial options:

{
  "source": "options",
  "baseUrl": "./",
  "aliases": {
    "PACKAGE": "/APP_ABSOLUTE_PATH/node_modules/PACKAGE",
  },
  "debug": true,
  "unsafeAllowModulesOutsideOfSrc": false
}

Initial aliases:

{
  "PACKAGE": "/BASE_PATH/APP_ABSOLUTE_PATH/node_modules/PACKAGE",
}

The same here: https://github.com/risenforces/craco-alias/blob/1b9940df7cc8ffe9ce6f5ef569bb3e34c2c86027/plugin/extract-aliases/index.js#L31

There's no option to use absolute path even in baseUrl