-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Idea: Doing a local module mapping for the project directory #1926
Comments
cc. #1701 |
Hey, this still an active issue? |
Correct me if I'm wrong, but I believe it is. The idea came from needing to locate a specific module by-convention for my plugin. I needed a way to obtain the path to the gatsby project source directory. This could be useful for a lot of similar and other functionality. Even moreso when a transpiler is involved because the code needs to be run through webpack still. |
Closing this issue as it's fairly old. If you have additional problems in this area, please open a new issue! |
Note: My gatsby project is authored in TypeScript using the official plugin and built from the default suggested project structure.
I'm currently authoring a browser plugin for gatsby and have been able to get it loading without having to resort to any duplicate bootstrap of TypeScript in
gatsby.config.js
. I got it working by doing this in mypackage.json
:By doing this, I insulated myself from having to come up with a convoluted way to pass an already-compiled version of my
.tsx
/.ts
module togatsby-browser.js
as config for my plugin. WhenonClientEntry
gets called, all I have to do is import"my-static-src/MyLocalProjectIntegrationBootstrapFile.ts"
and because by that point the gatsby ts plugin has booted,ts-loader
is available and everything goes into the normal dependency graph via webpack.So -- be it resolved that this works great and spares me having to resort to any workarounds, I'm wondering -- would it be worthwhile to add the project source path as a local module to all default gatsby starters? Something like
gatsby-src
orgatsby-program-directory
so that at any point in time you can reference something in that dir in your project code without having to worry about runtime semantics?The text was updated successfully, but these errors were encountered: