Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow: switch to pnpm #5060

Merged
merged 32 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
39c7ac8
wip: some tests are not passing
yyx990803 Sep 23, 2021
36dc8da
build: link vite to root
yyx990803 Sep 23, 2021
bcd89da
wip: some progress
yyx990803 Sep 23, 2021
c06da90
wip: some test progress
yyx990803 Sep 23, 2021
3af0c1e
wip: fix more tests
yyx990803 Sep 23, 2021
8d67732
wip: more progress
yyx990803 Sep 23, 2021
aff8b20
wip: all tests pass!
yyx990803 Sep 23, 2021
f9fc4c1
ci: use pnpm on ci
yyx990803 Sep 23, 2021
02ad3f5
chore: lockfile
yyx990803 Sep 23, 2021
149b816
ci: update config
yyx990803 Sep 23, 2021
a79ca27
ci: make pnpm happy
yyx990803 Sep 23, 2021
9021caf
wip: save
yyx990803 Sep 23, 2021
3887379
ci: workaround pnpm file protocol issues
yyx990803 Sep 23, 2021
d86ec6e
ci: install pnpm first
yyx990803 Sep 23, 2021
96994d5
ci: fix pnpm run flags
yyx990803 Sep 23, 2021
8cc134b
ci: fix lint
yyx990803 Sep 23, 2021
110ffa7
ci: fix nested workspace package
yyx990803 Sep 23, 2021
3f64161
ci: simplify workspace config
yyx990803 Sep 23, 2021
e359558
chore: update yarn references
yyx990803 Sep 23, 2021
2ccaff6
docs: add note about pnpm file protocol
yyx990803 Sep 23, 2021
2b51670
ci: attemp to fix test case on windows
yyx990803 Sep 23, 2021
e90886d
ci: use consistent steps for lint
yyx990803 Sep 24, 2021
7017dae
docs: force docs to use locally built vite + use pnpm for netlify
yyx990803 Sep 24, 2021
b7dc93f
docs: fix netlify npm flags
yyx990803 Sep 24, 2021
f7ff379
fix: remove yarn usage in vite build script
yyx990803 Sep 24, 2021
6af8527
workflow: update release script [ci skip]
yyx990803 Sep 24, 2021
41356c5
chore: revert unintended test case change
yyx990803 Sep 24, 2021
3eadde3
chore: ignore pnpm files from prettier
yyx990803 Sep 24, 2021
a5cb940
chore: update jest ignore pattern
yyx990803 Sep 24, 2021
fd16627
ci: fix lint workflow
yyx990803 Sep 24, 2021
2a8b559
Merge branch 'main' into pnpm
yyx990803 Sep 24, 2021
7d86fde
Update CONTRIBUTING.md
yyx990803 Sep 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip: all tests pass!
  • Loading branch information
