Skip to content

Commit

Permalink
chore: upgrade to monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 18, 2021
1 parent 8d6b97a commit a16e13b
Show file tree
Hide file tree
Showing 44 changed files with 12,028 additions and 98 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
_templates
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"globals": {
"NodeJS": true
},
"extends": [
"@nuxtjs/eslint-config-typescript"
],
"rules": {
"no-console": "off",
"vue/one-component-per-file": "off"
}
}
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: ci

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [14]

steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: checkout
uses: actions/checkout@master

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile --non-interactive

- name: Lint
run: yarn lint

- name: Build
run: yarn build

# - name: Test
# run: yarn jest

# - name: Coverage
# uses: codecov/codecov-action@v1
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Dependencies
node_modules
jspm_packages

# Only keep yarn.lock in the root
package-lock.json
*/**/yarn.lock

# Logs
*.log

# Temp directories
.temp
.tmp
.cache

# Generated dirs
dist
.nuxt*
.output

# Junit reports
reports

# Coverage reports
coverage
*.lcov
.nyc_output

# VSCode
.vscode

# Intellij idea
*.iml
.idea

# OSX
.DS_Store
.AppleDouble
.LSOverride

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
CHANGELOG.md
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Nuxt Monorepo

## Development

- Clone repository
- Install dependencies with `yarn install`
- Open playground with `yarn play`
24 changes: 24 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"conventionalCommits": true,
"packages": [
"packages/*"
],
"command": {
"publish": {
"npmClient": "npm"
}
},
"changelog": {
"labels": {
"feat": "New Feature",
"fix": "Bug Fix",
"docs": "Documentation",
"types": "Types",
"perf": "Performance",
"refactor": "Refactor"
}
}
}
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "nuxt-framework",
"private": "true",
"license": "MIT",
"workspaces": [
"packages/*"
],
"scripts": {
"link": "lerna link",
"nuxt": "jiti ./scripts/nuxt",
"build": "yarn workspaces run build",
"stub": "yarn workspaces run stub",
"play": "yarn nuxt dev playground",
"lint": "eslint --ext .vue,.ts,.js .",
"test": "yarn lint",
"postinstall": "yarn stub"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^6.0.0",
"@nuxtjs/eslint-config-typescript": "^6.0.0",
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.35",
"chalk": "^4.1.0",
"defu": "^3.2.2",
"esbuild": "^0.9.3",
"eslint": "^7.22.0",
"jest": "^26.6.3",
"jiti": "^1.6.4",
"lerna": "^4.0.0",
"mkdist": "^0.1.2",
"pretty-bytes": "^5.6.0",
"rimraf": "^3.0.2",
"rollup": "^2.41.5",
"rollup-plugin-dts": "^3.0.1",
"rollup-plugin-esbuild": "^3.0.2",
"standard-version": "^9.1.1",
"ts-jest": "^26.5.3",
"typescript": "^4.2.3"
}
}
84 changes: 84 additions & 0 deletions packages/nitro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"name": "@nuxt/nitro",
"version": "0.1.11",
"license": "MIT",
"main": "dist/index.js",
"files": [
"dist",
"compat.js"
],
"scripts": {
"build": "jiti ../../scripts/build .",
"stub": "yarn build --stub",
"prepublishOnly": "yarn build"
},
"build": {
"entries": {
"index": {},
"compat": { "format": "cjs" },
"runtime/": {}
},
"dependencies": [
"@cloudflare/kv-asset-handler",
"@nuxt/devalue",
"connect",
"destr",
"ohmyfetch",
"ora",
"vue-bundle-renderer",
"vue-server-renderer",
"@vue/server-renderer"
]
},
"dependencies": {
"@cloudflare/kv-asset-handler": "^0.1.0",
"@nuxt/devalue": "^1.2.5",
"@nuxt/un": "^0.1.1",
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-replace": "^2.4.1",
"@rollup/plugin-virtual": "^2.0.3",
"@rollup/pluginutils": "^4.1.0",
"@vercel/nft": "^0.9.5",
"@vue/server-renderer": "^3.0.7",
"archiver": "^5.2.0",
"chalk": "^4.1.0",
"chokidar": "^3.5.1",
"connect": "^3.7.0",
"consola": "^2.15.3",
"debounce": "^1.2.0",
"defu": "^3.2.2",
"destr": "^1.1.0",
"dot-prop": "^6.0.1",
"esbuild": "^0.9.3",
"etag": "^1.8.1",
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"gzip-size": "^6.0.0",
"h3": "^0.2.5",
"hasha": "^5.2.2",
"hookable": "^4.4.1",
"http-proxy": "^1.18.1",
"is-primitive": "^3.0.1",
"jiti": "^1.6.0",
"listhen": "^0.1.4",
"mime": "^2.5.2",
"node-fetch": "^2.6.1",
"ohmyfetch": "^0.1.8",
"ora": "^5.3.0",
"pretty-bytes": "^5.6.0",
"rollup": "^2.40.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"serve-placeholder": "^1.2.3",
"serve-static": "^1.14.1",
"std-env": "^2.3.0",
"table": "^6.0.7",
"upath": "^2.0.1",
"vue-bundle-renderer": "^0.2.3",
"vue-server-renderer": "^2.6.12"
}
}
38 changes: 5 additions & 33 deletions packages/nitro/src/rollup/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { extname, relative } from 'path'
import { Plugin, PluginContext } from 'rollup'
import { startService, Loader, Service, TransformResult } from 'esbuild'
import { Loader, TransformResult, transform } from 'esbuild'
import { createFilter, FilterPattern } from '@rollup/pluginutils'

