Migration
March 8, 2022 ยท View on GitHub
Migration from react-app-rewired-alias
Generic mode
- Replace library name for generic mode
- const {...} = require('react-app-rewire-alias')
+ const {...} = require('react-app-alias')
- Rename function
aliastoaliasWebpack
- const {alias} = require('react-app-alias')
+ const {aliasWebpack} = require('react-app-alias')
If dangerous mode is not used, scroll dow through next section to continue.
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/aliasDangerouspath part from import, - Notice that library name is different (suffix
-exadded),
- const {...} = require('react-app-rewired-alias/lib/aliasDangerous')
+ const {...} = require('react-app-alias-ex')
-
For dangerous mode function
aliasDangerousforreact-app-rewiredorcustomize-crais renamed toaliasWebpack(also same as functionaliasfor generic mode). -
Rename function
aliastoaliasWebpack
- const {aliasDangerous} = require('react-app-alias-ex')
+ const {aliasWebpack} = require('react-app-alias-ex')
Options
Before the agrument of aliasWebpack() and aliasJest() was alias map.
Now the argument of these functions is options.
Alias map now is alias option. So replace:
const aliasMap = configPaths("./tsconfig.paths.json")
// or possible alias map created in code
const aliasMap = {
'@app': 'src/app',
'@lib': 'lib',
}
- module.exports = aliasWebpack(aliasMap)
- module.exports.jest = aliasJest(aliasMap)
+ module.exports = aliasWebpack({alias: aliasMap})
+ module.exports.jest = aliasJest({alias: aliasMap})
Fucntion configPaths() now become needed in rare cases. It is used internally.
Now you can specify path of tsconfig.json or jsconfig.json as an option.
- const aliasMap = configPaths("./tsconfig.paths.json")
- module.exports = aliasWebpack({alias: aliasMap})
+ module.exports = aliasWebpack({tsconfig: "./tsconfig.paths.json"})
If you uses standart name of these files you can skip it. It will be opned automatically.
- const aliasMap = configPaths("./jsconfig.paths.json")
- module.exports = aliasWebpack({jsconfig: "./jsconfig.paths.json"})
+ module.exports = aliasWebpack({})