Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web UI] Avoid relative imports with module-resolver plugin #1363

Merged
merged 1 commit into from
Apr 24, 2018

Conversation

10xjs
Copy link
Contributor

@10xjs 10xjs commented Apr 23, 2018

What is this change?

Any absolute es6 import statement is resolved relative to the src directory.
Compared to a set of webpack aliases to specific directories within the project, this approach is more flexible, less fragile, and easier to reason.

Why is this change necessary?

This avoids the need to use deep relative paths that reference a file's current location making the app far easier to organize. This effectively allows any file in src to be referenced as a namespaced module, akin to any of the npm dependencies.

Does your change need a Changelog entry?

Nah.

Do you need clarification on anything?

Nah.

Were there any complications while making this change?

In order to use eslint-import-resolver-babel-module, babel-preset-react-app had to be abandoned. The new .babelrc file is a simplified copy of that preset preserving compatibility.

@10xjs 10xjs added component:web-ui Sensu dashboard improvements ready-for-review labels Apr 23, 2018
@10xjs 10xjs force-pushed the web/babel-module-resolver branch from 090d113 to a823d17 Compare April 23, 2018 23:06
Any absolute es6 import statement is resolved relative to the `src` directory. This avoids the need to use deep relative paths that reference a file's current location.

Compared to a set of webpack aliases to specific directories within the project, this approach is more flexible, less fragile, and easier to reason.

In order to use `eslint-import-resolver-babel-module`, `babel-preset-react-app` had to be abandoned. The new `.babelrc` file is a simplified copy of the previous preset.

Signed-off-by: Neal Granger <neal@nealg.com>
@10xjs 10xjs force-pushed the web/babel-module-resolver branch from a823d17 to 834fc8a Compare April 24, 2018 00:21
@jamesdphillips
Copy link
Contributor

jamesdphillips commented Apr 24, 2018

Build failure appears to be related to golang/lint#397.

Copy link
Contributor

@jamesdphillips jamesdphillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tyvm

@10xjs 10xjs merged commit 7d94d83 into master Apr 24, 2018
@10xjs 10xjs deleted the web/babel-module-resolver branch April 24, 2018 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:web-ui Sensu dashboard improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants