diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9fd0522d8062..9048da5efddf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,6 +33,15 @@ Since we are using [`TypeScript`](https://www.typescriptlang.org/), you need to - `yarn build:dev:filter `, which runs `yarn build:dev` only in projects relevant to the given package (so, for example, running `yarn build:dev:filter @sentry/react` will build the `react` package, all of its dependencies (`utils`, `core`, `browser`, etc), and all packages which depend on it (currently `gatsby` and `nextjs`)) - `yarn build:dev:watch`, which runs `yarn build:dev` in watch mode (recommended) + +## Testing SDK Packages Locally + +To test local versions of SDK packages, for instance in test projects, you have a couple of options: + +* Use [`yarn link`](https://classic.yarnpkg.com/lang/en/docs/cli/link/) to symlink your package to the test project. +* Use [`yalc` to install SDK packages](./docs/using-yalc.md) as if they were already published. +* Run `build:tarball` in the repo and `yarn add ./path/to/tarball.tgz` in the project. + ## Adding Tests **Any nontrivial fixes/features should include tests.** You'll find a `test` folder in each package. diff --git a/docs/using-yalc.md b/docs/using-yalc.md new file mode 100644 index 000000000000..e75255a9cd72 --- /dev/null +++ b/docs/using-yalc.md @@ -0,0 +1,51 @@ +# Using `yalc` for Local SDK Testing + +[Yalc](https://github.com/wclr/yalc) is a simple local dependency repository which we can use to work with local versions of our SDKs. +This is a good alternative to `npm|yarn link` for packages where linking is problematic (e.g. SvelteKit or Angular). + +Here's how to set up and use yalc: + +## Installing `yalc` + +Either install yalc globally, + +```sh +npm install -g yalc + +yarn global add yalc +``` + +or add it to your desired test projects (same command without the `-g|global` flags) + +## Registering/Updating packages + +Whenever you want to make your local changes available to your test projects (e.g. after a local code change), run: + +```sh +yarn yalc:publish +``` + +If you run this command in the root of the repo, this will publish all SDK packages to the local yalc repo. If you run it in a specific SDK package, it will just publish this package. You **don't need to** call `yalc update` in your test project. Already linked test projects will be update automatically. + +## Using yalc packages + +In your test project, run + +```sh +yalc add @sentry/browser #or any other SDK package +``` + +to add the local SDK package to your project. + +**Important:** You need to `yalc add` the dependencies of the SDK package as well (e.g. core, utils, types, etc.). + +## Troubleshooting: + +### My changes are not applied to the test project + +Did you run `yarn build && yarn publish:yalc` after making your changes? + +### My test project uses Vite and I still don't see changes + +Vite pre-bundles and caches dependencies for dev builds. It [doesn't recognize changes in yalc packages though](https://github.com/wclr/yalc/issues/189) :( To make these changes show up anyway, run `vite dev --force`. + diff --git a/package.json b/package.json index 4b9b23b531ce..f2177c40bb71 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "test:unit": "lerna run --ignore @sentry-internal/* test:unit", "test-ci-browser": "lerna run test --ignore \"@sentry/{node,opentelemetry-node,serverless,nextjs,remix,gatsby}\" --ignore @sentry-internal/*", "test-ci-node": "ts-node ./scripts/node-unit-tests.ts", - "test:update-snapshots": "lerna run test:update-snapshots" + "test:update-snapshots": "lerna run test:update-snapshots", + "yalc:publish": "lerna run yalc:publish" }, "volta": { "node": "16.19.0", @@ -117,7 +118,8 @@ "tslib": "^2.3.1", "typedoc": "^0.18.0", "typescript": "3.8.3", - "vitest": "^0.29.2" + "vitest": "^0.29.2", + "yalc": "^1.0.0-pre.53" }, "resolutions": { "**/agent-base": "5" diff --git a/packages/angular-ivy/package.json b/packages/angular-ivy/package.json index 2e123b1536a5..b4b0bfd876b3 100644 --- a/packages/angular-ivy/package.json +++ b/packages/angular-ivy/package.json @@ -56,7 +56,8 @@ "fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"", "lint": "run-s lint:prettier lint:eslint", "lint:eslint": "eslint . --format stylish", - "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"" + "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/angular/package.json b/packages/angular/package.json index 94222f6942f8..5106c688cdab 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -59,7 +59,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "yarn test:unit", "test:unit": "jest", - "test:unit:watch": "jest --watch" + "test:unit:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/browser/package.json b/packages/browser/package.json index a4d9d54bb414..ed3970eae99a 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -75,7 +75,8 @@ "test:integration:checkbrowsers": "node scripts/checkbrowsers.js", "test:package": "node test/package/npm-build.js && rm test/package/tmp.js", "test:unit:watch": "jest --watch", - "test:integration:watch": "test/integration/run.js --watch" + "test:integration:watch": "test/integration/run.js --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/core/package.json b/packages/core/package.json index e2852403a7e0..bc5eabc8d6f5 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -40,7 +40,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "jest", "test:watch": "jest --watch", - "version": "node ../../scripts/versionbump.js src/version.ts" + "version": "node ../../scripts/versionbump.js src/version.ts", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index bc9d53348496..a5e39f833d69 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -56,7 +56,8 @@ "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "yarn ts-node scripts/pretest.ts && yarn jest", - "test:watch": "yarn ts-node scripts/pretest.ts && yarn jest --watch" + "test:watch": "yarn ts-node scripts/pretest.ts && yarn jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/integrations/package.json b/packages/integrations/package.json index 512e8b0557ea..8267b24ef897 100644 --- a/packages/integrations/package.json +++ b/packages/integrations/package.json @@ -45,7 +45,8 @@ "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 227649b18e65..d3d0dbd95276 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -75,7 +75,8 @@ "test:types": "cd test/types && yarn test", "test:watch": "jest --watch", "vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh", - "vercel:project": "source vercel/make-project-use-current-branch.sh" + "vercel:project": "source vercel/make-project-use-current-branch.sh", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/node/package.json b/packages/node/package.json index 832387bda88c..2c241aa4444c 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -56,7 +56,8 @@ "test:jest": "jest", "test:release-health": "node test/manual/release-health/runner.js", "test:webpack": "cd test/manual/webpack-domain/ && yarn --silent && node npm-build.js", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index ab4808ae0a57..d99bbe241585 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -55,7 +55,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "yarn test:jest", "test:jest": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/react/package.json b/packages/react/package.json index a98817cc203c..aeabc835fb28 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -69,7 +69,8 @@ "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/remix/package.json b/packages/remix/package.json index d8a3d9f03259..3c42ec1a82b8 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -70,7 +70,8 @@ "test:integration:client:ci": "yarn test:integration:client --browser='all' --reporter='line'", "test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && jest --config=test/integration/jest.config.js test/integration/test/server/", "test:unit": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/replay/package.json b/packages/replay/package.json index ccbbfb8bdef0..37b2b2233cbc 100644 --- a/packages/replay/package.json +++ b/packages/replay/package.json @@ -29,7 +29,8 @@ "test": "jest", "test:watch": "jest --watch", "bootstrap:demo": "cd demo && yarn", - "start:demo": "yarn build:dev && cd demo && yarn start" + "start:demo": "yarn build:dev && cd demo && yarn start", + "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push" }, "repository": { "type": "git", diff --git a/packages/serverless/package.json b/packages/serverless/package.json index 887912408838..aad69db0ed07 100644 --- a/packages/serverless/package.json +++ b/packages/serverless/package.json @@ -57,7 +57,8 @@ "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 8e1819bc17ed..ca893e3b9b47 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -49,7 +49,8 @@ "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index d9f9da77528d..f652768c6736 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -52,7 +52,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "yarn test:unit", "test:unit": "vitest run", - "test:watch": "vitest --watch" + "test:watch": "vitest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/tracing-internal/package.json b/packages/tracing-internal/package.json index a19bc69c6a80..141a27e33857 100644 --- a/packages/tracing-internal/package.json +++ b/packages/tracing-internal/package.json @@ -44,7 +44,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test:unit": "jest", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/tracing/package.json b/packages/tracing/package.json index 7bae1b2c2e3b..8d098d192b47 100644 --- a/packages/tracing/package.json +++ b/packages/tracing/package.json @@ -48,7 +48,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test:unit": "jest", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/types/package.json b/packages/types/package.json index c5caadd3e873..f472e1996755 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -31,7 +31,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "fix": "run-s fix:eslint fix:prettier", "fix:eslint": "eslint . --format stylish --fix", - "fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"" + "fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/utils/package.json b/packages/utils/package.json index f0a5803d24fb..1425cdedc49f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -45,7 +45,8 @@ "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "jest", "test:watch": "jest --watch", - "test:package": "node test/types/index.js" + "test:package": "node test/types/index.js", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/vue/package.json b/packages/vue/package.json index 4fe6bb3bd465..62d15e3c9175 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -49,7 +49,8 @@ "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" }, "volta": { "extends": "../../package.json" diff --git a/packages/wasm/package.json b/packages/wasm/package.json index a8fc6d165079..fcf87880529d 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -40,7 +40,8 @@ "fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"", "lint": "run-s lint:prettier lint:eslint", "lint:eslint": "eslint . --format stylish", - "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"" + "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", + "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push" }, "volta": { "extends": "../../package.json" diff --git a/yarn.lock b/yarn.lock index d39f972d5311..554a09d17be1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15070,7 +15070,7 @@ ini@1.3.6: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.6.tgz#f1c46a2a93a253e7b3905115e74d527cd23061a1" integrity sha512-IZUoxEjNjubzrmvzZU4lKP7OnYmX72XRl3sqkfJhBKweKi5rnGi5+IUdlj/H1M+Ip5JQ1WzaDMOBRY90Ajc5jg== -ini@2.0.0: +ini@2.0.0, ini@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5" integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA== @@ -19456,6 +19456,16 @@ npm-packlist@^2.1.4: npm-bundled "^1.1.1" npm-normalize-package-bin "^1.0.1" +npm-packlist@^2.1.5: + version "2.2.2" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-2.2.2.tgz#076b97293fa620f632833186a7a8f65aaa6148c8" + integrity sha512-Jt01acDvJRhJGthnUJVF/w6gumWOZxO7IkpY/lsX9//zqQgnF7OJaxgQXcerd4uQOLu7W5bkb4mChL9mdfm+Zg== + dependencies: + glob "^7.1.6" + ignore-walk "^3.0.3" + npm-bundled "^1.1.1" + npm-normalize-package-bin "^1.0.1" + npm-packlist@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-3.0.0.tgz#0370df5cfc2fcc8f79b8f42b37798dd9ee32c2a9" @@ -27798,6 +27808,20 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== +yalc@^1.0.0-pre.53: + version "1.0.0-pre.53" + resolved "https://registry.yarnpkg.com/yalc/-/yalc-1.0.0-pre.53.tgz#c51db2bb924a6908f4cb7e82af78f7e5606810bc" + integrity sha512-tpNqBCpTXplnduzw5XC+FF8zNJ9L/UXmvQyyQj7NKrDNavbJtHvzmZplL5ES/RCnjX7JR7W9wz5GVDXVP3dHUQ== + dependencies: + chalk "^4.1.0" + detect-indent "^6.0.0" + fs-extra "^8.0.1" + glob "^7.1.4" + ignore "^5.0.4" + ini "^2.0.0" + npm-packlist "^2.1.5" + yargs "^16.1.1" + yallist@^3.0.0, yallist@^3.0.2, yallist@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"