@@ -33,6 +33,34 @@ yarn build:es5
3333# We need to build esm versions because that's what `next` actually uses when it builds the app
3434yarn build:esm
3535
36+ # Set all packages in the repo to point to their siblings as file dependencies. That way, when we install the local copy
37+ # of @sentry/nextjs, it'll pull the local copy of each of its @sentry/* dependents. This mimics what Lerna does with
38+ # symlinks, just with file dependencies (which we have to use because linking seems to lead to module resolution
39+ # errors).
40+ echo " "
41+ echo " POINTING SIBLING DEPENDENCIES IN PACKAGE.JSON AT LOCAL DIRECTORIES"
42+ PACKAGES_DIR=" $REPO_DIR /packages"
43+ # Escape all of the slashes in the path for use in sed
44+ ESCAPED_PACKAGES_DIR=$( echo $PACKAGES_DIR | sed s/' \/' /' \\\/' /g)
45+
46+ # Get the names of all of the packages
47+ package_names=()
48+ for abs_package_path in ${PACKAGES_DIR} /* ; do
49+ package_names+=($( basename $abs_package_path ) )
50+ done
51+
52+ # Modify each package's package.json file by searching in it for sentry dependencies from the monorepo and, for each
53+ # sibling dependency found, replacing the version number with a file dependency pointing to the sibling itself (so
54+ # `"@sentry/utils": "6.9.0"` becomes `"@sentry/utils": "file:/abs/path/to/sentry-javascript/packages/utils"`)
55+ for package in ${package_names[@]} ; do
56+ cd ${PACKAGES_DIR} /${package}
57+
58+ # Within a given package.json file, search for each of the other packages in turn, and if found, make the replacement
59+ for package_dep in ${package_names[@]} ; do
60+ sed -Ei /" @sentry\/${package_dep} " /s/" [0-9]+\.[0-9]+\.[0-9]+" /" file:${ESCAPED_PACKAGES_DIR} \/${package_dep} " / package.json
61+ done
62+ done
63+
3664echo " "
3765echo " MOVING BACK TO PROJECT DIRECTORY"
3866cd $PROJECT_DIR
0 commit comments