Skip to content

Commit

Permalink
Add extra entrypoints to allow packages to avoid pulling to many depe…
Browse files Browse the repository at this point in the history
…ndencies (#342)
  • Loading branch information
Andarist authored Mar 28, 2024
1 parent 7b1496c commit 22e473f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/cypress/src/support.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TestMetadataV2 } from "@replayio/test-utils";
import { buildTestId } from "@replayio/test-utils";
import { buildTestId } from "@replayio/test-utils/testId";
import { CONNECT_TASK_NAME } from "./constants";
import { PluginFeature, isFeatureEnabled } from "./features";

Expand Down
1 change: 1 addition & 0 deletions packages/replay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"./metadata": "./dist/metadata/index.js",
"./metadata/test": "./dist/metadata/test/index.js",
"./metadata/*": "./dist/metadata/*.js",
"./utils": "./dist/utils.js",
"./package.json": "./package.json"
},
"files": [
Expand Down
6 changes: 6 additions & 0 deletions packages/replay/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// This module is meant to be somewhat browser-friendly.
// It can't lead to importing node builtin modules like like worker_threads.
// Cypress bundles this file and runs it in the browser,
// some imports like path and http are OK because they are aliased~ by their webpack config:
// https://github.com/cypress-io/cypress/blob/fb87950d6337ba99d13cb5fa3ce129e5f5cac02b/npm/webpack-batteries-included-preprocessor/index.js#L151
// TODO: decouple this more so we never run into problems with this - we shouldn't rely on implementation details of Cypress bundling
import dbg from "debug";
import path from "path";
import { Agent as HttpAgent, AgentOptions } from "http";
Expand Down
1 change: 1 addition & 0 deletions packages/replay/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./dist/utils.js";
1 change: 1 addition & 0 deletions packages/replay/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("./dist/utils.js");
5 changes: 5 additions & 0 deletions packages/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"version": "1.3.16",
"description": "Utilities for recording tests with replay.io",
"main": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./testId": "./dist/testId.js",
"./package.json": "./package.json"
},
"scripts": {
"prepare": "yarn run build",
"build": "rm -rf dist/ tsconfig.tsbuildinfo && tsc",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/src/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDirectory } from "@replayio/replay";
import { getDirectory } from "@replayio/replay/utils";
import { existsSync, writeFileSync } from "fs";
import path from "path";
import { warn } from "./logging";
Expand Down
1 change: 1 addition & 0 deletions packages/test-utils/testId.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./dist/testId.js";
1 change: 1 addition & 0 deletions packages/test-utils/testId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("./dist/testId.js");

0 comments on commit 22e473f

Please sign in to comment.