-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Scoping: A typical webpack-addon-[name] package #42
Comments
I'm going to ping @developit and @addyosmani so they can help mold the user (addon author) and consumer (addon user) api and functionality. Below I'll list what I think feels like a great "user" surface api, and describe maybe a workflow. Hypothetical "Addon Author Dream Workflow"@developit is the maintainer of Preact and using webpack makes it trivial for his users to transition from react. But he also has a few boilerplates for initial setups (beyond a react=>preact) migrate that he recommends to people and would love to make the process easier and better adoption through a webpack addon. Hi imagines a user could simply do: Addon Project CreationCreates a new project locally and runs: Addon defaults, node api, and addon customizationThe webpack-addon repo comes with a "base" set of inquirer questions, and config out of the box. The webpack-addon lib has convenience api's for:
Now all that @developit has to do is specify the packages he'd like the user to have by default, prompt the user for additional "preact-friendly" libs based on questions, and maybe custom webpack config that he can map the AST transform to a inquirer question. He could even pull in a set of Addon deploymentFrom there |
This is just one idea, and maybe we can take pieces, start with a few items and go from there. |
For the project and file generation, this should be easily doable from a Yeoman generator. This does raise some questions:
Speaking from the perspective of the Neutrino CLI which does the tool part (no project generation), an addon maps to a Neutrino preset. Here is how we addressed these questions:
If you'd like to know more about how Neutrino tackled some of these issues, feel free to ask. I hope the work we've done so far can shed some light and help you with the webpack-cli tool. 😃 Links, for reference: https://github.com/mozilla-neutrino/neutrino-dev |
@TheLarkInn This is pretty rad. From engineer perspective we could do with
This would allow the user to both get a walkthrough of the addon creation as well as the actual functions/utils to use.
This would be a bit outside the CLI scope, but the idea to send the metadata for us to track is great for organizational purposes, I'm +1 to that. With the extend feature, I was thinking abit about using module.exports = {
....
childDep: ['webpack-addons-preact', 'webpack-addons-hot']
} we could extend the base config in that way. By default I think that the module layering, because of this is pretty convenient. If you specify module.exports = {
...
overRideRules: ['entry']
childDep: ['webpack-addons-preact', 'webpack-addons-hot']
} you care about that rule for that package, and similar for other packages. By default, the overhead package should have the most importance, so if My concern is getting to edge use cases like module.exports = {
...
module: require('./template.js')
} with template literals and then we use that module as an injection instead of us generating it, except we only care about the logic outside the config. template.jsDon't care about the code so much, just the idea of people expressing their code in various waysmodule.exports = (c) => {
return(
`
const path = require('path');
const webpack = require('webpack');
const CleanPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const projectRootPath = path.resolve(__dirname, '../');
const assetsPath = path.resolve(projectRootPath, './${c}');
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
const WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
const webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(require('./webpack-isomorphic-tools'));
`
)
} webpack-addons-somethingInject template at line 40 with the template given. (Readline is unstable, could need to use ASTs here too if it works.
|
@ev1stensberg my comment about Yeoman was more about using it internally, as it has a nice mapping of Inquirer prompts to file generation flow. You can use it programmatically without requiring the user to install yeoman, yo, or anything else. Pure webpack-cli. For overrides, I think the default should be that local configuration always overrides addon configuration. By passing a parameter that says which fields addons override from local, how do you resolve the case of multiple addons overriding the same field? Last-in-wins? |
@eliperelman I'll have a look at it, was discussed when starting to work on this tool. First in wins for childDep packages and first one in for initing with multiple addons. Have you accepted the invite for the cli slack? |
@ev1stensberg yep! I'm in there. |
Fwiw, https://github.com/yeoman/generator can help quite a lot with building out scaffolding support for community templates and has some nice helpers on top of inquirer as @eliperelman notes. We use this type of setup internally at Google for a few projects and externally in projects like the polymer-cli, where you get to enable the add-on workflows described above without end-users needing to think about yo, yeoman etc. It's pretty transparent. Over in Polymer, we implemented It sounds like Eli has you covered on Yeoman internals, but if any of us on the Yeoman side (including @SBoudrias, @sindresorhus, @silvenon) can help, feel free to holler 👋 |
@addyosmani Could you get someone from Polymer involved in this thread? These features are relative to our CLI. Would be great to suck out information from one of them guys, so we can build ours as great as possible! |
Update: |
Resolved for now in #105, closing. |
1. Discuss how we want to generate needed rules in a webpack-addon package
2. Discuss what to expected returned from an addons package for our transformer to run
3. Discuss on if we should allow
.babelrc
and such, to also be generated4. Come up with an example of an webpack-addon
The text was updated successfully, but these errors were encountered: