tilgovi commented on a change in pull request #117:
URL: 
https://github.com/apache/incubator-annotator/pull/117#discussion_r747276780



##########
File path: babel.config.js
##########
@@ -47,14 +50,25 @@ module.exports = (api) => {
   // Options for the module-resolver plugin.
   // Used for resolving source files during development.
   const resolverOptions = {
-    alias: {
-      ...(DEV || TEST
-        ? {
+    ...(DEV || TEST
+      ? {
+          alias: {
             '^@apache-annotator/([^/]+)$': ([, name]) =>
-              path.join(__dirname, 'packages', name, '/src/index.ts'),
-          }
-        : null),
-    },
+              path.join(packagePath, name, '/src/index.ts'),
+          },
+          resolvePath(sourcePath, currentFile, opts) {
+            if (
+              currentFile.startsWith(packagePath) &&
+              currentFile.endsWith('.ts') &&
+              sourcePath.startsWith('.') &&
+              sourcePath.endsWith('.js')
+            ) {
+              return sourcePath.replace(/\.js$/, '.ts');
+            }
+            return resolvePath(sourcePath, currentFile, opts);
+          },

Review comment:
       I don't recall the arguments, but I have read through the issues about 
it. It doesn't seem likely. They don't want to get into the business of 
rewriting imports. Their position is that you should write `.js`. The 
TypeScript resolver knows how to resolve that to equivalent `.ts` files, and 
maybe part of the answer is to use `eslint-import-resolver-typescript`. 
However, it's helpful to have Babel for our final build anyway, and 
`babel-plugin-module-resolver` _will_ rewrite imports for us, and 
`eslint-import-resolver-babel-module` can piggyback off that, so this is what I 
think is the best thing for now.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@annotator.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to