const defaultLoaders: { [ext: string]: Loader } = {
Expand Down Expand Up @@ -64,24 +64,9 @@ export function esbuild (options: Options = {}): Plugin {
options.exclude || EXCLUDE_REGEXP
)

let service: Service | undefined

const stopService = () => {
if (service) {
service.stop()
service = undefined
}
}

return {
name: 'esbuild',

async buildStart () {
if (!service) {
service = await startService()
}
},

async transform (code, id) {
if (!filter(id)) {
return null
Expand All @@ -90,13 +75,13 @@ export function esbuild (options: Options = {}): Plugin {
const ext = extname(id)
const loader = loaders[ext]

if (!loader || !service) {
if (!loader) {
return null
}

target = options.target || 'node12'

const result = await service.transform(code, {
const result = await transform(code, {
loader,
target,
define: options.define,
Expand All @@ -114,16 +99,9 @@ export function esbuild (options: Options = {}): Plugin {
)
},

buildEnd (error) {
// Stop the service early if there's error
if (error && !this.meta.watchMode) {
stopService()
}
},

async renderChunk (code) {
if (options.minify && service) {
const result = await service.transform(code, {
if (options.minify) {
const result = await transform(code, {
loader: 'js',
minify: true,
target
Expand All @@ -136,12 +114,6 @@ export function esbuild (options: Options = {}): Plugin {
}
}
return null
},

generateBundle () {
if (!this.meta.watchMode) {
stopService()
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nitro/src/runtime/app/nitro.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { $fetch } from 'ohmyfetch'

_global.process = _global.process || {};

// eslint-disable-next-line
(function () { const o = Date.now(); const t = () => Date.now() - o; _global.process.hrtime = _global.process.hrtime || ((o) => { const e = Math.floor(0.001 * (Date.now() - t())); const a = 0.001 * t(); let l = Math.floor(a) + e; let n = Math.floor(a % 1 * 1e9); return o && (l -= o[0], n -= o[1], n < 0 && (l--, n += 1e9)), [l, n] }) })()

global.$fetch = $fetch
Loading

0 comments on commit a16e13b

Please sign in to comment.