Skip to content

Commit

Permalink
YAY 3.0!!!
Browse files Browse the repository at this point in the history
Co-authored-by: Aiden Bai <[email protected]>
Co-authored-by: Nisarg Patel <[email protected]>
Co-authored-by: Mohammad Bagher Abiyat <[email protected]>
Co-authored-by: Alexis H. Munsayac <[email protected]>
  • Loading branch information
4 people authored Feb 2, 2024
1 parent 1632110 commit b594ab7
Show file tree
Hide file tree
Showing 127 changed files with 8,822 additions and 21,232 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/*.ts
dist/
node_modules/
packages/kitchen-sink
packages/kitchen-sink
*.old.ts
3 changes: 3 additions & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ module.exports = {
'no-nested-ternary': 'off',
'no-param-reassign': 'off',
'tsdoc/syntax': 'off',
'import/no-extraneous-dependencies': 'off',
'eslint-comments/require-description': 'off',
'import/no-relative-packages': 'off',
},
},
],
Expand Down
1 change: 0 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ The `packages` folder contains all the code related to the Million.js package, b
- `jsx-runtime` - This folder contains the code related to the runtime code for jsx.
- `million` - This folder contains the code for the core Million.js package. The implementation of the optimized array rendering `<For/>`, `block()`, and virtual DOM for React are in here.
- `react` and `react-server` - This folder contains the Million.js support package for React
- `preact` and `preact-server` - This folder contains the Million.js support package for Preact
- `types` - This folder contains all the shared types between packages

To run the project locally, run the following commands:
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ website/pages/docs/compiler.mdx
website/pages/docs/install.mdx
website/pages/docs/quickstart.mdx
website/pages/docs/rules.mdx
website/pages/docs/automatic.mdx
website/pages/docs/automatic.mdx
website/pages/blog/million-3.mdx
26 changes: 14 additions & 12 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { defineBuildConfig } from 'unbuild';
import banner from 'rollup-plugin-banner2';
import replace from '@rollup/plugin-replace';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

const version = JSON.parse(
readFileSync(join(__dirname, 'package.json'), 'utf-8'),
readFileSync(join(__dirname, 'package.json'), 'utf-8')
).version;

export default defineBuildConfig({
Expand All @@ -15,8 +14,6 @@ export default defineBuildConfig({
'./packages/compiler',
'./packages/react',
'./packages/react-server',
'./packages/preact',
'./packages/preact-server',
'./packages/types',
],
declaration: true,
Expand All @@ -25,19 +22,24 @@ export default defineBuildConfig({
rollup: {
emitCJS: true,
inlineDependencies: true,
replace: {
'process.env.VERSION': JSON.stringify(version),
preventAssignment: true,
}
},
hooks: {
'rollup:options'(_ctx, options) {
if (Array.isArray(options?.plugins)) {
options.plugins.push(banner(() => `'use client';\n`));
options.plugins.push(
replace({
'process.env.VERSION': JSON.stringify(version),
preventAssignment: true,
}),
);
options.plugins.push(banner(() => `'use client';\n`) as any);
}
},
},
externals: ['react', 'react-dom', 'preact', 'million', 'vite', 'esbuild'],
externals: [
'react',
'react-dom',
'million',
'vite',
'esbuild',
'rollup',
],
});
23 changes: 23 additions & 0 deletions example.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { transformAsync } from '@babel/core';
import { babel } from 'million/compiler';

async function compile(code) {
const result = await transformAsync(code, {
plugins: [
[babel, { server: true }],
],
parserOpts: {
plugins: [
'jsx',
],
},
});

return result?.code ?? '';
}

console.log(await compile(`
import { block } from 'million/react';
export const Example = block(() => <h1>Hello World</h1>);
`));
173 changes: 75 additions & 98 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,32 @@
"name": "million",
"version": "2.6.4",
"description": "Make React Faster. Automatically.",
"main": "dist/packages/million.mjs",
"module": "dist/packages/million.mjs",
"jsdelivr": "dist/packages/million.mjs",
"unpkg": "dist/packages/million.mjs",
"types": "dist/packages/million.d.ts",
"scripts": {
"build": "unbuild",
"cleanup": "prettier --write ./**/*.{ts,tsx}",
"lint": "eslint ./packages --ext .ts --cache",
"lint:fix": "pnpm lint --fix",
"test": "vitest run --coverage",
"test:dev": "vitest watch",
"bump": "pnpm build && pnpm test && pnpm lint && publint --strict && bumpp"
"keywords": [
"million",
"virtualdom",
"vdom",
"library",
"web",
"ui",
"browser"
],
"homepage": "https://million.dev",
"bugs": {
"url": "https://github.com/aidenybai/million/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aidenybai/million.git"
},
"files": [
"dist/**/*",
"packages/cli/dist/index.js",
"react.d.ts",
"jsx-runtime.d.ts",
"compiler.d.ts",
"react-server.d.ts",
"preact.d.ts",
"preact-server.d.ts",
"types.d.ts"
],
"bin": {
"million": "./packages/cli/dist/index.js"
"funding": "https://github.com/sponsors/aidenybai",
"license": "MIT",
"author": {
"name": "Aiden Bai",
"email": "[email protected]",
"url": "https://aidenybai.com"
},
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": {
Expand Down Expand Up @@ -85,26 +79,6 @@
"default": "./dist/packages/react-server.cjs"
}
},
"./preact": {
"import": {
"types": "./dist/packages/preact.d.mts",
"default": "./dist/packages/preact.mjs"
},
"require": {
"types": "./dist/packages/preact.d.ts",
"default": "./dist/packages/preact.cjs"
}
},
"./preact-server": {
"import": {
"types": "./dist/packages/preact-server.d.mts",
"default": "./dist/packages/preact-server.mjs"
},
"require": {
"types": "./dist/packages/preact-server.d.ts",
"default": "./dist/packages/preact-server.cjs"
}
},
"./types": {
"import": {
"types": "./dist/packages/types.d.mts",
Expand All @@ -114,67 +88,70 @@
"types": "./dist/packages/types.d.ts",
"default": "./dist/packages/types.cjs"
}
}
},
"./*": "./*"
},
"packageManager": "[email protected]",
"sideEffects": false,
"keywords": [
"million",
"virtualdom",
"vdom",
"library",
"web",
"ui",
"browser"
],
"funding": "https://github.com/sponsors/aidenybai",
"author": {
"name": "Aiden Bai",
"email": "[email protected]",
"url": "https://aidenybai.com"
"main": "dist/packages/million.mjs",
"jsdelivr": "dist/packages/million.mjs",
"unpkg": "dist/packages/million.mjs",
"module": "dist/packages/million.mjs",
"types": "dist/packages/million.d.ts",
"bin": {
"million": "./packages/cli/dist/index.js"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/aidenybai/million/issues"
"files": [
"dist/**/*",
"packages/cli/dist/index.js",
"react.d.ts",
"jsx-runtime.d.ts",
"compiler.d.ts",
"react-server.d.ts",
"types.d.ts"
],
"scripts": {
"build": "unbuild",
"bump": "pnpm build && pnpm test && pnpm lint && publint --strict && bumpp",
"cleanup": "prettier --write ./**/*.{ts,tsx}",
"lint": "eslint ./packages --ext .ts --cache",
"lint:fix": "pnpm lint --fix",
"test": "vitest run --coverage",
"test:dev": "vitest watch"
},
"homepage": "https://github.com/aidenybai/million",
"prettier": "@vercel/style-guide/prettier",
"dependencies": {
"@babel/core": "^7.21.0",
"@babel/generator": "^7.22.7",
"@babel/plugin-syntax-jsx": "^7.21.4",
"@babel/plugin-syntax-typescript": "^7.21.4",
"@babel/types": "^7.21.3",
"@babel/core": "^7.23.7",
"@babel/types": "^7.23.6",
"@rollup/pluginutils": "^5.1.0",
"kleur": "^4.1.5",
"rollup": "^3.28.0",
"unplugin": "^1.3.1"
"undici": "^6.3.0",
"unplugin": "^1.6.0"
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.2",
"@types/babel__core": "^7.20.0",
"@types/babel__generator": "^7.6.4",
"@types/babel-types": "^7.0.11",
"@types/node": "^18.14.1",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"@vercel/style-guide": "^3.0.0",
"@vitejs/plugin-react": "^4.0.0",
"@vitest/coverage-v8": "^0.32.0",
"bumpp": "^9.2.0",
"c8": "^7.13.0",
"@types/babel__core": "^7.20.5",
"@types/node": "^18.19.4",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vercel/style-guide": "^5.1.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.1.1",
"babel-plugin-tester": "^11.0.4",
"bumpp": "^9.2.1",
"c8": "^7.14.0",
"esbuild": "^0.14.54",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"jsdom": "^21.1.0",
"prettier": "^2.8.4",
"publint": "^0.1.12",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"jsdom": "^21.1.2",
"prettier": "^3.1.1",
"publint": "^0.1.16",
"rollup": "^4.9.2",
"rollup-plugin-banner2": "^1.2.2",
"source-map": "^0.7.4",
"tslib": "^2.5.0",
"typescript": "^5.1.6",
"unbuild": "2.0.0-rc.0",
"vite": "^4.4.9",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "0.32.0"
}
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"unbuild": "2.0.0",
"vite": "^5.0.12",
"vite-tsconfig-paths": "^4.2.3",
"vitest": "1.0.1"
},
"packageManager": "[email protected]"
}
22 changes: 9 additions & 13 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,32 @@ import { abort } from './utils/utils.js';
import { handleConfigFile } from './utils/config.js';
import { isPackageInstalled } from './utils/package-json.js';

