Skip to content

Commit

Permalink
Vite 3 (#21)
Browse files Browse the repository at this point in the history
* feat: improve vite 3 support

* chore: update dev tooling

* test: add test for projects with node_modules

(cherry picked from commit a4594e7)

* fix: simplify vite tag implementation and fix tests

Co-authored-by: Michael Rawlings <[email protected]>
  • Loading branch information
DylanPiercey and mlrawlings authored Jul 12, 2022
1 parent d5b5cb2 commit 31688b4
Show file tree
Hide file tree
Showing 57 changed files with 9,110 additions and 14,086 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
16 changes: 16 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "marko-js/vite"
}
],
"updateInternalDependencies": "patch",
"baseBranch": "main",
"access": "public",
"commit": false,
"linked": [],
"ignore": [],
"fixed": []
}
5 changes: 5 additions & 0 deletions .changeset/eighty-trees-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Improve support for Vite 3.
5 changes: 5 additions & 0 deletions .changeset/small-wolves-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix issue with unlinked builds trying to render assets.
3 changes: 0 additions & 3 deletions .commitlintrc.json

This file was deleted.

71 changes: 56 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,85 @@ name: CI

on:
pull_request:
paths-ignore: ["**.md"]
types: [opened, synchronize]
push:
branches: ["main"]
paths-ignore: ["**.md"]
branches: [main]

concurrency:
group: "${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
lint:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Use node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: "npm"
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint code
run: npm run lint
- name: Format Code
run: npm run format
- name: Build Code
run: npm run build
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[ci] format"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ${{ matrix.os }}
name: "test: node@${{ matrix.node }} (${{ matrix.os }})"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [14.x, 16.x]
os: [ubuntu-latest, windows-latest]
node: [14, 16, 18]
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Use node@${{ matrix.node }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: "npm"
cache: npm
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run ci:test
- name: Report code coverage
uses: codecov/codecov-action@v2
release:
runs-on: ubuntu-latest
needs: [format, test]
if: "${{ github.repository_owner == 'marko-js' && github.event_name == 'push' }}"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Release
id: changesets
uses: changesets/action@v1
with:
version: npm run version
publish: npm run release
commit: "[ci] release"
title: "[ci] release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
27 changes: 0 additions & 27 deletions .github/workflows/release.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
*.DS_Store

# NPM
node_modules
**/node_modules/*
!**/node_modules/test-package
npm-debug.log

# Build
dist
*.actual.*
*actual*
*.tsbuildinfo

# Coverage
Expand Down
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged
npm exec lint-staged
3 changes: 1 addition & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"exit": true,
"timeout": 20000,
"extension": ["js", "ts", ".marko"],
"enable-source-maps": true,
"watchFiles": ["src/**/*.ts", "src/**/*.marko"],
"require": ["esbuild-register", "mocha-snap"]
"require": ["tsx", "mocha-snap"]
}
3 changes: 0 additions & 3 deletions .releaserc.json

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 eBay Inc. and contributors
Copyright (c) 2022 eBay Inc. and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
57 changes: 57 additions & 0 deletions build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import fs from "fs";
import path from "path";
import glob from "fast-glob";
import { build, BuildOptions } from "esbuild";

const entryPoints = [];
const srcdir = path.resolve("src");
const outdir = path.resolve("dist");
const files = glob.stream(["**", "!*.d.ts", "!**/__tests__"], {
cwd: srcdir,
}) as AsyncIterable<string>;

for await (const file of files) {
if (path.extname(file) === ".ts") {
entryPoints.push(path.resolve(srcdir, file));
} else {
const outfile = path.join(outdir, file);
await fs.promises.mkdir(path.dirname(outfile), { recursive: true });
await fs.promises.copyFile(path.join(srcdir, file), outfile);
}
}

const opts: BuildOptions = {
outdir,
entryPoints,
outbase: srcdir,
platform: "node",
target: ["node14"],
};

await Promise.all([
build({
...opts,
format: "cjs",
}),
build({
...opts,
format: "esm",
bundle: true,
splitting: true,
outExtension: { ".js": ".mjs" },
plugins: [
{
name: "external-modules",
setup(build) {
build.onResolve(
{ filter: /^[^./]|^\.[^./]|^\.\.[^/]/ },
({ path }) => ({
path,
external: true,
})
);
},
},
],
}),
]);
59 changes: 0 additions & 59 deletions build.ts

This file was deleted.

Loading

0 comments on commit 31688b4

Please sign in to comment.