Bump `@parcel/watcher`

Adds M1 builds for language server
master
Brad Cornes 2021-11-26 15:07:15 +00:00
parent 0535454958
commit a655ad4701
4 changed files with 1697 additions and 1547 deletions

3195
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
"access": "public" "access": "public"
}, },
"devDependencies": { "devDependencies": {
"@parcel/watcher": "2.0.0-alpha.10", "@parcel/watcher": "2.0.3",
"@types/debounce": "1.2.0", "@types/debounce": "1.2.0",
"@types/node": "14.14.34", "@types/node": "14.14.34",
"@types/vscode": "1.52.0", "@types/vscode": "1.52.0",

View File

@ -35,7 +35,7 @@ import normalizePath from 'normalize-path'
import * as path from 'path' import * as path from 'path'
import * as os from 'os' import * as os from 'os'
import * as fs from 'fs' import * as fs from 'fs'
import chokidar, { FSWatcher } from 'chokidar' import type * as chokidar from 'chokidar'
import findUp from 'find-up' import findUp from 'find-up'
import minimatch from 'minimatch' import minimatch from 'minimatch'
import resolveFrom, { setPnpApi } from './util/resolveFrom' import resolveFrom, { setPnpApi } from './util/resolveFrom'
@ -247,7 +247,7 @@ async function createProjectService(
const documentSettingsCache: Map<string, Settings> = new Map() const documentSettingsCache: Map<string, Settings> = new Map()
let registrations: Promise<BulkUnregistration> let registrations: Promise<BulkUnregistration>
let chokidarWatcher: FSWatcher let chokidarWatcher: chokidar.FSWatcher
let ignore = [ let ignore = [
'**/.git/objects/**', '**/.git/objects/**',
'**/.git/subtree-cache/**', '**/.git/subtree-cache/**',
@ -339,7 +339,8 @@ async function createProjectService(
}, },
}) })
} else { } else {
chokidarWatcher = chokidar.watch([`**/${CONFIG_FILE_GLOB}`, '**/package.json'], { let watch: typeof chokidar.watch = require('chokidar').watch
chokidarWatcher = watch([`**/${CONFIG_FILE_GLOB}`, '**/package.json'], {
cwd: folder, cwd: folder,
ignorePermissionErrors: true, ignorePermissionErrors: true,
ignoreInitial: true, ignoreInitial: true,

View File

@ -12,6 +12,10 @@ const armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_versi
const uv = (process.versions.uv || '').split('.')[0] const uv = (process.versions.uv || '').split('.')[0]
const prebuilds = { const prebuilds = {
'darwin-arm64': {
'node.napi.glibc.node': () =>
require('@parcel/watcher/prebuilds/darwin-arm64/node.napi.glibc.node'),
},
'darwin-x64': { 'darwin-x64': {
'node.napi.glibc.node': () => 'node.napi.glibc.node': () =>
require('@parcel/watcher/prebuilds/darwin-x64/node.napi.glibc.node'), require('@parcel/watcher/prebuilds/darwin-x64/node.napi.glibc.node'),
@ -68,9 +72,13 @@ exports.unsubscribe = (dir, fn, opts) => {
} }
function resolve() { function resolve() {
// Find matching "prebuilds/<platform>-<arch>" directory
var tuples = Object.keys(prebuilds).map(parseTuple)
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0]
if (!tuple) return
// Find most specific flavor first // Find most specific flavor first
var list = prebuilds[platform + '-' + arch] var list = prebuilds[tuple.name]
if (!list) return
var builds = Object.keys(list) var builds = Object.keys(list)
var parsed = builds.map(parseTags) var parsed = builds.map(parseTags)
var candidates = parsed.filter(matchTags(runtime, abi)) var candidates = parsed.filter(matchTags(runtime, abi))
@ -82,6 +90,34 @@ function resolve() {
} }
} }
function parseTuple(name) {
// Example: darwin-x64+arm64
var arr = name.split('-')
if (arr.length !== 2) return
var platform = arr[0]
var architectures = arr[1].split('+')
if (!platform) return
if (!architectures.length) return
if (!architectures.every(Boolean)) return
return { name, platform, architectures }
}
function matchTuple(platform, arch) {
return function (tuple) {
if (tuple == null) return false
if (tuple.platform !== platform) return false
return tuple.architectures.includes(arch)
}
}
function compareTuples(a, b) {
// Prefer single-arch prebuilds over multi-arch
return a.architectures.length - b.architectures.length
}
function parseTags(file) { function parseTags(file) {
var arr = file.split('.') var arr = file.split('.')
var extension = arr.pop() var extension = arr.pop()