diff --git a/docs/migration/v8-to-v9.md b/docs/migration/v8-to-v9.md index 77f1607e9169..a43a86bd1566 100644 --- a/docs/migration/v8-to-v9.md +++ b/docs/migration/v8-to-v9.md @@ -163,6 +163,10 @@ Object.defineProperty(exports, '__esModule', { value: true }); The SDK no longer contains these statements. Let us know if this is causing issues in your setup by opening an issue on GitHub. +### `@sentry/deno` + +- The import of Sentry from the deno registry has changed. Use `import * as Sentry from 'https://deno.land/x/sentry/build/index.mjs'` instead. + ## 6. Type Changes In v8, types have been exported from `@sentry/types`, while implementations have been exported from other classes. diff --git a/packages/deno/README.md b/packages/deno/README.md index 502778cf8abb..b1f0ac5ddb0d 100644 --- a/packages/deno/README.md +++ b/packages/deno/README.md @@ -26,7 +26,7 @@ and hook into the environment. Note that you can turn off almost all side effect ```javascript // Import from the Deno registry -import * as Sentry from 'https://deno.land/x/sentry/index.mjs'; +import * as Sentry from 'https://deno.land/x/sentry/build/index.mjs'; // or import from npm registry import * as Sentry from 'npm:@sentry/deno'; diff --git a/packages/deno/package.json b/packages/deno/package.json index 0bd8498ceae9..ce1827578550 100644 --- a/packages/deno/package.json +++ b/packages/deno/package.json @@ -39,7 +39,7 @@ "build:types": "run-s deno-types build:types:tsc build:types:bundle", "build:types:tsc": "tsc -p tsconfig.types.json", "build:types:bundle": "rollup -c rollup.types.config.mjs", - "build:tarball": "node ./scripts/prepack.js && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build build-types build-test coverage node_modules/.deno sentry-deno-*.tgz", "prefix": "yarn deno-types", @@ -50,7 +50,7 @@ "test": "run-s install:deno deno-types test:unit", "test:unit": "deno test --allow-read --allow-run --no-check", "test:unit:update": "deno test --allow-read --allow-write --allow-run -- --update", - "yalc:publish": "node ./scripts/prepack.js && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/deno/scripts/prepack.js b/packages/deno/scripts/prepack.js deleted file mode 100644 index 6c7db2bc9878..000000000000 --- a/packages/deno/scripts/prepack.js +++ /dev/null @@ -1,127 +0,0 @@ -/* eslint-disable no-console */ - -/** - * This script prepares the central `build` directory for NPM package creation. - * It first copies all non-code files into the `build` directory, including `package.json`, which - * is edited to adjust entry point paths. These corrections are performed so that the paths align with - * the directory structure inside `build`. - * - * TODO(v9): Remove this script and change the Deno SDK to import from build/X. - */ - -const fs = require('node:fs'); -const path = require('node:path'); - -const BUILD_DIR = 'build'; - -const ENTRY_POINTS = ['main', 'module', 'types', 'browser']; -const EXPORT_MAP_ENTRY_POINT = 'exports'; -const TYPES_VERSIONS_ENTRY_POINT = 'typesVersions'; - -const ASSETS = ['README.md', 'LICENSE', 'package.json', '.npmignore']; - -const PACKAGE_JSON = 'package.json'; - -/** - * @typedef {Record<(typeof ENTRY_POINTS)[number], string>} PackageJsonEntryPoints - an object containing module details - */ - -/** - * @typedef {Record} ConditionalExportEntryPoints - an object containing module details - */ - -/** - * @typedef {Record>} TypeVersions - an object containing module details - */ - -/** - * @typedef {Partial & Record>} PackageJsonExports - types for `package.json` exports - */ - -/** - * @typedef {Record & PackageJsonEntryPoints & {[EXPORT_MAP_ENTRY_POINT]: PackageJsonExports} & {[TYPES_VERSIONS_ENTRY_POINT]: TypeVersions}} PackageJson - types for `package.json` - */ - -/** - * @type {PackageJson} - */ -const pkgJson = require(path.resolve(PACKAGE_JSON)); - -// check if build dir exists -if (!fs.existsSync(path.resolve(BUILD_DIR))) { - console.error(`\nERROR: Directory '${BUILD_DIR}' does not exist in ${pkgJson.name}.`); - console.error("This script should only be executed after you've run `yarn build`."); - process.exit(1); -} - -const buildDirContents = fs.readdirSync(path.resolve(BUILD_DIR)); - -// copy non-code assets to build dir -ASSETS.forEach(asset => { - const assetPath = path.resolve(asset); - if (fs.existsSync(assetPath)) { - const destinationPath = path.resolve(BUILD_DIR, path.basename(asset)); - console.log(`Copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}.`); - fs.copyFileSync(assetPath, destinationPath); - } -}); - -// package.json modifications -const newPackageJsonPath = path.resolve(BUILD_DIR, PACKAGE_JSON); - -/** - * @type {PackageJson} - */ -const newPkgJson = require(newPackageJsonPath); - -// modify entry points to point to correct paths (i.e. strip out the build directory) -ENTRY_POINTS.filter(entryPoint => newPkgJson[entryPoint]).forEach(entryPoint => { - newPkgJson[entryPoint] = newPkgJson[entryPoint].replace(`${BUILD_DIR}/`, ''); -}); - -/** - * Recursively traverses the exports object and rewrites all string values to remove the build directory. - * - * @param {PackageJsonExports} exportsObject - the exports object to traverse - * @param {string} key - the key of the current exports object - */ -function rewriteConditionalExportEntryPoint(exportsObject, key) { - const exportsField = exportsObject[key]; - if (!exportsField) { - return; - } - - if (typeof exportsField === 'string') { - exportsObject[key] = exportsField.replace(`${BUILD_DIR}/`, ''); - return; - } - Object.keys(exportsField).forEach(subfieldKey => { - rewriteConditionalExportEntryPoint(exportsField, subfieldKey); - }); -} - -if (newPkgJson[EXPORT_MAP_ENTRY_POINT]) { - Object.keys(newPkgJson[EXPORT_MAP_ENTRY_POINT]).forEach(key => { - rewriteConditionalExportEntryPoint(newPkgJson[EXPORT_MAP_ENTRY_POINT], key); - }); -} - -if (newPkgJson[TYPES_VERSIONS_ENTRY_POINT]) { - Object.entries(newPkgJson[TYPES_VERSIONS_ENTRY_POINT]).forEach(([key, val]) => { - newPkgJson[TYPES_VERSIONS_ENTRY_POINT][key] = Object.entries(val).reduce((acc, [key, val]) => { - const newKey = key.replace(`${BUILD_DIR}/`, ''); - acc[newKey] = val.map(v => v.replace(`${BUILD_DIR}/`, '')); - return acc; - }, {}); - }); -} - -newPkgJson.files = buildDirContents; - -// write modified package.json to file (pretty-printed with 2 spaces) -try { - fs.writeFileSync(newPackageJsonPath, JSON.stringify(newPkgJson, null, 2)); -} catch (error) { - console.error(`\nERROR: Error while writing modified ${PACKAGE_JSON} to disk in ${pkgJson.name}:\n`, error); - process.exit(1); -}