@bleedingdev/modern-js-create 3.2.0-ultramodern.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +112 -0
- package/bin/run.js +73 -0
- package/dist/index.js +2320 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locale/en.d.ts +55 -0
- package/dist/types/locale/index.d.ts +112 -0
- package/dist/types/locale/zh.d.ts +55 -0
- package/dist/types/ultramodern-workspace.d.ts +20 -0
- package/package.json +56 -0
- package/template/.browserslistrc +4 -0
- package/template/.github/workflows/ultramodern-gates.yml.handlebars +30 -0
- package/template/.gitignore.handlebars +30 -0
- package/template/.nvmrc +2 -0
- package/template/README.md +78 -0
- package/template/api/effect/index.ts.handlebars +61 -0
- package/template/api/lambda/hello.ts.handlebars +6 -0
- package/template/biome.json +41 -0
- package/template/modern.config.ts.handlebars +50 -0
- package/template/package.json.handlebars +47 -0
- package/template/postcss.config.mjs.handlebars +6 -0
- package/template/scripts/validate-ultramodern.mjs.handlebars +102 -0
- package/template/shared/effect/api.ts.handlebars +18 -0
- package/template/src/modern-app-env.d.ts +1 -0
- package/template/src/modern.runtime.ts.handlebars +9 -0
- package/template/src/routes/index.css.handlebars +118 -0
- package/template/src/routes/layout.tsx.handlebars +9 -0
- package/template/src/routes/page.tsx.handlebars +119 -0
- package/template/tailwind.config.ts.handlebars +10 -0
- package/template/tsconfig.json +16 -0
- package/template-workspace/README.md.handlebars +28 -0
- package/template-workspace/pnpm-workspace.yaml +5 -0
- package/template-workspace/scripts/validate-ultramodern-workspace.mjs.handlebars +276 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Modern.js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Modern.js</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
A Progressive React Framework for modern web development.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js.
|
|
14
|
+
|
|
15
|
+
### Router Template
|
|
16
|
+
|
|
17
|
+
You can scaffold a TanStack Router first template:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @modern-js/create my-app --router tanstack
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Tailwind Template
|
|
24
|
+
|
|
25
|
+
You can scaffold Tailwind CSS v4 setup (PostCSS + starter utility classes):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx @modern-js/create my-app --tailwind
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You can combine both options:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx @modern-js/create my-app --router tanstack --tailwind
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### BFF Runtime Template
|
|
38
|
+
|
|
39
|
+
You can scaffold BFF APIs with the current default runtime:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx @modern-js/create my-app --bff
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
You can explicitly scaffold Effect HttpApi runtime for BFF:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx @modern-js/create my-app --bff-runtime effect
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To scaffold Hono runtime explicitly:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx @modern-js/create my-app --bff-runtime hono
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Generated starters expose `presetUltramodern(...)` as the public opinionated
|
|
58
|
+
config wrapper when you want the full Ultramodern setup surface in
|
|
59
|
+
`modern.config.ts`.
|
|
60
|
+
|
|
61
|
+
You can combine TanStack Router + Tailwind + Effect BFF in one command:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx @modern-js/create my-app --router tanstack --tailwind --bff-runtime effect
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Micro Vertical Workspace Recipes
|
|
68
|
+
|
|
69
|
+
Use the existing create flags to scaffold packages inside a Micro Vertical
|
|
70
|
+
workspace. The shell and remotes use TanStack Router; services use Effect by
|
|
71
|
+
default, with Hono kept as an explicit compatibility lane.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx @modern-js/create apps/shell --router tanstack --tailwind --workspace --sub
|
|
75
|
+
npx @modern-js/create apps/remotes/catalog --router tanstack --tailwind --workspace --sub
|
|
76
|
+
npx @modern-js/create apps/remotes/design-system --router tanstack --tailwind --workspace --sub
|
|
77
|
+
npx @modern-js/create services/catalog-api --bff-runtime effect --workspace --sub
|
|
78
|
+
npx @modern-js/create services/legacy-api --bff-runtime hono --workspace --sub
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
When a design system needs independent deployment, treat it as a horizontal
|
|
82
|
+
Module Federation remote with the same topology, trust, SSR, compatibility, and
|
|
83
|
+
fallback expectations as feature remotes. Otherwise shared packages should be
|
|
84
|
+
regular workspace packages for tokens, primitives, generated clients, or
|
|
85
|
+
domain-neutral utilities. Keep feature composites and workflow logic owned by a
|
|
86
|
+
shell, remote, or service package.
|
|
87
|
+
|
|
88
|
+
See
|
|
89
|
+
`docs/super-app-rfc-adr/WORKSPACE-0001-micro-vertical-workspace-scaffolding.md`
|
|
90
|
+
for the canonical workspace topology and local orchestration model.
|
|
91
|
+
|
|
92
|
+
### Local Monorepo Testing
|
|
93
|
+
|
|
94
|
+
When testing unreleased Modern.js packages from a local monorepo checkout, use
|
|
95
|
+
workspace protocol dependencies:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npx @modern-js/create my-app --router tanstack --bff-runtime effect --workspace
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
- [English Documentation](https://modernjs.dev/en/)
|
|
104
|
+
- [中文文档](https://modernjs.dev)
|
|
105
|
+
|
|
106
|
+
## Contributing
|
|
107
|
+
|
|
108
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
|
|
11
|
+
const pkgInfo = require(path.join(__dirname, '../package.json'));
|
|
12
|
+
const srcPath = './src/index.ts';
|
|
13
|
+
const distPath = pkgInfo.main;
|
|
14
|
+
const project = path.join(__dirname, '../tsconfig.json');
|
|
15
|
+
|
|
16
|
+
let env = 'production';
|
|
17
|
+
if (fs.existsSync(project)) {
|
|
18
|
+
env = 'development';
|
|
19
|
+
}
|
|
20
|
+
if (process.env.CODESMITH_ENV) {
|
|
21
|
+
env = process.env.CODESMITH_ENV;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const entry = path.join(
|
|
25
|
+
__dirname,
|
|
26
|
+
`../${env === 'development' ? srcPath : distPath}`,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if (env === 'development') {
|
|
30
|
+
try {
|
|
31
|
+
// 从当前包的 node_modules 中解析 tsx/esm/api
|
|
32
|
+
// 使用 require.resolve 来找到 tsx 包的位置
|
|
33
|
+
const packageRoot = path.join(__dirname, '..');
|
|
34
|
+
let tsxApiPath = 'tsx/esm/api';
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
// 尝试解析 tsx 包的 package.json
|
|
38
|
+
const tsxPackageJson = require.resolve('tsx/package.json', {
|
|
39
|
+
paths: [packageRoot],
|
|
40
|
+
});
|
|
41
|
+
const tsxPackageDir = path.dirname(tsxPackageJson);
|
|
42
|
+
// 根据 tsx 的 exports 配置,esm/api 指向 dist/esm/api/index.mjs
|
|
43
|
+
const tsxApiFile = path.join(
|
|
44
|
+
tsxPackageDir,
|
|
45
|
+
'dist',
|
|
46
|
+
'esm',
|
|
47
|
+
'api',
|
|
48
|
+
'index.mjs',
|
|
49
|
+
);
|
|
50
|
+
if (fs.existsSync(tsxApiFile)) {
|
|
51
|
+
tsxApiPath = pathToFileURL(tsxApiFile).href;
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
// 如果解析失败,使用默认的模块名(Node.js 会从工作区的 node_modules 中查找)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const { register } = await import(tsxApiPath);
|
|
58
|
+
register({
|
|
59
|
+
tsconfig: project,
|
|
60
|
+
});
|
|
61
|
+
await import(pathToFileURL(entry).href);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Error: Cannot load TypeScript file in development mode.');
|
|
64
|
+
console.error('Please install tsx: pnpm add -D tsx');
|
|
65
|
+
console.error('Or build the project: pnpm build');
|
|
66
|
+
console.error(error);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
import(pathToFileURL(entry).href).catch(e => {
|
|
71
|
+
console.error(e);
|
|
72
|
+
});
|
|
73
|
+
}
|