You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ra...@apache.org on 2019/10/27 23:03:05 UTC
[incubator-annotator] 01/02: Specify babel module resolver options
once
This is an automated email from the ASF dual-hosted git repository.
randall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit c5427459dde442ebfb585cb19afa8344717a63b9
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Sun Oct 13 20:31:45 2019 -0400
Specify babel module resolver options once
---
.eslintrc.js | 15 ++++++++++-----
babel.config.js | 4 ++--
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/.eslintrc.js b/.eslintrc.js
index cb6c43c..526cfc3 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,3 +1,12 @@
+const babel = require('@babel/core');
+
+// Use the root babel.config.js for module resolution.
+// Relevant issue: tleunen/eslint-import-resolver-babel-module#89
+const babelOptions = babel.loadOptions({ cwd: __dirname });
+const babelModuleResolver = babelOptions.plugins.find(
+ ({ key }) => key === 'module-resolver',
+);
+
module.exports = {
root: true,
env: {
@@ -44,11 +53,7 @@ module.exports = {
},
settings: {
'import/resolver': {
- 'babel-module': {
- alias: {
- '^@annotator/(.+)$': '@annotator/\\1/src/index.js',
- },
- },
+ 'babel-module': babelModuleResolver.options,
},
},
overrides: [
diff --git a/babel.config.js b/babel.config.js
index 6469948..ffb36ab 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -35,7 +35,7 @@ module.exports = api => {
};
// Options for the module-resolver plugin.
- // Used for resolving source files during development and testing.
+ // Used for resolving source files during development.
let resolverOptions = {
alias: {
'^@annotator/(.+)$': '@annotator/\\1/src/index.js',
@@ -54,7 +54,7 @@ module.exports = api => {
plugins: [
'preserve-comment-header',
['@babel/transform-runtime', runtimeOptions],
- ...(DEV || TEST ? [['module-resolver', resolverOptions]] : []),
+ ...(DEV ? [['module-resolver', resolverOptions]] : []),
...(TEST ? ['istanbul'] : []),
],
presets: [['@babel/env', envOptions]],