Skip to content
Merged
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
1 change: 0 additions & 1 deletion packages/storybook/src/plugins/mock-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export function mockRouter(): PluginOption {
if (id.includes('src')) {
code = code.replace(
"'@cedarjs/router'",
// TODO(storybook): Use the mock router from @cedarjs/testing instead
"'storybook-framework-cedarjs/dist/mocks/MockRouter'",
)
}
Expand Down
36 changes: 2 additions & 34 deletions packages/testing/build.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs'

import { build, buildEsm, defaultBuildOptions } from '@cedarjs/framework-tools'
import { buildCjs, buildEsm } from '@cedarjs/framework-tools'
import {
generateTypesCjs,
generateTypesEsm,
Expand All @@ -10,21 +10,7 @@ import {
await buildEsm()
await generateTypesEsm()

await build({
buildOptions: {
...defaultBuildOptions,
tsconfig: 'tsconfig.cjs.json',
outdir: 'dist/cjs',
logOverride: {
// This feels a bit dangerous, I wish I could do this with a comment
// inside the file where I need this for greater control, but I haven't
// found a way to do that yet.
// This is to silence the CJS warning for `import.meta.glob` and
// `import.meta.dirname`
'empty-import-meta': 'silent',
},
},
})
await buildCjs()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Potential issue: files using import.meta.glob in src/web/globRoutesImporter.ts may not work properly in CJS builds without the custom handling that was removed

await generateTypesCjs()
await insertCommonJsPackageJson({
buildFileUrl: import.meta.url,
Expand Down Expand Up @@ -85,21 +71,3 @@ fs.writeFileSync(
configJestWebJestSetupPath,
webJestSetupFile.replaceAll('await import', 'require'),
)

// ./src/web/globRoutesImporter.ts contains `import.meta.glob`. This is not
// supported in CJS. And for CJS we don't really use this, but it does get
// imported and executed, so we need to mock it. esbuild will just make
// `import.meta` be an empty object, but that's not quite enough for what we
// need here, so I extend it a bit more.
const globRoutesImporterBuildPath = './dist/cjs/web/globRoutesImporter.js'
const globRoutesImporterFile = fs.readFileSync(
globRoutesImporterBuildPath,
'utf-8',
)
fs.writeFileSync(
globRoutesImporterBuildPath,
globRoutesImporterFile.replaceAll(
'const import_meta = {};',
'const import_meta = { glob: () => ({ "routes.tsx": () => null }) };',
),
)
21 changes: 1 addition & 20 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
"default": "./dist/cjs/api/index.js"
}
},
"./api/vitest": {
"types": "./dist/api/vitest/index.d.ts",
"default": "./dist/api/vitest/index.js"
},
"./cache": {
"import": {
"types": "./dist/cache/index.d.ts",
Expand All @@ -86,20 +82,6 @@
"types": "./dist/cjs/web/index.d.ts",
"default": "./dist/cjs/web/index.js"
}
},
"./web/MockRouter.js": {
"import": {
"types": "./dist/web/MockRouter.d.ts",
"default": "./dist/web/MockRouter.js"
},
"require": {
"types": "./dist/cjs/web/MockRouter.d.ts",
"default": "./dist/cjs/web/MockRouter.js"
}
},
"./web/vitest": {
"types": "./dist/web/vitest/index.d.ts",
"default": "./dist/web/vitest/index.js"
}
},
"files": [
Expand All @@ -113,7 +95,7 @@
"build": "tsx ./build.mts && yarn build:types",
"build:pack": "yarn pack -o cedarjs-testing.tgz",
"build:types": "tsc --build --verbose ./tsconfig.build.json",
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
"build:types-cjs": "tsc --build --verbose tsconfig.cjs.json",
"build:watch": "nodemon --watch src --ext 'js,jsx,ts,tsx' --ignore dist --exec 'yarn build'",
"check:attw": "yarn rw-fwtools-attw",
"check:package": "concurrently npm:check:attw yarn:publint",
Expand Down Expand Up @@ -143,7 +125,6 @@
"jest-watch-typeahead": "2.2.2",
"msw": "1.3.5",
"ts-toolbelt": "9.6.0",
"unplugin-auto-import": "19.3.0",
"whatwg-fetch": "3.6.20"
},
"devDependencies": {
Expand Down
46 changes: 0 additions & 46 deletions packages/testing/src/api/mockContext.ts

This file was deleted.

59 changes: 0 additions & 59 deletions packages/testing/src/api/vitest/CedarApiVitestEnv.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/testing/src/api/vitest/index.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/testing/src/api/vitest/vite-plugin-auto-import.ts

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions packages/testing/src/api/vitest/vite-plugin-track-db-imports.ts

This file was deleted.

Loading
Loading