Skip to content

Commit 78f6a64

Browse files
authored
Fix: Nx config (#1454)
1 parent 544af5b commit 78f6a64

File tree

88 files changed

+698
-282034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+698
-282034
lines changed

.changeset/config.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
"changelog": "@changesets/cli/changelog",
44
"commit": false,
55
"fixed": [],
6-
"linked": [
7-
[
8-
"@builder.io/mitosis",
9-
"@builder.io/mitosis-cli"
10-
]
11-
],
6+
"linked": [["@builder.io/mitosis", "@builder.io/mitosis-cli"]],
127
"access": "public",
138
"baseBranch": "main",
149
"updateInternalDependencies": "patch",
@@ -17,7 +12,6 @@
1712
"@builder.io/e2e-*",
1813
"@builder.io/*example*",
1914
"@e2e-app/*",
20-
"@builder.io/talk*",
2115
"@builder.io/e2e*"
2216
]
2317
}

.changeset/ten-chairs-approve.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@builder.io/mitosis': patch
3+
'@builder.io/mitosis-cli': patch
4+
---
5+
6+
Misc: remove unused dependencies.
+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
########################################################################################
2+
# "yarn install" composite action for yarn 3/4+ and "nodeLinker: node-modules" #
3+
#--------------------------------------------------------------------------------------#
4+
# Requirement: @setup/node should be run before #
5+
# #
6+
# Usage in workflows steps: #
7+
# #
8+
# - name: 📥 Monorepo install #
9+
# uses: ./.github/actions/yarn-nm-install #
10+
# with: #
11+
# enable-corepack: false # (default = 'false') #
12+
# cwd: ${{ github.workspace }}/apps/my-app # (default = '.') #
13+
# cache-prefix: add cache key prefix # (default = 'default') #
14+
# cache-node-modules: false # (default = 'false') #
15+
# cache-install-state: false # (default = 'false') #
16+
# #
17+
# Reference: #
18+
# - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a #
19+
# #
20+
# Versions: #
21+
# - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. #
22+
# - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. #
23+
# - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) #
24+
# - 1.0.2 - 02-06-2023 - install-state default to false #
25+
# - 1.0.1 - 29-05-2023 - cache-prefix doc #
26+
# - 1.0.0 - 27-05-2023 - new input: cache-prefix #
27+
########################################################################################
28+
29+
name: 'Monorepo install (yarn)'
30+
description: 'Run yarn install with node_modules linker and cache enabled'
31+
inputs:
32+
cwd:
33+
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
34+
required: false
35+
default: '.'
36+
cache-prefix:
37+
description: 'Add a specific cache-prefix'
38+
required: false
39+
default: 'default'
40+
cache-npm-cache:
41+
description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)'
42+
required: false
43+
default: 'true'
44+
cache-node-modules:
45+
description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)'
46+
required: false
47+
default: 'false'
48+
cache-install-state:
49+
description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)'
50+
required: false
51+
default: 'false'
52+
enable-corepack:
53+
description: 'Enable corepack'
54+
required: false
55+
default: 'true'
56+
57+
runs:
58+
using: 'composite'
59+
60+
steps:
61+
- name: ⚙️ Enable Corepack
62+
if: inputs.enable-corepack == 'true'
63+
shell: bash
64+
working-directory: ${{ inputs.cwd }}
65+
run: corepack enable
66+
67+
- name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT"
68+
id: yarn-config
69+
shell: bash
70+
working-directory: ${{ inputs.cwd }}
71+
env:
72+
YARN_ENABLE_GLOBAL_CACHE: 'false'
73+
run: |
74+
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
75+
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT
76+
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT
77+
echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT
78+
79+
- name: ♻️ Restore yarn cache
80+
uses: actions/cache@v3
81+
id: yarn-download-cache
82+
with:
83+
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
84+
key: yarn-download-cache-${{ inputs.cache-prefix }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
85+
restore-keys: |
86+
yarn-download-cache-${{ inputs.cache-prefix }}-
87+
88+
- name: ♻️ Restore node_modules
89+
if: inputs.cache-node-modules == 'true'
90+
id: yarn-nm-cache
91+
uses: actions/cache@v3
92+
with:
93+
path: ${{ inputs.cwd }}/**/node_modules
94+
key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
95+
96+
- name: ♻️ Restore global npm cache folder
97+
if: inputs.cache-npm-cache == 'true'
98+
id: npm-global-cache
99+
uses: actions/cache@v3
100+
with:
101+
path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}
102+
key: npm-global-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
103+
104+
- name: ♻️ Restore yarn install state
105+
if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true'
106+
id: yarn-install-state-cache
107+
uses: actions/cache@v3
108+
with:
109+
path: ${{ inputs.cwd }}/.yarn/ci-cache
110+
key: yarn-install-state-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
111+
112+
- name: 📥 Install dependencies
113+
shell: bash
114+
working-directory: ${{ inputs.cwd }}
115+
run: yarn install --immutable --inline-builds
116+
env:
117+
# Overrides/align yarnrc.yml options (v3, v4) for a CI context
118+
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives
119+
YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only)
120+
YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size
121+
YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present
122+
# Other environment variables
123+
HUSKY: '0' # By default do not run HUSKY install

