-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Feat: init create webpack app #4167
base: master
Are you sure you want to change the base?
Conversation
- init create-webpack-app package - installed deps - plop - minimist
added template files which containe handlebar templates and other common files
init .tsconfig
change the internal structure of template files
add build script add watch script
type: module is set in package.json
} from "node-plop"; | ||
|
||
export type InitOptions = { template: string; force?: boolean }; | ||
export type LoaderOptions = { template: string }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RE: slack conv, you should make this generic. You see the pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I will work on this soon,
I will definitely use the already established types and interfaces in @generators
package as inspiration and tweak them.
This project has been created using **webpack-cli**, you can now run | ||
|
||
```bash | ||
npm run build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what I am supposed to do here I would love if you can be a bit more specific,
all I can infer is you want me to change the run -> --run
npm run build | |
npm --run build |
like this?
also I have read the section in the link provided
add ejs for rendering logic using ejs templates in future
for compatibility with plopfile, as it throws error if it's a commonjs file
- change templates to ejs templates - implement ejs rendering logic in plopfile.ts
- remove helper function - remove unnecessary comment
@evenstensberg @snitin315 , |
```js | ||
const createWebpackApp = require("create-webpack-app"); | ||
|
||
// TODO: DEMONSTRATE API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to promote the API usage? IMO, CWA interaction should be limited to CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same thing, will surely work on a better readme.
import { fileURLToPath } from "node:url"; | ||
import minimist from "minimist"; | ||
import { Plop, run } from "plop"; | ||
/* cSpell:disable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this disable cspell for the whole file or just the next line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
section of code but I have found a better alternative
/* cSpell:disable */ | |
/* cSpell:words plopfile */ |
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/webpack/create-webpack-app.git" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is under the webpacki-cli repo
"watch": "tsc --watch" | ||
}, | ||
"engines": { | ||
"node": ">=14.15.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's support the minimum version as v18, we also have plans to drop support for v14 in other packages too.
"node": ">=14.15.0" | |
"node": ">=18.12.0" |
"peerDependencies": {}, | ||
"peerDependenciesMeta": {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"peerDependencies": {}, | |
"peerDependenciesMeta": {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed this in latest commit
import { NodePlopAPI } from "./types"; | ||
import { resolve } from "path"; | ||
import ejs from "ejs"; | ||
/* eslint-disable no-unused-vars */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not disable the rule for the whole file, prefer to use //eslint-disable-next-line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed this in latest commits
message: "Enter your project name:", | ||
default: "webpack-project", | ||
validate(input, _) { | ||
if (!input) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more strict check, in case the user just passes space.
if (!input) { | |
if (!input.trim()) { |
}, | ||
{ | ||
type: "input", | ||
name: "configPath", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: "configPath", | |
name: "projectPath", |
type: "input", | ||
name: "entryPoint", | ||
message: "Enter the entry point of your application:", | ||
default: "src/index.js", | ||
validate(input, _) { | ||
if (!input) { | ||
return "Entry point cannot be empty"; | ||
} | ||
return true; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are the ones generating templates we should have control over the entry point. We should not ask this question for scaffolding, users can refactor templates if they wish to post scaffolding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense.
- better input validation - remove entrypoint prompt - fix path issues
- add both index.js and index.ts - fix bud in package.json template file
- fix the url - bumped the required node from 14 -> 18 - removed empty peerDeps and peerMetaDeps fields - fix cli entry point typo
@snitin315 I have made all the changes you asked! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4167 +/- ##
==========================================
- Coverage 90.18% 89.90% -0.29%
==========================================
Files 22 22
Lines 1702 1714 +12
Branches 491 493 +2
==========================================
+ Hits 1535 1541 +6
- Misses 167 173 +6 see 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
- installs all the packages from deps array to the project directory
- single prompt to ask whether to skip - if yes then returns default answers object - if no then returns the interactive prompts interface
What kind of change does this PR introduce?
Did you add tests for your changes?
If relevant, did you update the documentation?
Summary
Does this PR introduce a breaking change?
Other information