Skip to content

chore: reuse source maps documentation between the debugging and preprocessor pages #6121

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 2 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/node-events/preprocessors-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ fs.watch(filePath, () => {
})
```

## Source maps

<SourceMaps />

## Publishing

Publish preprocessors to [npm](https://www.npmjs.com/) with the naming
Expand Down
30 changes: 1 addition & 29 deletions docs/app/guides/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -198,35 +198,7 @@ application under test, so the test above will fail.

### Source maps

Cypress utilizes source maps to enhance the error experience. Stack traces are
translated so that your source files are shown instead of the generated file
that is loaded by the browser. This also enables displaying code frames. Without
inline source maps, you will not see code frames.

By default, Cypress will include an inline source map in your spec file, so you
will get the most out of the error experience. If you
[modify the preprocessor](/api/node-events/preprocessors-api), ensure that inline
source maps are enabled to get the same experience. Some examples of this include:

- With webpack and the
[webpack preprocessor](https://github.com/cypress-io/cypress/tree/develop/npm/webpack-preprocessor), set
[the `devtool` option](https://webpack.js.org/configuration/devtool/) to
`inline-source-map`.
- With esbuild and the
[esbuild preprocessor](https://github.com/bahmutov/cypress-esbuild-preprocessor/tree/main), set
[the `sourcemap` option](https://esbuild.github.io/api/#sourcemap) to `inline` when
[creating the bundler](https://github.com/bahmutov/cypress-esbuild-preprocessor#esbuild-options).
- With cucumber and the
[cucumber preprocessor](https://github.com/badeball/cypress-cucumber-preprocessor/tree/master)
third party bundlers are used to bundle the code.
- For esbuild and the
[esbuild preprocessor](https://github.com/bahmutov/cypress-esbuild-preprocessor/tree/main),
set [the `sourcemap` option](https://esbuild.github.io/api/#sourcemap) to `inline` when
[creating the bundler](https://github.com/bahmutov/cypress-esbuild-preprocessor#esbuild-options).
Note: the cucumber preprocessor documentation for the esbuild bundler describes an experimental
option: `prettySourceMaps`, but this option is buggy and setting source maps on the esbuild
bundler directly works better.
- The other bundlers all default their source maps appropriately.
<SourceMaps />

## Debugging flake

Expand Down
29 changes: 29 additions & 0 deletions docs/partials/_source-maps.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Cypress utilizes source maps to enhance the error experience. Stack traces are
translated so that your source files are shown instead of the generated file
that is loaded by the browser. This also enables displaying code frames. Without
inline source maps, you will not see code frames.

By default, Cypress will include an inline source map in your spec file, so you
will get the most out of the error experience. If you
[modify the preprocessor](/api/node-events/preprocessors-api#Usage), ensure that inline
source maps are enabled to get the same experience. Some examples of this include:

- With webpack and the
[webpack preprocessor](https://github.com/cypress-io/cypress/tree/develop/npm/webpack-preprocessor), set
[the `devtool` option](https://webpack.js.org/configuration/devtool/) to
`inline-source-map`.
- With esbuild and the
[esbuild preprocessor](https://github.com/bahmutov/cypress-esbuild-preprocessor/tree/main), set
[the `sourcemap` option](https://esbuild.github.io/api/#sourcemap) to `inline` when
[creating the bundler](https://github.com/bahmutov/cypress-esbuild-preprocessor#esbuild-options).
- With cucumber and the
[cucumber preprocessor](https://github.com/badeball/cypress-cucumber-preprocessor/tree/master)
third party bundlers are used to bundle the code.
- For esbuild and the
[esbuild preprocessor](https://github.com/bahmutov/cypress-esbuild-preprocessor/tree/main),
set [the `sourcemap` option](https://esbuild.github.io/api/#sourcemap) to `inline` when
[creating the bundler](https://github.com/bahmutov/cypress-esbuild-preprocessor#esbuild-options).
Note: the cucumber preprocessor documentation for the esbuild bundler describes an experimental
option: `prettySourceMaps`, but this option is buggy and setting source maps on the esbuild
bundler directly works better.
- The other bundlers all default their source maps appropriately.
2 changes: 2 additions & 0 deletions src/theme/MDXComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Icon from "@site/src/components/icon";
import ImportMountFunctions from "@site/docs/partials/_import-mount-functions.mdx";
import IntellisenseCodeCompletion from "@site/docs/partials/_intellisense-code-completion.mdx";
import ProductHeading from "@site/src/components/product-heading";
import SourceMaps from "@site/docs/partials/_source-maps.mdx";
import SupportFileConfiguration from "@site/docs/partials/_support-file-configuration.mdx";
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
Expand Down Expand Up @@ -185,6 +186,7 @@ export default {
ImportMountFunctions,
IntellisenseCodeCompletion,
ProductHeading,
SourceMaps,
SupportFileConfiguration,
Tabs,
TabItem,
Expand Down