-
Notifications
You must be signed in to change notification settings - Fork 56
feat(component-annotate): Introduce new plugin to annotate frontend components at build-time #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 38 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
a05479f
Initial commit for component name annotate plugin
0Calories 56e5777
convert file to TS
0Calories e63f275
Get the build working
0Calories be75356
Initial conversion
gggritso 9af8ac9
Extract constants
gggritso b91ccfb
Move functions around
gggritso 516803f
add tests and convert to TS
0Calories 30e1be7
progress on adding types to plugin index file
0Calories 8cbc95d
yarn lock
0Calories 2f33062
Improve typing of `applyAttributes`
gggritso e35150f
Improve `isReactFragment`
gggritso 30fabf2
Add types to `matchesIgnoreRule`
gggritso 7be1a2e
Improve `hasAttributeWithName`
gggritso a9bdc69
Loosen types on string comparisons
gggritso a726b39
Remove FSTagName
gggritso ca3aa49
Remove unnecessary state
gggritso cea5c8a
Improve `isKnownIncompatiblePluginFromState`
gggritso 93eea1b
Merge branch 'feat/react-annotate-component-names-plugin' into feat/r…
gggritso 137400d
Fix component name fetching
gggritso f7bb682
Improve `processJSX` handling
gggritso c155af2
Rename stale option name
gggritso 9aea4c8
Improve file name logic
gggritso f5617cb
Update plugin import
gggritso 696856f
Ignore Babel config file
gggritso 85d75bd
Update incompatible plugins
gggritso 0d41794
Improve `React.Fragment` handling
gggritso a513911
More robust function body checks
gggritso 52ea127
Fix bad rename
gggritso d9a0477
Fix logical fault in comparator
gggritso d5a67be
Remove unnecessary excludes
gggritso 981c835
remove preset
0Calories 1e56734
remove irrelevant tests
0Calories 31839a1
Update inline snapshots
0Calories 7fa8970
rename plugin and do not use default export
0Calories e6901fc
use full return statements
0Calories 4c03eea
template strings
0Calories ce85d88
add snapshots
0Calories 4e4017a
remove unused variables
0Calories c2ab09b
Add notes on what changed in vendored code
0Calories 968e07e
Add license to constants
0Calories 9b39f13
move comment
0Calories 0c9f610
Update packages/component-annotate-plugin/src/index.ts
0Calories b97d05d
Add package to Craft `requireNames`
0Calories 21d3fd8
Add readme content
0Calories 6b3fd7b
Add beta notice
0Calories 900aedd
Add minimum JS SDK version notice
0Calories 89d8291
change version to align with other packages
0Calories 7111b5f
add plugin ordering note
0Calories bc50479
Add note that it is not supported by esbuild
0Calories 384aa0a
i said bundler too much
0Calories 9f3d223
Rename to README and remove prepack file
0Calories e6b052b
dont gitignore the readme!"
0Calories File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| { | ||
| "presets": ["@babel/typescript"] | ||
| } |
This file contains hidden or 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,20 @@ | ||
| const jestPackageJson = require("jest/package.json"); | ||
|
|
||
| /** @type {import('eslint').ESLint.Options} */ | ||
| module.exports = { | ||
| root: true, | ||
| extends: ["@sentry-internal/eslint-config/jest", "@sentry-internal/eslint-config/base"], | ||
| ignorePatterns: [".eslintrc.js", "dist", "jest.config.js", "rollup.config.js"], | ||
| parserOptions: { | ||
| tsconfigRootDir: __dirname, | ||
| project: ["./src/tsconfig.json", "./test/tsconfig.json"], | ||
| }, | ||
| env: { | ||
| node: true, | ||
| }, | ||
| settings: { | ||
| jest: { | ||
| version: jestPackageJson.version, | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or 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,3 @@ | ||
| dist | ||
| README.md | ||
| .DS_Store |
This file contains hidden or 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,29 @@ | ||
| # MIT License | ||
|
|
||
| Copyright (c) 2024, Sentry | ||
| All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without | ||
| modification, are permitted provided that the following conditions are met: | ||
|
|
||
| - Redistributions of source code must retain the above copyright notice, this | ||
| list of conditions and the following disclaimer. | ||
|
|
||
| - Redistributions in binary form must reproduce the above copyright notice, | ||
| this list of conditions and the following disclaimer in the documentation | ||
| and/or other materials provided with the distribution. | ||
|
|
||
| - Neither the name of the copyright holder nor the names of its | ||
| contributors may be used to endorse or promote products derived from | ||
| this software without specific prior written permission. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Empty file.
This file contains hidden or 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,6 @@ | ||
| module.exports = { | ||
| testEnvironment: "node", | ||
| transform: { | ||
| "^.+\\.(t|j)sx?$": ["@swc/jest"], | ||
| }, | ||
| }; |
This file contains hidden or 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,81 @@ | ||
| { | ||
| "name": "@sentry/component-annotate-plugin", | ||
| "version": "1.0.0", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to align with the other version of the other packages in this repo. |
||
| "description": "A Babel plugin that annotates frontend components with additional data to enrich the experience in Sentry", | ||
| "repository": "git://github.com/getsentry/sentry-javascript-bundler-plugins.git", | ||
| "homepage": "https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/component-annotate-plugin", | ||
| "author": "Sentry", | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "Sentry", | ||
| "React", | ||
| "bundler", | ||
| "plugin", | ||
| "babel", | ||
| "component", | ||
| "annotate" | ||
| ], | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "exports": { | ||
| ".": { | ||
| "import": "./dist/esm/index.mjs", | ||
| "require": "./dist/cjs/index.js", | ||
| "types": "./dist/types/index.d.ts" | ||
| } | ||
| }, | ||
| "main": "dist/cjs/index.js", | ||
| "module": "dist/esm/index.mjs", | ||
| "types": "dist/types/index.d.ts", | ||
| "scripts": { | ||
| "build": "rimraf ./out && run-p build:rollup build:types", | ||
| "build:watch": "run-p build:rollup:watch build:types:watch", | ||
| "build:rollup": "rollup --config rollup.config.js", | ||
| "build:rollup:watch": "rollup --config rollup.config.js --watch --no-watch.clearScreen", | ||
| "build:types": "tsc --project types.tsconfig.json", | ||
| "build:types:watch": "tsc --project types.tsconfig.json --watch --preserveWatchOutput", | ||
| "build:npm": "npm pack", | ||
| "check:types": "run-p check:types:src check:types:test", | ||
| "check:types:src": "tsc --project ./src/tsconfig.json --noEmit", | ||
| "check:types:test": "tsc --project ./test/tsconfig.json --noEmit", | ||
| "clean": "run-s clean:build", | ||
| "clean:all": "run-p clean clean:deps", | ||
| "clean:build": "rimraf ./dist *.tgz", | ||
| "clean:deps": "rimraf node_modules", | ||
| "test": "jest", | ||
| "lint": "eslint ./src ./test", | ||
| "prepack": "ts-node ./src/prepack.ts" | ||
| }, | ||
| "dependencies": {}, | ||
| "devDependencies": { | ||
| "@babel/core": "7.18.5", | ||
| "@babel/preset-env": "7.18.2", | ||
| "@babel/preset-react": "^7.23.3", | ||
| "@babel/preset-typescript": "7.17.12", | ||
| "@rollup/plugin-babel": "5.3.1", | ||
| "@rollup/plugin-node-resolve": "13.3.0", | ||
| "@sentry-internal/eslint-config": "2.10.3", | ||
| "@sentry-internal/sentry-bundler-plugin-tsconfig": "2.10.3", | ||
| "@swc/core": "^1.2.205", | ||
| "@swc/jest": "^0.2.21", | ||
| "@types/jest": "^28.1.3", | ||
| "@types/node": "^18.6.3", | ||
| "@types/uuid": "^9.0.1", | ||
| "eslint": "^8.18.0", | ||
| "jest": "^28.1.1", | ||
| "rimraf": "^3.0.2", | ||
| "rollup": "2.75.7", | ||
| "ts-node": "^10.9.1", | ||
| "typescript": "^4.7.4" | ||
| }, | ||
| "volta": { | ||
| "extends": "../../package.json" | ||
| }, | ||
| "engines": { | ||
| "node": ">= 14" | ||
| } | ||
| } | ||
This file contains hidden or 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,42 @@ | ||
| import resolve from "@rollup/plugin-node-resolve"; | ||
| import babel from "@rollup/plugin-babel"; | ||
| import packageJson from "./package.json"; | ||
| import modulePackage from "module"; | ||
|
|
||
| const input = ["src/index.ts"]; | ||
|
|
||
| const extensions = [".ts"]; | ||
|
|
||
| export default { | ||
| input, | ||
| external: [...Object.keys(packageJson.dependencies), ...modulePackage.builtinModules], | ||
| onwarn: (warning) => { | ||
| throw new Error(warning.message); // Warnings are usually high-consequence for us so let's throw to catch them | ||
| }, | ||
| plugins: [ | ||
| resolve({ | ||
| extensions, | ||
| rootDir: "./src", | ||
| preferBuiltins: true, | ||
| }), | ||
| babel({ | ||
| extensions, | ||
| babelHelpers: "bundled", | ||
| include: ["src/**/*"], | ||
| }), | ||
| ], | ||
| output: [ | ||
| { | ||
| file: packageJson.module, | ||
| format: "esm", | ||
| exports: "named", | ||
| sourcemap: true, | ||
| }, | ||
| { | ||
| file: packageJson.main, | ||
| format: "cjs", | ||
| exports: "named", | ||
| sourcemap: true, | ||
| }, | ||
| ], | ||
| }; |
This file contains hidden or 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,121 @@ | ||
| export const KNOWN_INCOMPATIBLE_PLUGINS = [ | ||
| // This module might be causing an issue preventing clicks. For safety, we won't run on this module. | ||
| "react-native-testfairy", | ||
| // This module checks for unexpected property keys and throws an exception. | ||
| "@react-navigation", | ||
| ]; | ||
|
|
||
| export const DEFAULT_IGNORED_ELEMENTS = [ | ||
| "a", | ||
| "abbr", | ||
| "address", | ||
|
0Calories marked this conversation as resolved.
|
||
| "area", | ||
| "article", | ||
| "aside", | ||
| "audio", | ||
| "b", | ||
| "base", | ||
| "bdi", | ||
| "bdo", | ||
| "blockquote", | ||
| "body", | ||
| "br", | ||
| "button", | ||
| "canvas", | ||
| "caption", | ||
| "cite", | ||
| "code", | ||
| "col", | ||
| "colgroup", | ||
| "data", | ||
| "datalist", | ||
| "dd", | ||
| "del", | ||
| "details", | ||
| "dfn", | ||
| "dialog", | ||
| "div", | ||
| "dl", | ||
| "dt", | ||
| "em", | ||
| "embed", | ||
| "fieldset", | ||
| "figure", | ||
| "footer", | ||
| "form", | ||
| "h1", | ||
| "h2", | ||
| "h3", | ||
| "h4", | ||
| "h5", | ||
| "h6", | ||
| "head", | ||
| "header", | ||
| "hgroup", | ||
| "hr", | ||
| "html", | ||
| "i", | ||
| "iframe", | ||
| "img", | ||
| "input", | ||
| "ins", | ||
| "kbd", | ||
| "keygen", | ||
| "label", | ||
| "legend", | ||
| "li", | ||
| "link", | ||
| "main", | ||
| "map", | ||
| "mark", | ||
| "menu", | ||
| "menuitem", | ||
| "meter", | ||
| "nav", | ||
| "noscript", | ||
| "object", | ||
| "ol", | ||
| "optgroup", | ||
| "option", | ||
| "output", | ||
| "p", | ||
| "param", | ||
| "pre", | ||
| "progress", | ||
| "q", | ||
| "rb", | ||
| "rp", | ||
| "rt", | ||
| "rtc", | ||
| "ruby", | ||
| "s", | ||
| "samp", | ||
| "script", | ||
| "section", | ||
| "select", | ||
| "small", | ||
| "source", | ||
| "span", | ||
| "strong", | ||
| "style", | ||
| "sub", | ||
| "summary", | ||
| "sup", | ||
| "table", | ||
| "tbody", | ||
| "td", | ||
| "template", | ||
| "textarea", | ||
| "tfoot", | ||
| "th", | ||
| "thead", | ||
| "time", | ||
| "title", | ||
| "tr", | ||
| "track", | ||
| "u", | ||
| "ul", | ||
| "var", | ||
| "video", | ||
| "wbr", | ||
| ]; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a README with some explanations about how it works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, writing that right now!