Skip to content

Commit

Permalink
BREAKING CHANGE: function alias renamed to aliasWebpack #60
Browse files Browse the repository at this point in the history
  • Loading branch information
oklas committed Feb 22, 2022
1 parent 4676bf3 commit bee697b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
36 changes: 28 additions & 8 deletions docs/migration.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
# Migration

# Migration from react-app-rewired-alias
## Migration from react-app-rewired-alias

Dangerous mode is renamed to extended/extremal. The implementation
for dangerous mode is moved to separaded liblrary with suffix **`-ex`**.
### Generic mode

* Replace library name for generic mode

```diff
- const {alias} = require('react-app-rewire-alias')
+ const {alias} = require('react-app-alias')
- const {...} = require('react-app-rewire-alias')
+ const {...} = require('react-app-alias')
```

* Rename function `alias` to `aliasWebpack`

```diff
- const {alias} = require('react-app-alias')
+ const {aliasWebpack} = require('react-app-alias')
```

### Dangerous mode

Dangerous mode is renamed to extended/extremal and the implementation
is moved to separated liblrary with suffix **`-ex`**.

* Replace library name for dangerous mode,
* Remove `/lib/aliasDangerous` path part from import,
* Notice that library name is different (suffix `-ex` added),
* Fangerous mode function `aliasDangerous` for `react-app-rewired` or `customize-cra` is renamed to `alias`.

```diff
- const {aliasDangerous} = require('react-app-rewired-alias/lib/aliasDangerous')
+ const {alias} = require('react-app-alias-ex')
- const {...} = require('react-app-rewired-alias/lib/aliasDangerous')
+ const {...} = require('react-app-alias-ex')
```

* For dangerous mode function `aliasDangerous` for `react-app-rewired` or `customize-cra` is renamed to `aliasWebpack` (also same as function `alias` for generic mode).

* Rename function `alias` to `aliasWebpack`

```diff
- const {aliasDangerous} = require('react-app-alias-ex')
+ const {aliasWebpack} = require('react-app-alias-ex')
```


4 changes: 2 additions & 2 deletions example/above/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {aliasDangerous, aliasJest, configPaths} = require('react-app-alias-ex')
const {aliasWebpack, aliasJest, configPaths} = require('react-app-alias-ex')

const aliasPaths = configPaths('./tsconfig.paths.json')

module.exports = aliasDangerous(aliasPaths)
module.exports = aliasWebpack(aliasPaths)
module.exports.jest = aliasJest(aliasPaths)
4 changes: 2 additions & 2 deletions example/main/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {alias, aliasJest, configPaths} = require('react-app-alias')
const {aliasWebpack, aliasJest, configPaths} = require('react-app-alias')

const aliasPaths = configPaths('./tsconfig.paths.json')

module.exports = alias(aliasPaths)
module.exports = aliasWebpack(aliasPaths)
module.exports.jest = aliasJest(aliasPaths)
6 changes: 3 additions & 3 deletions packages/react-app-alias-ex/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function aliasJest(aliasMap) {
}
}

function aliasDangerous(aliasMap) {
function aliasWebpack(aliasMap) {
const aliasLocal = Object.keys(aliasMap).reduce( (a,i) => {
a[i] = path.resolve(paths.appPath, aliasMap[i])
return a
Expand All @@ -136,15 +136,15 @@ function aliasDangerous(aliasMap) {

const CracoAliasPlugin = {
overrideWebpackConfig: function({webpackConfig, pluginOptions}) {
return aliasDangerous(pluginOptions.alias||configPaths())(webpackConfig)
return aliasWebpack(pluginOptions.alias||configPaths())(webpackConfig)
},
overrideJestConfig: function({jestConfig, pluginOptions}) {
return aliasJest(pluginOptions.alias||configPaths())(jestConfig)
}
}

module.exports = {
aliasDangerous,
aliasWebpack,
aliasJest,
configPaths,
expandResolveAlias,
Expand Down
6 changes: 3 additions & 3 deletions packages/react-app-alias/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function checkOutside(aliasMap) {
const outside = Object.keys(aliasMap).reduce( (a, i) => {
if(isOutsideOfRoot(aliasMap[i])) {
console.error(
`alias '${i}' is outside of root - supported only by aliasDangerous`
`alias '${i}' is outside of root - supported only by react-app-alias-ex`
)
return true
}
Expand All @@ -63,7 +63,7 @@ function checkOutside(aliasMap) {
}
}

function alias(aliasMap) {
function aliasWebpack(aliasMap) {
checkOutside(aliasMap)
const aliasLocal = Object.keys(aliasMap).reduce( (a,i) => {
a[i] = path.resolve(paths.appPath, aliasMap[i])
Expand Down Expand Up @@ -154,7 +154,7 @@ const CracoAliasPlugin = {
}

module.exports = {
alias,
aliasWebpack,
aliasJest,
configFilePath,
configPathsRaw,
Expand Down

0 comments on commit bee697b

Please sign in to comment.