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

Feat: init create webpack app #4167

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

maverox
Copy link
Collaborator

@maverox maverox commented May 16, 2024

What kind of change does this PR introduce?

  • inits the create-webpack-app

Did you add tests for your changes?

If relevant, did you update the documentation?

Summary

Does this PR introduce a breaking change?

Other information

@maverox maverox requested a review from a team as a code owner May 16, 2024 15:45
Copy link

linux-foundation-easycla bot commented May 16, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

} from "node-plop";

export type InitOptions = { template: string; force?: boolean };
export type LoaderOptions = { template: string };
Copy link
Member

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

Copy link
Collaborator Author

@maverox maverox May 18, 2024

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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

Suggested change
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
@maverox
Copy link
Collaborator Author

maverox commented May 18, 2024

@evenstensberg @snitin315 ,
I have resolved the problem with rendering
pushed the changes in the latest commits please have a look.

```js
const createWebpackApp = require("create-webpack-app");

// TODO: DEMONSTRATE API
Copy link
Member

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.

Copy link
Collaborator Author

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 */
Copy link
Member

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?

Copy link
Collaborator Author

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

Suggested change
/* cSpell:disable */
/* cSpell:words plopfile */

"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/webpack/create-webpack-app.git"
Copy link
Member

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"
Copy link
Member

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.

Suggested change
"node": ">=14.15.0"
"node": ">=18.12.0"

Comment on lines 51 to 52
"peerDependencies": {},
"peerDependenciesMeta": {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"peerDependencies": {},
"peerDependenciesMeta": {}

Copy link
Collaborator Author

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 */
Copy link
Member

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

Copy link
Collaborator Author

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) {
Copy link
Member

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.

Suggested change
if (!input) {
if (!input.trim()) {

},
{
type: "input",
name: "configPath",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: "configPath",
name: "projectPath",

Comment on lines 34 to 43
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;
},
Copy link
Member

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.

Copy link
Collaborator Author

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
@maverox
Copy link
Collaborator Author

maverox commented May 19, 2024

@snitin315 I have made all the changes you asked!
PTAL

Copy link

codecov bot commented May 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.90%. Comparing base (31f634a) to head (1bdf924).
Report is 44 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd1099a...1bdf924. Read the comment docs.

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants