Improve the developer experience for theme pack / context plugins #682
Replies: 9 comments 13 replies
-
|
Yeah, although I wish we could have supported relative paths, if you keep going down, there were some issues 😞 If we could make it work though, that would be amazing. Maybe something #691 could help with? 🤔 |
Beta Was this translation helpful? Give feedback.
-
|
One thing about the isDevelopment flag is that Greenwood will always look in the src/ directory, even when building. const packageJson = require('./package.json');
const path = require('path');
module.exports = (options = {}) => [{
type: 'context',
name: `${packageJson.name}:context`,
provider: (compilation) => {
const templateLocation = options.__isDevelopment
? path.join(compilation.context.userWorkspace, 'layouts')
: path.join(__dirname, 'dist/layouts');
return {
templates: [
templateLocation
]
};
}
}];Ideally when creating a theme pack and running |
Beta Was this translation helpful? Give feedback.
-
|
Another observation, when creating the one off development resource there seems to be a discrepancy in how process.env.__GWD_COMMAND__ = command;In the tests I added here I was able to test the command in the resource like this return Promise.resolve(process.env.__GWD_COMMAND__ === 'develop' ... );But in my main theme pack repo, I had to add a space? return Promise.resolve((process.env.__GWD_COMMAND__ === ' develop') ... );Maybe it's something about how commands are getting passed between npm / yarn in npm scripts? Left the docs to match what I have in my repo just to be safe? 🤷♂️ |
Beta Was this translation helpful? Give feedback.
-
|
Noticed there's also an opportunity to clean up some code added here too as it seems that when theme pack was added and rebased into #674, Error: Cannot find module 'my-theme-pack'
Require stack:
- /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/plugins/resource/plugin-node-modules.js
- /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/config.js
- /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/compile.js
- /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/commands/build.js
- /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.resolve (internal/modules/cjs/helpers.js:94:19)
at NodeModulesResource.resolve (/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/plugins/resource/plugin-node-modules.js:29:85)
at /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/serve.js:4:421
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/serve.js:4:216
at async /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/serve.js:4:216
at async /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/serve.js:4:216
at async /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/serve.js:4:216
at async /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/serve.js:4:216 {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/plugins/resource/plugin-node-modules.js',
'/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/config.js',
'/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/lifecycles/compile.js',
'/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/commands/build.js',
'/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/packages/cli/src/index.js'
]
}So had to add a fallback in that case, to what our prior logic was, just to be safe. Would be nice to find a way to make sure this can interop nicely with our (Theme Pack) tests so we can remove this, although I suppose leaving the error handling in is fine. |
Beta Was this translation helpful? Give feedback.
-
|
Another opportunity to improve things for Greenwood, not so much developers, is in order to support #674 , we needed to add a work around for Theme Packs specifically. Maybe there could be a way to eliminate this, possibly in conjunction with #691 ? |
Beta Was this translation helpful? Give feedback.
-
|
Even after the v0.27.0 upgrade, for theme packs it seems, like the [greenwood-starter-presentation[(https://github.com/thescientist13/greenwood-starter-presentation) for some reason aren't bundling |
Beta Was this translation helpful? Give feedback.
-
|
After getting my personal theme pack working I have a couple of thoughts. The biggest is that it would be awesome if the Context plugin allowed me to implement the same object as Compilation.context, and have the "default" context from the consuming project's workspace get merged with the one provided by the plugin. I recognize that isn't a small ask. More minor, but potentially just as difficult to implement, is that on a number of occasions I hit situations where it was difficult to figure out what I was doing wrong because I couldn't get console.out anywhere in my code to work. It would really help if I could turn on, ideally something on the command line I could put in my scripts section of package.json, the ability to trace as plugins get initialized so that I can see
For this second one, I want to emphasize that each time this happened, when I did trace it down, it was always in fact something that I was doing wrong in my code. It just would have helped to have a bit more in the way of guardrails to tell me what I was doing wrong. |
Beta Was this translation helpful? Give feedback.
-
|
I don't want to configure any of them. It occurred to me that a read only view of them would let me know anything the greenwood.config.ts file knows. I could get reusable values for plugins like site title similar to the way you can with plugins in vite for essentially free (to me as a plugin author). It lets a plugin more easily allow for configured or rather parameterized behavior, which has a number of use cases for a resource plugin. |
Beta Was this translation helpful? Give feedback.
-
|
A read/write use case is that a plugin could inject its own directory into any of the search paths as it already does for layouts. Off hand that might only be useful for a context plugin paired with an external source plugin. The read only use cases are, I admit, at the forefront of my thinking. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently the workflow for developing and publishing a theme pack is a little clunky, so would be good to track and discuss ways to make this better.
Beta Was this translation helpful? Give feedback.
All reactions