.github/pull_request_template.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
## Description
22

3-
Add a short description of:
4-
- what changes you made,
5-
- why you made them, and
6-
- any other context that you think might be helpful for someone to better understand what is contained in this pull request.
3+
Please provide the following information:
74

8-
This sort of information is useful for people reviewing the code, as well as anyone from the future trying to understand why changes were made or why a bug started happening.
5+
- What changes you made:
96

7+
- Why you made them, and:
8+
9+
- Any other useful context:
10+
11+
Make sure to follow the PR preparation steps in [CONTRIBUTING.md](../CONTRIBUTING.md#preparing-your-pr) before submitting your PR:
12+
13+
- [ ] Format the codebase
14+
- [ ] Update all snapshots

.github/workflows/checks.yml

+17-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
push:
1010
pull_request:
1111

12-
env:
12+
env:
1313
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
1414

1515
jobs:
@@ -23,10 +23,12 @@ jobs:
2323
uses: actions/setup-node@v3
2424
with:
2525
node-version: 20
26-
cache: 'yarn'
2726

28-
- name: Install dependencies
29-
run: yarn --immutable
27+
- name: 📥 Monorepo install
28+
uses: ./.github/actions/yarn-nm-install
29+
with:
30+
cache-node-modules: true
31+
cache-install-state: true
3032

3133
- name: Lint
3234
run: yarn ci:lint
@@ -47,19 +49,15 @@ jobs:
4749
uses: actions/setup-node@v3
4850
with:
4951
node-version: 20
50-
cache: 'yarn'
51-
52-
- name: Install dependencies
53-
run: yarn --immutable
5452

55-
- name: Build Core
56-
run: yarn ci:build:core
57-
58-
- name: Build eslint-plugin
59-
run: yarn ci:build:eslint-plugin
53+
- name: 📥 Monorepo install
54+
uses: ./.github/actions/yarn-nm-install
55+
with:
56+
cache-node-modules: true
57+
cache-install-state: true
6058

6159
- name: Build Site
62-
run: yarn ci:build:site
60+
run: yarn nx build @builder.io/mitosis-site
6361

6462
e2e:
6563
runs-on: ubuntu-latest
@@ -71,10 +69,12 @@ jobs:
7169
uses: actions/setup-node@v3
7270
with:
7371
node-version: 20
74-
cache: 'yarn'
7572

76-
- name: Install dependencies
77-
run: yarn --immutable
73+
- name: 📥 Monorepo install
74+
uses: ./.github/actions/yarn-nm-install
75+
with:
76+
cache-node-modules: true
77+
cache-install-state: true
7878

7979
- name: Build
8080
run: yarn ci:build

.github/workflows/publish.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,21 @@ jobs:
2525
- name: Use Node.js
2626
uses: actions/setup-node@v3
2727
with:
28-
node-version: 20
29-
registry-url: "https://registry.npmjs.org"
30-
cache: 'yarn'
28+
node-version: '18.x'
3129

32-
- name: Install dependencies
33-
run: yarn --immutable
30+
- name: 📥 Monorepo install
31+
uses: ./.github/actions/yarn-nm-install
32+
with:
33+
cache-node-modules: true
34+
cache-install-state: true
3435

3536
- name: Create Release PR & Publish to npm
3637
id: changesets
3738
uses: changesets/action@v1
3839
with:
3940
publish: yarn ci:release
40-
title: "📦 Publish Mitosis"
41-
commit: "📦 Publish Mitosis"
41+
title: '📦 Publish Mitosis'
42+
commit: '📦 Publish Mitosis'
4243
env:
4344
# need this custom token to run CI checks on the created PR
4445
GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ packages/core/mitosis-build
2828
**/playwright-report/
2929

3030
packages/core/src/__tests__/__snapshots__/local.test.ts.snap
31+
32+
.nx/cache
33+
.nx-cache

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20
1+
20.11.0

.tool-versions

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 18.17.1
1+
nodejs 20.11.0

developer/README.md CONTRIBUTING.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Local Development
22

3-
Welcome ⚡️!! If you've found a bug, or have an idea to add a feature we'd love to hear from you. It may save time to first ping the group on [Mitosis' Discord channel](https://discord.com/channels/842438759945601056/935218469799071835) to talk through any ideas or any issues that may be a bug.
3+
Welcome ⚡️!! If you've found a bug, or have an idea to add a feature we'd love to hear from you. It may save time to first ping the group on [Mitosis' Discord channel](https://discord.gg/yxjk5vn6pn) to talk through any ideas or any issues that may be a bug.
44

55
## Project Structure
66

7-
Mitosis is structured as a mono-repo using Yarn (v3) Workspaces. The packages
7+
Mitosis is structured as a mono-repo using Yarn (v3) Workspaces and Nx. The packages
88
live under `packages/` and `examples/`:
99

1010
- `core` (`@builder.io/mitosis`): contains the Mitosis engine
@@ -38,7 +38,7 @@ In `core`, we use vitest snapshots & integeration tests for test coverage. If yo
3838

3939
- copy your fiddle component into a file in `packages/core/src/__tests__/data`. See [packages/core/src/**tests**/data/basic.raw.tsx](/packages/core/src/__tests__/data/basic.raw.tsx) as an example.
4040
- add that test to the [test generator](/packages/core/src/__tests__/test-generator.ts), most likely in `BASIC_TESTS`.
41-
- run `yarn test:watch` in the `packages/core` directory to run the snapshot tests in watch mode
41+
- run `yarn nx test:watch` in the `packages/core` directory to run the snapshot tests in watch mode
4242

4343
PS: don't worry about failing imports in the raw test TSX files. These are not an issue, since the files are standalone and don't actually belong to a cohesive project.
4444

@@ -58,6 +58,9 @@ PS: don't worry about failing imports in the raw test TSX files. These are not a
5858

5959
From there, you can keep iterating until the snapshots look as expected, and the integration tests pass!
6060

61-
### Pre-submit
61+
### Preparing your PR
6262

63-
- format: `yarn run fmt:prettier`
63+
Before submitting your PR, please make sure to format the codebase and update all snapshots:
64+
65+
- format the codebase: from the root, run `yarn fmt:prettier`.
66+
- update all snapshots (in core & CLI): from the root, run `yarn test:update`. This will run an Nx command that will update all the snapshots in the `core` and `cli` packages. while making sure all required dependencies are built beforehand.

README.MD

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Using Mitosis, you can:
3131
- Sync your [design systems from Figma to code](https://mitosis.builder.io/docs/figma/) and publish them to npm across frameworks
3232
- Avoid the [pitfalls of web components](https://mitosis.builder.io/docs/overview/) by compiling to native framework code
3333

34-
_PS: We are actively looking for folks interested in becoming contributors to Mitosis. If interested, look at our list of [good first issues](https://github.com/BuilderIO/mitosis/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) or reach out on our [Discord](https://discord.gg/SNusEyNGsx)_
34+
_PS: We are actively looking for folks interested in becoming contributors to Mitosis. If interested, look at our list of [good first issues](https://github.com/BuilderIO/mitosis/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) or reach out on our [Discord](https://discord.gg/yxjk5vn6pn)_
3535

3636
![Gif example of devloping with Mitosis](https://cdn.builder.io/api/v1/file/assets%2FYJIGb4i01jvw0SRdL5Bt%2F868af1e6d9fd4923b18ecd1d892f3a6e)
3737

@@ -60,11 +60,11 @@ Learn more about our [Figma integration](https://mitosis.builder.io/docs/figma).
6060
- [Documentation](https://mitosis.builder.io/docs)
6161
- [Playground](https://mitosis.builder.io/playground)
6262
- [Figma integration](https://mitosis.builder.io/docs/figma/)
63-
- [Mitosis Discord](https://discord.gg/SNusEyNGsx)
63+
- [Mitosis Discord](https://discord.gg/yxjk5vn6pn)
6464

6565
## Contribute
6666

67-
Interested in contribute? Head over to the [developer](developer/) docs and see how you can get setup & started!
67+
Interested in contribute? Head over to the [CONTRIBUTING](CONTRIBUTING.md) docs and see how you can get setup & started!
6868

6969
Once you're ready, checkout our [issues](https://github.com/BuilderIO/mitosis/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) page and grab your first issue!
7070

e2e/e2e-alpine/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Alpine.js app</title>
88
</head>
9+
910
<body>
10-
<div id="app">{{> my-component }}</div>
11+
<div id="app">{{> homepage }}</div>
1112
<script type="module" src="/src/main.ts"></script>
1213
</body>
1314
</html>

e2e/e2e-alpine/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
},
1414
"devDependencies": {
1515
"alpinejs": "^3.10.5",
16+
"nx": "^19.0.8",
17+
"nx-cloud": "^19.0.0",
1618
"rimraf": "^3.0.2",
1719
"vite": "^3.2.2",
1820
"vite-plugin-handlebars": "^1.6.0"
19-
},
20-
"packageManager": "[email protected]"
21+
}
2122
}

e2e/e2e-alpine/src/main.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { E2eApp } from '@builder.io/e2e-app/alpine';
12
import Alpine from 'alpinejs';
2-
// import myComponent from '@builder.io/e2e-app/alpine/components/my-component.html?raw'
33

44
window.Alpine = Alpine;
55

6-
// Alpine.data('myComponent', myComponent)
6+
console.log('hello', E2eApp);
77

8-
// console.log(myComponent)
9-
// document.getElementById('app').innerHTML = myComponent;
8+
Alpine.data('e2e-app', E2eApp);
9+
10+
document.getElementById('app')!.innerHTML = E2eApp;
1011

1112
Alpine.start();

e2e/e2e-alpine/vite.config.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@ import { resolve } from 'path';
22
import { defineConfig } from 'vite';
33
import handlebars from 'vite-plugin-handlebars';
44

5-
const dir = resolve(
6-
__dirname,
7-
'node_modules',
8-
'@builder.io',
9-
'e2e-app',
10-
'output',
11-
'alpine',
12-
'alpine',
13-
'src',
14-
'components',
15-
);
5+
const dir = resolve(__dirname, 'node_modules', '@builder.io', 'e2e-app', 'output', 'alpine', 'src');
166

177
// https://vitejs.dev/config/
188
export default defineConfig({

0 commit comments

Comments
 (0)