yyx990803 committed Sep 23, 2021
commit aff8b20cb42d96594523e6b4d1d11043286c0501
2 changes: 1 addition & 1 deletion packages/playground/nested-deps/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'test-package-b',
'test-package-c',
'test-package-c/side',
'test-package-d > test-package-d-nested'
'test-package-d > test-package-d-nested'
yyx990803 marked this conversation as resolved.
Show resolved Hide resolved
],
exclude: ['test-package-d']
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"nested-include": "file:./nested-include"
"nested-include": "link:./nested-include"
}
}
4 changes: 2 additions & 2 deletions packages/playground/optimize-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"dependencies": {
"axios": "^0.21.1",
"clipboard": "^2.0.6",
"dep-cjs-compiled-from-cjs": "file:./dep-cjs-compiled-from-cjs",
"dep-cjs-compiled-from-esm": "file:./dep-cjs-compiled-from-esm",
"dep-cjs-compiled-from-cjs": "link:./dep-cjs-compiled-from-cjs",
"dep-cjs-compiled-from-esm": "link:./dep-cjs-compiled-from-esm",
"dep-esbuild-plugin-transform": "link:./dep-esbuild-plugin-transform",
"dep-linked": "link:./dep-linked",
"dep-linked-include": "link:./dep-linked-include",
Expand Down
16 changes: 14 additions & 2 deletions packages/playground/optimize-deps/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ module.exports = {
optimizeDeps: {
include: [
'dep-linked-include',
'nested-exclude > nested-include',
// required since it isn't in node_modules and is ignored by the optimizer otherwise
'dep-esbuild-plugin-transform',
'nested-exclude>nested-include'
'dep-cjs-compiled-from-cjs',
'dep-cjs-compiled-from-esm'
],
exclude: ['nested-exclude'],
esbuildOptions: {
Expand All @@ -36,7 +38,17 @@ module.exports = {

build: {
// to make tests faster
minify: false
minify: false,
// force CommonJS handling on nested-exclude > nested-include since it's
// linked and not in node_modules
commonjsOptions: {
include: [
/node_modules/,
/nested-include/,
/dep-cjs-compiled-from-cjs/,
/dep-cjs-compiled-from-esm/
]
}
},

plugins: [
Expand Down
92 changes: 4 additions & 88 deletions packages/playground/preserve-symlinks/__tests__/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
// the default e2e test serve behavior

const path = require('path')
const http = require('http')
const sirv = require('sirv')
const fs = require('fs')

const port = (exports.port = 9527)
const fs = require('fs-extra')

/**
* @param {string} root
* @param {boolean} isBuildTest
*/
exports.serve = async function serve(root, isBuildTest) {
const testDist = path.resolve(__dirname, '../moduleA/dist')
exports.preServe = async (root) => {
const testDist = path.resolve(root, './moduleA/dist')

if (fs.existsSync(testDist)) {
emptyDir(testDist)
await fs.emptyDir(testDist)
} else {
fs.mkdirSync(testDist, { recursive: true })
}
Expand All @@ -26,83 +21,4 @@ exports.serve = async function serve(root, isBuildTest) {
path.resolve(testDist, '../src/index.js'),
path.resolve(testDist, 'symlinks-moduleA.esm.js')
)

if (!isBuildTest) {
const { createServer } = require('vite')
process.env.VITE_INLINE = 'inline-serve'
let viteServer = await (
await createServer({
root: root,
logLevel: 'silent',
server: {
watch: {
usePolling: true,
interval: 100
},
host: true,
fs: {
strict: !isBuildTest
}
},
build: {
target: 'esnext'
}
})
).listen()
// use resolved port/base from server
const base = viteServer.config.base === '/' ? '' : viteServer.config.base
const url =
(global.viteTestUrl = `http://localhost:${viteServer.config.server.port}${base}`)
await page.goto(url)

return viteServer
} else {
const { build } = require('vite')
await build({
root,
logLevel: 'silent',
configFile: path.resolve(__dirname, '../vite.config.js')
})

// start static file server
const serve = sirv(path.resolve(root, 'dist'))
const httpServer = http.createServer((req, res) => {
if (req.url === '/ping') {
res.statusCode = 200
res.end('pong')
} else {
serve(req, res)
}
})

return new Promise((resolve, reject) => {
try {
const server = httpServer.listen(port, async () => {
await page.goto(`http://localhost:${port}`)
resolve({
// for test teardown
async close() {
await new Promise((resolve) => {
server.close(resolve)
})
}
})
})
} catch (e) {
reject(e)
}
})
}
}

function emptyDir(dir) {
for (const file of fs.readdirSync(dir)) {
const abs = path.resolve(dir, file)
if (fs.lstatSync(abs).isDirectory()) {
emptyDir(abs)
fs.rmdirSync(abs)
} else {
fs.unlinkSync(abs)
}
}
}
13 changes: 1 addition & 12 deletions packages/playground/preserve-symlinks/moduleA/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,5 @@
"name": "@symlinks/moduleA",
"version": "0.0.0",
"module": "dist/symlinks-moduleA.esm.js",
"main": "dist/symlinks-moduleA.cjs.js",
"preconstruct": {
"entrypoints": [
"index.js"
]
},
"scripts": {
"dev": "preconstruct dev"
},
"devDependencies": {
"@preconstruct/cli": "^2.0.6"
}
"main": "dist/symlinks-moduleA.cjs.js"
}
18 changes: 16 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages:
- 'packages/*'
- 'packages/playground/*'
- 'packages/playground/nested-deps/test-package-d'
- 'packages/playground/optimize-deps/nested-exclude'
23 changes: 8 additions & 15 deletions scripts/jestPerTestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,7 @@ beforeAll(async () => {
// start a vite server in that directory.
if (testName) {
const playgroundRoot = resolve(__dirname, '../packages/playground')
const srcDir = resolve(playgroundRoot, testName)
tempDir = resolve(__dirname, '../packages/temp/', testName)
// await fs.copy(srcDir, tempDir, {
// dereference: false,
// filter(file) {
// file = slash(file)
// return (
// !file.includes('__tests__') &&
// // !file.includes('node_modules') &&
// !file.match(/dist(\/|$)/)
// )
// }
// })

// when `root` dir is present, use it as vite's root
let testCustomRoot = resolve(tempDir, 'root')
Expand All @@ -83,9 +71,14 @@ beforeAll(async () => {
const testCustomServe = resolve(dirname(testPath), 'serve.js')
if (fs.existsSync(testCustomServe)) {
// test has custom server configuration.
const { serve } = require(testCustomServe)
server = await serve(rootDir, isBuildTest)
return
const { serve, preServe } = require(testCustomServe)
if (preServe) {
await preServe(rootDir, isBuildTest)
}
if (serve) {
server = await serve(rootDir, isBuildTest)
return
}
}

const options: UserConfig = {
Expand Down