Improve the developer experience for theme pack / context plugins #682
Replies: 6 comments
-
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.
-
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