async function runMillionWizard({
telemetry,
}: {
telemetry: boolean;
}): Promise<void> {
async function runMillionWizard(): Promise<void> {
const isMillionAlreadyInstalled = await isPackageInstalled();
await installPackage({
packageName: 'million',
alreadyInstalled: isMillionAlreadyInstalled,
});
await handleConfigFile({ telemetry });
if (!isMillionAlreadyInstalled) {
await handleConfigFile();
}
}

const TELEMETRY_ENABLED = !process.argv.includes('--no-telemetry');

async function main() {
async function main(): Promise<void> {
intro(showWelcomeScreen());
await runMillionWizard({ telemetry: TELEMETRY_ENABLED });
await runMillionWizard();
outro(`${chalk.bold.green('✓ ')} You're all set!`);
}

main().catch(() => {
abort(
'Failed to setup Million.js, refer to the docs for manual setup: https://million.dev/docs/install',
'Failed to setup Million.js, refer to the docs for manual setup: https://million.dev/docs/install'
);
});

function showWelcomeScreen() {
function showWelcomeScreen(): string {
const text = chalk.magentaBright(
`⚡ Million.js ${process.env.VERSION || ''}`,
`⚡ Million.js ${process.env.VERSION || ''}`
);
return text;
}
Loading

0 comments on commit b594ab7

Please sign in to comment.