Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hip-carrots-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"modular-scripts": minor
---

Improve the way modular add creates new workspaces, add the custom `--path` option, factor out addPackage tests
2 changes: 1 addition & 1 deletion .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
- name: 'Build internal prerequisites'
run: yarn workspace @modular-scripts/workspace-resolver build
- name: Run Windows tests
run: yarn test esmView.test.ts workspace-resolver
run: yarn test esmView.test.ts workspace-resolver addPackage.test.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ packages/sample-view
packages/sample-esm-view
packages/sample-package
packages/nested
packages/custom
packages/sample-library-package
packages/sample-renamable-library-package
packages/sample-renamed-library-package
Expand Down
27 changes: 19 additions & 8 deletions docs/commands/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ parent: Commands
title: modular add
---

# `modular add <packagePath>`
# `modular add <packageName>`

Adds a new package by creating a new workspace at `packages/<packagePath>`
Adds a new package by creating a new workspace at `packages/<packageName>`,
Copy link
Contributor

Choose a reason for hiding this comment

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

How about we have the 5 examples from the discussion thread right in the docs? I think it makes it really fast to understand how to use the option (even though your written docs are also good!)

omitting the scope if the package is
[scoped](https://docs.npmjs.com/cli/v8/using-npm/scope). If `--path <somePath>`
is specified, create the workspace at `<somePath>/<packageName>`.

(i.e. `modular add my-app` would create a package in `packages/my-app` and
`modular add libs/lib-a` would create a package in `packages/libs/lib-a`)
(i.e. `modular add my-app` would create a package in `packages/my-app`,
`modular add @scoped/my-scoped-app` would create a package in
`packages/my-scoped-app` and `modular add lib-a --path libs` would create a
package in `libs/lib-a`)

Packages can currently be one of the following types:

- A standalone `app`. This corresponds to a single `create-react-app` project in
a workspace. Inside this workspace, you can import packages from other
workspaces freely, and features like jsx and typechecking work out of the box.
- A standalone `app`. This corresponds to a static Single Page Application (SPA)
project in a workspace. Inside this workspace, you can import packages from
other workspaces freely, and features like jsx and typechecking work out of
the box.

- An `esm-view`, which is a package that typically exports a React component by
default. ESM Views are built as ES modules that can be `import`ed at runtime
Expand All @@ -25,12 +31,17 @@ Packages can currently be one of the following types:
- A `view`, which is a package that exports a React component by default. Read
more about Views in [this explainer](../concepts/views.md).

- A typical JavaScript `package`. You can use this to create any other kind of
- A generic JavaScript `package`. You can use this to create any other kind of
utility, tool, or whatever your needs require you to do. As an example, you
could build a node.js server inside one of these.

## Options:

`--path`: Optionally set the directory in which the workspace is created. If the
provided path is outside (i.e., not a descendant) of the paths specified in
[the `workspaces` field](https://classic.yarnpkg.com/lang/en/docs/workspaces/#toc-how-to-use-it)
of the root `package.json`, the command will fail

`--prefer-offline`: Uses offline yarn cache when possible

`--verbose`: Run yarn commands with --verbose set and sets
Expand Down
7 changes: 5 additions & 2 deletions packages/modular-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"micromatch": "4.0.5",
"mime": "^3.0.0",
"mini-css-extract-plugin": "2.6.1",
"minimatch": "^5.1.0",
"npm-packlist": "5.1.1",
"open": "8.3.0",
"parse5": "6.0.1",
Expand Down Expand Up @@ -117,9 +118,10 @@
"ts-morph": "^14.0.0",
"update-notifier": "5.1.0",
"url-loader": "4.1.1",
"validate-npm-package-name": "^4.0.0",
"webpack": "5.73.0",
"webpack-dev-server": "4.9.3",
"webpack-manifest-plugin": "5.0.0",
"webpack": "5.73.0",
"ws": "8.8.1"
},
"peerDependencies": {
Expand All @@ -142,8 +144,9 @@
"@schemastore/package": "0.0.6",
"@schemastore/tsconfig": "0.0.9",
"@types/js-yaml": "^4.0.5",
"react-dom": "17.0.2",
"@types/validate-npm-package-name": "^4.0.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"typescript": "4.7.4"
}
}
Loading