-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(build): Add central
build
directory to packages without CDN bun…
…dles (Part 1) (#4854) This PR is part 1 of adding the `build` directory to packages _without_ CDN bundles. It is split into two parts to make reviewing easier. It covers the following packages: * Core * Gatsby * Hub * Minimal Additionally, it adjusts `prepack.ts` to handle both kinds of packages (with/without CDN bundles) via a CL argument. For the Gatsby SDK, additional actions have to be performed which are only relevant for this package. Therefore, `prepack.ts` now supports calling a package-specific `prepack.ts` file located in `<package>/scripts/prepack.ts`. While the tarball structure is identical to the structure in #4838 (except for temporary CDN bundles), the `build` directory structure is simplified due to the fact that there are no CDN bundles or legacy NPM packages to be added to it. Therefore we can reduce one hierarchy level, resulting in the following structure: ``` <sdk>/ ├─ build/ │ ├─ cjs/ // dist until v7 │ │ ├─ CJS modules (+maps) │ ├─ esm/ │ │ ├─ ES6 modules (+maps) │ ├─ types/ │ │ ├─ *.d.ts files (+maps) │ ├─ package.json │ ├─ LICENSE │ ├─ README.md ├─ ... ``` Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
- Loading branch information
1 parent
eb11979
commit 329e033
Showing
19 changed files
with
127 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# Info: the paths in this file are specified so that they align with the file | ||
# structure in `./build` where this file is copied to. This is done by the | ||
# prepack script `sentry-javascript/scripts/prepack.ts`. | ||
|
||
* | ||
|
||
!/dist/**/* | ||
!/esm/**/* | ||
!/build/types/**/* | ||
!/types/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "dist" | ||
"outDir": "build/dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "es6", | ||
"outDir": "esm" | ||
"outDir": "build/esm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
# Info: the paths in this file are specified so that they align with the file | ||
# structure in `./build` where this file is copied to. This is done by the | ||
# prepack script `sentry-javascript/scripts/prepack.ts`. | ||
|
||
* | ||
|
||
!/dist/**/* | ||
!/esm/**/* | ||
!/build/types/**/* | ||
!/types/**/* | ||
|
||
# Gatsby specific | ||
!gatsby-browser.js | ||
!gatsby-node.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable no-console */ | ||
|
||
// DO NOT RUN this script yourself! | ||
// This is invoked from the main `prepack.ts` script in `sentry-javascript/scripts/prepack.ts`. | ||
|
||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
const PACKAGE_ASSETS = ['gatsby-browser.js', 'gatsby-node.js']; | ||
|
||
export function prepack(buildDir: string): boolean { | ||
// copy package-specific assets to build dir | ||
return PACKAGE_ASSETS.every(asset => { | ||
const assetPath = path.resolve(asset); | ||
try { | ||
if (!fs.existsSync(assetPath)) { | ||
console.error(`Asset ${asset} does not exist.`); | ||
return false; | ||
} | ||
fs.copyFileSync(assetPath, path.resolve(buildDir, asset)); | ||
} catch (error) { | ||
console.error(`Error while copying ${asset} to ${buildDir}`); | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "dist" | ||
"outDir": "build/dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "es6", | ||
"outDir": "esm" | ||
"outDir": "build/esm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# Info: the paths in this file are specified so that they align with the file | ||
# structure in `./build` where this file is copied to. This is done by the | ||
# prepack script `sentry-javascript/scripts/prepack.ts`. | ||
|
||
* | ||
|
||
!/dist/**/* | ||
!/esm/**/* | ||
!/build/types/**/* | ||
!/types/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "dist" | ||
"outDir": "build/dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "es6", | ||
"outDir": "esm" | ||
"outDir": "build/esm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# Info: the paths in this file are specified so that they align with the file | ||
# structure in `./build` where this file is copied to. This is done by the | ||
# prepack script `sentry-javascript/scripts/prepack.ts`. | ||
|
||
* | ||
|
||
!/dist/**/* | ||
!/esm/**/* | ||
!/build/types/**/* | ||
!/types/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "dist" | ||
"outDir": "build/dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
|
||
"compilerOptions": { | ||
"module": "es6", | ||
"outDir": "esm" | ||
"outDir": "build/esm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters