Resolve module aliases in Babel.
If we only resolve them in WebPack the tests will not work.
This commit is contained in:
parent
1590eff831
commit
e2125c3555
26
.babelrc
26
.babelrc
@ -14,6 +14,32 @@
|
|||||||
["transform-runtime", {
|
["transform-runtime", {
|
||||||
"useBuiltIns": true,
|
"useBuiltIns": true,
|
||||||
"useESModules": true
|
"useESModules": true
|
||||||
|
}],
|
||||||
|
["module-resolver", {
|
||||||
|
/**
|
||||||
|
* Use aliases to avoid relative path import hell.
|
||||||
|
*/
|
||||||
|
"root": [
|
||||||
|
/**
|
||||||
|
* Components
|
||||||
|
*/
|
||||||
|
"./src/components"
|
||||||
|
],
|
||||||
|
"alias": {
|
||||||
|
/**
|
||||||
|
* Top level src directories
|
||||||
|
*/
|
||||||
|
"Actions": "./src/actions/",
|
||||||
|
"Backends": "./src/backends/",
|
||||||
|
"Constants": "./src/constants/",
|
||||||
|
"Formats": "./src/formats/",
|
||||||
|
"Integrations": "./src/integrations/",
|
||||||
|
"Lib": "./src/lib/",
|
||||||
|
"Reducers": "./src/reducers/",
|
||||||
|
"Redux": "./src/redux/",
|
||||||
|
"Routing": "./src/routing/",
|
||||||
|
"ValueObjects": "./src/valueObjects/",
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
"babel-jest": "^21.2.0",
|
"babel-jest": "^21.2.0",
|
||||||
"babel-loader": "^7.0.0",
|
"babel-loader": "^7.0.0",
|
||||||
"babel-plugin-lodash": "^3.2.0",
|
"babel-plugin-lodash": "^3.2.0",
|
||||||
|
"babel-plugin-module-resolver": "^3.0.0",
|
||||||
"babel-plugin-transform-builtin-extend": "^1.1.0",
|
"babel-plugin-transform-builtin-extend": "^1.1.0",
|
||||||
"babel-plugin-transform-runtime": "^6.23.0",
|
"babel-plugin-transform-runtime": "^6.23.0",
|
||||||
"babel-preset-env": "^1.6.0",
|
"babel-preset-env": "^1.6.0",
|
||||||
|
@ -1,46 +1,9 @@
|
|||||||
/* eslint global-require: 0 */
|
/* eslint global-require: 0 */
|
||||||
|
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const path = require('path');
|
|
||||||
const { partial } = require('lodash');
|
|
||||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
|
|
||||||
const resolveAlias = partial(path.resolve, __dirname);
|
|
||||||
const componentsDir = 'src/components';
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
|
||||||
* Use aliases to avoid relative path import hell.
|
|
||||||
*/
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
/**
|
|
||||||
* Components
|
|
||||||
*/
|
|
||||||
App: resolveAlias(`${componentsDir}/App/`),
|
|
||||||
Collection: resolveAlias(`${componentsDir}/Collection/`),
|
|
||||||
Editor: resolveAlias(`${componentsDir}/Editor/`),
|
|
||||||
EditorWidgets: resolveAlias(`${componentsDir}/EditorWidgets/`),
|
|
||||||
MarkdownPlugins: resolveAlias(`${componentsDir}/MarkdownPlugins/`),
|
|
||||||
MediaLibrary: resolveAlias(`${componentsDir}/MediaLibrary/`),
|
|
||||||
UI: resolveAlias(`${componentsDir}/UI/`),
|
|
||||||
Workflow: resolveAlias(`${componentsDir}/Workflow/`),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Top level src directories
|
|
||||||
*/
|
|
||||||
Actions: resolveAlias('src/actions/'),
|
|
||||||
Backends: resolveAlias('src/backends/'),
|
|
||||||
Constants: resolveAlias('src/constants/'),
|
|
||||||
Formats: resolveAlias('src/formats/'),
|
|
||||||
Integrations: resolveAlias('src/integrations/'),
|
|
||||||
Lib: resolveAlias('src/lib/'),
|
|
||||||
Reducers: resolveAlias('src/reducers/'),
|
|
||||||
Redux: resolveAlias('src/redux/'),
|
|
||||||
Routing: resolveAlias('src/routing/'),
|
|
||||||
ValueObjects: resolveAlias('src/valueObjects/'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
29
yarn.lock
29
yarn.lock
@ -613,6 +613,16 @@ babel-plugin-lodash@^3.2.0:
|
|||||||
lodash "^4.17.4"
|
lodash "^4.17.4"
|
||||||
require-package-name "^2.0.1"
|
require-package-name "^2.0.1"
|
||||||
|
|
||||||
|
babel-plugin-module-resolver@^3.0.0:
|
||||||
|
version "3.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-3.0.0.tgz#a2fe5b97f7b809a8bbac18beada0a94d45987c63"
|
||||||
|
dependencies:
|
||||||
|
find-babel-config "^1.1.0"
|
||||||
|
glob "^7.1.2"
|
||||||
|
pkg-up "^2.0.0"
|
||||||
|
reselect "^3.0.1"
|
||||||
|
resolve "^1.4.0"
|
||||||
|
|
||||||
babel-plugin-syntax-async-functions@^6.8.0:
|
babel-plugin-syntax-async-functions@^6.8.0:
|
||||||
version "6.13.0"
|
version "6.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
|
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
|
||||||
@ -3276,6 +3286,13 @@ finalhandler@1.1.0:
|
|||||||
statuses "~1.3.1"
|
statuses "~1.3.1"
|
||||||
unpipe "~1.0.0"
|
unpipe "~1.0.0"
|
||||||
|
|
||||||
|
find-babel-config@^1.1.0:
|
||||||
|
version "1.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.1.0.tgz#acc01043a6749fec34429be6b64f542ebb5d6355"
|
||||||
|
dependencies:
|
||||||
|
json5 "^0.5.1"
|
||||||
|
path-exists "^3.0.0"
|
||||||
|
|
||||||
find-cache-dir@^1.0.0:
|
find-cache-dir@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
|
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
|
||||||
@ -6261,6 +6278,12 @@ pkg-up@^1.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
find-up "^1.0.0"
|
find-up "^1.0.0"
|
||||||
|
|
||||||
|
pkg-up@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f"
|
||||||
|
dependencies:
|
||||||
|
find-up "^2.1.0"
|
||||||
|
|
||||||
pleeease-filters@^4.0.0:
|
pleeease-filters@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/pleeease-filters/-/pleeease-filters-4.0.0.tgz#6632b2fb05648d2758d865384fbced79e1ccaec7"
|
resolved "https://registry.yarnpkg.com/pleeease-filters/-/pleeease-filters-4.0.0.tgz#6632b2fb05648d2758d865384fbced79e1ccaec7"
|
||||||
@ -7901,6 +7924,10 @@ requires-port@1.0.x, requires-port@1.x.x, requires-port@~1.0.0:
|
|||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
|
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
|
||||||
|
|
||||||
|
reselect@^3.0.1:
|
||||||
|
version "3.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147"
|
||||||
|
|
||||||
resolve-cwd@^2.0.0:
|
resolve-cwd@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
|
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
|
||||||
@ -7934,7 +7961,7 @@ resolve@1.1.7:
|
|||||||
version "1.1.7"
|
version "1.1.7"
|
||||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
|
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
|
||||||
|
|
||||||
resolve@^1.1.6, resolve@^1.1.7, resolve@^1.2.0:
|
resolve@^1.1.6, resolve@^1.1.7, resolve@^1.2.0, resolve@^1.4.0:
|
||||||
version "1.5.0"
|
version "1.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
|
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user