Clean up - imports (beta)
Closed this issue · 1 comments
Description
Currently, imports in FDT refer to just the file name. It doesn't include the directory name, doesn't use relative paths, or absolute paths.
Now since imports are written like require("FixedDataTable")
, build will fail. To overcome this, we have a custom script (see buildNPMInternals.sh) which uses regex to transform this into require("./FixedDataTable")
(notice the ./)
Now all the files are put into the same directory, so that they are properly resolved with the current directory.
Problem:
This is very hard to manage, and regex needs to be changed if the transpiling ends up differently during upgrades (see #453).
Solution
We should clean up our imports to be more idiomatic.
Or use webpack's resolve.modules to resolve the imports from the root path rather than relatively.
More Info
This is a pain, could we clean up our imports to be more idiomatic and remove this in the future?
Alternatively you might be able to use webpack's resolve.modules to resolve the imports from the root path rather than relatively which is what we do in LD. It would still require specifying the path from the root rather than just the filename, but may be easier to migrate to than specifying relative path.https://webpack.js.org/configuration/resolve#resolvemodules
https://opengrok.schrodinger.com/xref/seurat/SEURAT-JavaScript/webpack/common.config.js#68
Closing the issue as it was resolved through #519, where the haste resolver was removed in favor of using relative imports.