Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .circleci/src/pipeline/@pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ jobs:
source ./scripts/ensure-node.sh
yarn lerna run types
- sanitize-verify-and-store-mocha-results:
expectedResultCount: 10
expectedResultCount: 9

verify-release-readiness:
<<: *defaults
Expand Down
2 changes: 1 addition & 1 deletion guides/esm-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa
- [x] packages/telemetry ✅ **COMPLETED**
- [ ] packages/ts - ultimate goal is removal and likely not worth the effort to convert
- [x] packages/types ✅ **COMPLETED**
- [ ] packages/v8-snapshot-require
- [x] packages/v8-snapshot-require ✅ **COMPLETED**

### Phase 3: Bundle ESM/CJS versions of NPM packages

Expand Down
5 changes: 3 additions & 2 deletions packages/v8-snapshot-require/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"clean": "rimraf dist",
"clean-deps": "rimraf node_modules",
"test": "yarn test-unit",
"test-unit": "mocha --config ./test/.mocharc.js",
"test-debug": "vitest --inspect-brk --no-file-parallelism --test-timeout=0",
"test-unit": "vitest run",
"tslint": "tslint --config ../ts/tslint.json --project .",
"watch": "tsc --watch"
},
Expand All @@ -21,7 +22,7 @@
},
"devDependencies": {
"@tooling/packherd": "0.0.0-development",
"mocha": "7.0.1"
"vitest": "^3.2.4"
},
"files": [
"dist",
Expand Down
9 changes: 0 additions & 9 deletions packages/v8-snapshot-require/test/.mocharc.js

This file was deleted.

22 changes: 11 additions & 11 deletions packages/v8-snapshot-require/test/dependency-map.circular.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest'
import { buildDependencyMap } from '@tooling/v8-snapshot'
import { DependencyMap } from '../src/dependency-map'
import type { Metadata } from '../src/types'
import { expect } from 'chai'

const ROOT = 'lib/root.js'
const FOO = 'lib/foo.js'
Expand Down Expand Up @@ -84,18 +84,18 @@ const dp = new DependencyMap(map)

describe('dependency map: circular', () => {
it('creates a map with circular dep - all deps ', () => {
expect(dp.allDepsOf(ROOT)).to.deep.equal(ALL_ROOT)
expect(dp.allDepsOf(FOO)).to.deep.equal(ALL_FOO)
expect(dp.allDepsOf(BAR)).to.deep.equal(ALL_BAR)
expect(dp.allDepsOf(BAZ)).to.deep.equal(ALL_BAZ)
expect(dp.allDepsOf(FOZ)).to.deep.equal(ALL_FOZ)
expect(dp.allDepsOf(ROOT)).toEqual(ALL_ROOT)
expect(dp.allDepsOf(FOO)).toEqual(ALL_FOO)
expect(dp.allDepsOf(BAR)).toEqual(ALL_BAR)
expect(dp.allDepsOf(BAZ)).toEqual(ALL_BAZ)
expect(dp.allDepsOf(FOZ)).toEqual(ALL_FOZ)
})

it('creates a map with circular dep - direct deps ', () => {
expect(dp.directDepsOf(ROOT)).to.deep.equal(DIRECT_ROOT)
expect(dp.directDepsOf(FOO)).to.deep.equal(DIRECT_FOO)
expect(dp.directDepsOf(BAR)).to.deep.equal(DIRECT_BAR)
expect(dp.directDepsOf(BAZ)).to.deep.equal(DIRECT_BAZ)
expect(dp.directDepsOf(FOZ)).to.deep.equal(DIRECT_FOZ)
expect(dp.directDepsOf(ROOT)).toEqual(DIRECT_ROOT)
expect(dp.directDepsOf(FOO)).toEqual(DIRECT_FOO)
expect(dp.directDepsOf(BAR)).toEqual(DIRECT_BAR)
expect(dp.directDepsOf(BAZ)).toEqual(DIRECT_BAZ)
expect(dp.directDepsOf(FOZ)).toEqual(DIRECT_FOZ)
})
})
22 changes: 11 additions & 11 deletions packages/v8-snapshot-require/test/dependency-map.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest'
import { buildDependencyMap } from '@tooling/v8-snapshot'
import { DependencyMap } from '../src/dependency-map'
import type { Metadata } from '../src/types'
import { expect } from 'chai'

const NO_DEPS = 'lib/fixtures/no-deps.js'
const SYNC_DEPS = 'lib/fixtures/sync-deps.js'
Expand Down Expand Up @@ -68,31 +68,31 @@ describe('dependency map', () => {
const cache: Record<string, NodeModule> = {}

for (const id of allIds) {
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).to.be.false
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).toBe(false)
}

for (const id of allIds) {
cache[id] = {} as NodeModule
loaded.add(id)
}
for (const id of allIds) {
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).to.be.false
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).toBe(false)
}

delete cache[NO_DEPS]

for (const id of allIds) {
const res = id === NO_DEPS

expect(dp.loadedButNotCached(id, loaded, cache)).to.equal(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
expect(dp.loadedButNotCached(id, loaded, cache)).toEqual(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
}

delete cache[SYNC_DEPS]

for (const id of allIds) {
const res = id === NO_DEPS || id === SYNC_DEPS

expect(dp.loadedButNotCached(id, loaded, cache)).to.equal(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
expect(dp.loadedButNotCached(id, loaded, cache)).toEqual(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
}
})

Expand All @@ -107,20 +107,20 @@ describe('dependency map', () => {

load(NO_DEPS)

expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs no reload').to.be.false
expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs no reload').toBe(false)

delete cache[NO_DEPS]

expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs reload since not in cache and NO_DEPS is direct dep').to.be.true
expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs reload since not in cache and NO_DEPS is direct dep').toBe(true)

expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs reload since a cache free path to NO_DEPS exists').to.be.true
expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs reload since a cache free path to NO_DEPS exists').toBe(true)

expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs reload since a cache free path to NO_DEPS exists').to.be.true
expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs reload since a cache free path to NO_DEPS exists').toBe(true)

load(SYNC_DEPS)

expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs no reload since no cache free path to NO_DEPS exists').to.be.false
expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs no reload since no cache free path to NO_DEPS exists').toBe(false)

expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs no reload since no cache free path to NO_DEPS exists').to.be.false
expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs no reload since no cache free path to NO_DEPS exists').toBe(false)
})
})
9 changes: 9 additions & 0 deletions packages/v8-snapshot-require/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
include: ['test/**/*.spec.ts'],
globals: true,
environment: 'node',
},
})
Loading