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

Idea: Doing a local module mapping for the project directory #1926

Closed
atrauzzi opened this issue Aug 27, 2017 · 4 comments
Closed

Idea: Doing a local module mapping for the project directory #1926

atrauzzi opened this issue Aug 27, 2017 · 4 comments

Comments

@atrauzzi
Copy link
Contributor

atrauzzi commented Aug 27, 2017

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 my package.json:

  "dependencies": {
    "my-static-src": "file:./src",

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 to gatsby-browser.js as config for my plugin. When onClientEntry 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 or gatsby-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?

@atrauzzi
Copy link
Contributor Author

cc. #1701

@KyleAMathews
Copy link
Contributor

Hey, this still an active issue?

@atrauzzi
Copy link
Contributor Author

atrauzzi commented Dec 23, 2017

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.

@KyleAMathews
Copy link
Contributor

Closing this issue as it's fairly old. If you have additional problems in this area, please open a new issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants