Skip to content

Commit

Permalink
Use Next.js' built in absolute imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kmjennison committed Jul 21, 2020
1 parent c29c782 commit f8b1371
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 54 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
fetch: 'writable',
},
settings: {
// Handle linting for absolute imports.
'import/resolver': {
alias: [
['src', './src']
Expand Down
9 changes: 0 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,5 @@ module.exports = {
artifactDirectory: './src/relay/__generated__',
},
],
[
'module-resolver',
{
root: ['./'],
alias: {
src: './src',
},
},
],
],
}
5 changes: 5 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"baseUrl": "."
}
}
7 changes: 0 additions & 7 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ const nextConfig = {
URLS_USE_TRAILING_SLASH: process.env.URLS_USE_TRAILING_SLASH,
},
webpack: (config, options) => {
// Use absolute imports from 'src/'. See:
// https://github.com/zeit/next.js/blob/canary/examples/with-absolute-imports/next.config.js#L8
// We use eslint-import-resolver-alias in eslintrc.json to handle linting.
// https://github.com/benmosher/eslint-plugin-import/issues/1286
// eslint-disable-next-line no-param-reassign
config.resolve.alias.src = path.join(__dirname, 'src')

// Sentry error logging. See:
// https://github.com/vercel/next.js/blob/canary/examples/with-sentry-simple/next.config.js
//
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@babel/core": "^7.9.6",
"@testing-library/react-hooks": "^3.2.1",
"babel-jest": "^26.0.1",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-relay": "^9.1.0",
"codecov": "^3.6.5",
"enzyme": "^3.11.0",
Expand Down
38 changes: 1 addition & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3537,17 +3537,6 @@ babel-plugin-macros@^2.0.0:
cosmiconfig "^6.0.0"
resolve "^1.12.0"

babel-plugin-module-resolver@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-4.0.0.tgz#8f3a3d9d48287dc1d3b0d5595113adabd36a847f"
integrity sha512-3pdEq3PXALilSJ6dnC4wMWr0AZixHRM4utpdpBR9g5QG7B7JwWyukQv7a9hVxkbGFl+nQbrHDqqQOIBtTXTP/Q==
dependencies:
find-babel-config "^1.2.0"
glob "^7.1.6"
pkg-up "^3.1.0"
reselect "^4.0.0"
resolve "^1.13.1"

babel-plugin-relay@^9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-relay/-/babel-plugin-relay-9.1.0.tgz#e44573c6ea847951724cd3fea95219b36e759353"
Expand Down Expand Up @@ -6061,14 +6050,6 @@ fill-range@^7.0.1:
dependencies:
to-regex-range "^5.0.1"

find-babel-config@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.2.0.tgz#a9b7b317eb5b9860cda9d54740a8c8337a2283a2"
integrity sha512-jB2CHJeqy6a820ssiqwrKMeyC6nNdmrcgkKWJWmpoxpE8RKciYJXCcXRq1h2AzCo5I5BJeN2tkGEO3hLTuePRA==
dependencies:
json5 "^0.5.1"
path-exists "^3.0.0"

[email protected]:
version "3.3.1"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880"
Expand Down Expand Up @@ -7917,11 +7898,6 @@ json-stringify-safe@~5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=

json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=

json5@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
Expand Down Expand Up @@ -9537,13 +9513,6 @@ pkg-up@^2.0.0:
dependencies:
find-up "^2.1.0"

pkg-up@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-3.1.0.tgz#100ec235cc150e4fd42519412596a28512a0def5"
integrity sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==
dependencies:
find-up "^3.0.0"

[email protected]:
version "1.3.3"
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.3.tgz#646c77011899870b6a0903e75e997e8e51da7461"
Expand Down Expand Up @@ -10575,11 +10544,6 @@ require-main-filename@^2.0.0:
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==

reselect@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==

resolve-cwd@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d"
Expand Down Expand Up @@ -10623,7 +10587,7 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=

resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1:
resolve@^1.10.0, resolve@^1.12.0, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1:
version "1.13.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.13.1.tgz#be0aa4c06acd53083505abb35f4d66932ab35d16"
integrity sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==
Expand Down

0 comments on commit f8b1371

Please sign in to comment.