Skip to content

Commit

Permalink
sku v13: Set sourceMapsProd default value to true (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis authored Jul 11, 2024
1 parent fa8758f commit 3abefdc
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 32 deletions.
26 changes: 26 additions & 0 deletions .changeset/many-deers-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'sku': major
---

`sourceMapsProd` is now `true` by default

**BREAKING CHANGE**:

`sourceMapsProd` is now `true` by default. To enable the previous behaviour, set `sourceMapsProd: false` in your sku config:

```ts
// sku.config.ts
import type { SkuConfig } from 'sku';

export default {
sourceMapsProd: false,
} satisfies SkuConfig;
```

**NOTE**: Production source maps can increase memory usage during builds to the point where the Node process exhausts its heap memory. If this occurs, you can increase the memory limit for the Node process by setting the `NODE_OPTIONS` environment variable to `--max-old-space-size=4096` (or a higher value) before running the build command.

For example:

```sh
NODE_OPTIONS=--max-old-space-size=4096 sku build
```
23 changes: 20 additions & 3 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,34 @@ const config = {

type `boolean`

By default source maps will be generated only for development builds.
Set to `true` to enable source maps in production.
Default: `true`

Source maps are always generated for development builds.
It is recommended to enable source maps for production builds in order to aid debugging.
To disable source maps for production builds, set this option to `false`.

Example:

```ts
export default {
sourceMapsProd: true,
sourceMapsProd: false,
} satisfies SkuConfig;
```

**NOTE**: Production source maps can increase memory usage during builds to the point where the Node process exhausts its heap memory.
If this occurs, you can increase the memory limit for the Node process by setting the `NODE_OPTIONS` environment variable to `--max-old-space-size=4096` (or a higher value) before running the build command.

For example:

```sh
NODE_OPTIONS=--max-old-space-size=4096 sku build
```

### When to disable `sourceMapsProd`

Production source maps can be expensive.
If your application does not utilize production source maps, e.g. you have no tracking of production errors, you can disable them to potentially reduce build times and memory usage.

## srcPaths

type `Array<string>`
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/extra-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ If you want to use a currently unsupported format feel free to submit a PR or co

## Source maps

Source maps are enabled by default when running the `sku start` command.
However, if you want to generate source maps when running `sku build`, you can do so by enabling [`sourceMapsProd`](./docs/configuration#sourcemapsprod).
Source maps are enabled by default when running both `sku start` and `sku build`.
If you want to disable source map generation for production builds, you can set [`sourceMapsProd`](./docs/configuration#sourcemapsprod) to `false`.

## Compile packages

Expand Down
2 changes: 1 addition & 1 deletion packages/sku/context/defaultSkuConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
polyfills: [],
libraryName: null,
libraryFile: null,
sourceMapsProd: false,
sourceMapsProd: true,
displayNamesProd: false,
dangerouslySetWebpackConfig: defaultDecorator,
dangerouslySetJestConfig: defaultDecorator,
Expand Down
4 changes: 3 additions & 1 deletion packages/sku/sku-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,10 @@ export interface SkuConfig {
skipPackageCompatibilityCompilation?: string[];

/**
* By default source maps will be generated only for development builds. Set to `true` to enable source maps in production.
* Source maps are always generated for development builds.
* To disable source maps for production builds, set this option to `false`.
*
* @default true
* @link https://seek-oss.github.io/sku/#/./docs/configuration?id=sourcemapsprod
*/
sourceMapsProd?: boolean;
Expand Down
15 changes: 10 additions & 5 deletions tests/__snapshots__/braid-design-system.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`braid-design-system build should generate the expected files 1`] = `
{
"2-07fafa59b5872fc8269f.css": ._1toce6t0 {
"2-057ed479da430777bc0c.css": ._1toce6t0 {
border: 0;
box-sizing: border-box;
font-size: 100%;
Expand Down Expand Up @@ -3100,7 +3100,10 @@ html:not(._19jnx86z) .ad2p4ma {
0 12px 12px -4px rgba(28, 35, 48, 0.1),
0 20px 20px -12px rgba(28, 35, 48, 0.2);
}
/*# sourceMappingURL=2-057ed479da430777bc0c.css.map*/
,
"2-057ed479da430777bc0c.css.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"externals.json": "[
"crypto",
"fs",
Expand All @@ -3119,7 +3122,7 @@ html:not(._19jnx86z) .ad2p4ma {
<meta charset="UTF-8">
<title>My Awesome Project</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link data-chunk="main" rel="stylesheet" href="/2-07fafa59b5872fc8269f.css">
<link data-chunk="main" rel="stylesheet" href="/2-057ed479da430777bc0c.css">
<link data-chunk="main" rel="preload" as="script" href="/runtime.js">
<link data-chunk="main" rel="preload" as="script" href="/main.js">
<script>
Expand All @@ -3139,15 +3142,17 @@ html:not(._19jnx86z) .ad2p4ma {
</html>
",
"main.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"main.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"runtime.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"runtime.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"seekAnz/index.html": "
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Awesome Project</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link data-chunk="main" rel="stylesheet" href="/2-07fafa59b5872fc8269f.css">
<link data-chunk="main" rel="stylesheet" href="/2-057ed479da430777bc0c.css">
<link data-chunk="main" rel="preload" as="script" href="/runtime.js">
<link data-chunk="main" rel="preload" as="script" href="/main.js">
<script>
Expand Down Expand Up @@ -3175,7 +3180,7 @@ SCRIPTS: [
"/main.js",
]
CSS: [
"/2-07fafa59b5872fc8269f.css",
"/2-057ed479da430777bc0c.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -3408,7 +3413,7 @@ SCRIPTS: [
"/main.js",
]
CSS: [
"/2-07fafa59b5872fc8269f.css",
"/2-057ed479da430777bc0c.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down
3 changes: 3 additions & 0 deletions tests/__snapshots__/custom-src-paths.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ POST HYDRATE DIFFS: NO DIFF
exports[`custom-src-paths build should generate the expected files 1`] = `
{
"2.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"2.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"index.html": SCRIPTS: [
"/some-static-place/runtime.js",
"/some-static-place/2.js",
Expand Down Expand Up @@ -156,7 +157,9 @@ SOURCE HTML: <!DOCTYPE html>
</body>
</html>,
"main.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"main.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"runtime.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"runtime.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
}
`;
Expand Down
6 changes: 6 additions & 0 deletions tests/__snapshots__/library-build.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
exports[`library-build build should generate the expected files 1`] = `
{
"1.chunk.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"1.chunk.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"2.chunk.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"2.chunk.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"MyLibrary.css": ._1a0fqha0 {
color: red;
}
/*# sourceMappingURL=MyLibrary.css.map*/
,
"MyLibrary.css.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"MyLibrary.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"MyLibrary.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
}
`;

Expand Down
6 changes: 6 additions & 0 deletions tests/__snapshots__/library-file.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
exports[`library-file build should generate the expected files 1`] = `
{
"1.chunk.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"1.chunk.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"2.chunk.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"2.chunk.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"my-library.css": ._1h1dzz60 {
color: red;
}
/*# sourceMappingURL=my-library.css.map*/
,
"my-library.css.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"my-library.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"my-library.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
}
`;

Expand Down
28 changes: 20 additions & 8 deletions tests/__snapshots__/multiple-routes.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@
exports[`multiple-routes build and serve should generate the expected files 1`] = `
{
"5.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"5.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"AsyncComponent.chunk.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"handlers-Details-f390f327b19b16af7923.css": ._1hpn1da0 {
"AsyncComponent.chunk.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"handlers-Details-791506971640531b9f92.css": ._1hpn1da0 {
color: blue;
}
/*# sourceMappingURL=handlers-Details-791506971640531b9f92.css.map*/
,
"handlers-Details-791506971640531b9f92.css.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"handlers-Details.chunk.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"handlers-Home-17aa52f5474e9553d3f1.css": .ms22la0 {
"handlers-Details.chunk.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"handlers-Home-2d237e279ab26e7d9ff4.css": .ms22la0 {
color: red;
}
/*# sourceMappingURL=handlers-Home-2d237e279ab26e7d9ff4.css.map*/
,
"handlers-Home-2d237e279ab26e7d9ff4.css.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"handlers-Home.chunk.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"handlers-Home.chunk.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"main.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"main.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"production/au/details/$id/index.html": SCRIPTS: [
"https://code.jquery.com/jquery-3.5.0.slim.min.js",
"/static/place/runtime.js",
Expand All @@ -24,7 +35,7 @@ exports[`multiple-routes build and serve should generate the expected files 1`]
"/static/place/AsyncComponent.chunk.js",
]
CSS: [
"/static/place/handlers-Details-f390f327b19b16af7923.css",
"/static/place/handlers-Details-791506971640531b9f92.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -154,7 +165,7 @@ SOURCE HTML: <!DOCTYPE html>
"/static/place/handlers-Home.chunk.js",
]
CSS: [
"/static/place/handlers-Home-17aa52f5474e9553d3f1.css",
"/static/place/handlers-Home-2d237e279ab26e7d9ff4.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -270,7 +281,7 @@ SOURCE HTML: <!DOCTYPE html>
"/static/place/AsyncComponent.chunk.js",
]
CSS: [
"/static/place/handlers-Details-f390f327b19b16af7923.css",
"/static/place/handlers-Details-791506971640531b9f92.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -400,7 +411,7 @@ SOURCE HTML: <!DOCTYPE html>
"/static/place/handlers-Home.chunk.js",
]
CSS: [
"/static/place/handlers-Home-17aa52f5474e9553d3f1.css",
"/static/place/handlers-Home-2d237e279ab26e7d9ff4.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -508,6 +519,7 @@ SOURCE HTML: <!DOCTYPE html>
</body>
</html>,
"runtime.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"runtime.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
}
`;
Expand All @@ -521,7 +533,7 @@ SCRIPTS: [
"/static/place/AsyncComponent.chunk.js",
]
CSS: [
"/static/place/handlers-Details-f390f327b19b16af7923.css",
"/static/place/handlers-Details-791506971640531b9f92.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -664,7 +676,7 @@ SCRIPTS: [
"/static/place/handlers-Home.chunk.js",
]
CSS: [
"/static/place/handlers-Home-17aa52f5474e9553d3f1.css",
"/static/place/handlers-Home-2d237e279ab26e7d9ff4.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/public-path.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SCRIPTS: [
"/static/main.js",
]
CSS: [
"/static/main-adb7247c0c8cd4e8d7fe.css",
"/static/main-2805b6163358bccd828d.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/sku-with-https.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SCRIPTS: [
"/main.js",
]
CSS: [
"/main-3b6ce26d1c21661bee3e.css",
"/main-20b517520995ff660440.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/ssr-hello-world.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SCRIPTS: [
"https://code.jquery.com/jquery-3.5.0.slim.min.js",
]
CSS: [
"http://localhost:4000/main-f3b971c536c8a1f55a47.css",
"http://localhost:4000/main-1f5c2cf64419575cffa6.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -114,7 +114,7 @@ SCRIPTS: [
"https://code.jquery.com/jquery-3.5.0.slim.min.js",
]
CSS: [
"http://localhost:4000/main-f3b971c536c8a1f55a47.css",
"http://localhost:4000/main-1f5c2cf64419575cffa6.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down
12 changes: 9 additions & 3 deletions tests/__snapshots__/styling.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SCRIPTS: [
"/styling/main.js",
]
CSS: [
"/styling/main-1a83a1ba0e49241a7187.css",
"/styling/main-f11c7eb5d7d4b8c58e2e.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -113,13 +113,14 @@ POST HYDRATE DIFFS:
exports[`styling build should generate the expected files 1`] = `
{
"2.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"2.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"index.html": SCRIPTS: [
"/styling/runtime.js",
"/styling/2.js",
"/styling/main.js",
]
CSS: [
"/styling/main-1a83a1ba0e49241a7187.css",
"/styling/main-f11c7eb5d7d4b8c58e2e.css",
]
SOURCE HTML: <!DOCTYPE html>
<html>
Expand Down Expand Up @@ -210,7 +211,7 @@ SOURCE HTML: <!DOCTYPE html>
</script>
</body>
</html>,
"main-1a83a1ba0e49241a7187.css": .external {
"main-f11c7eb5d7d4b8c58e2e.css": .external {
display: none;
font-size: 9px;
}
Expand All @@ -223,9 +224,14 @@ SOURCE HTML: <!DOCTYPE html>
height: 100px;
width: 100px;
}
/*# sourceMappingURL=main-f11c7eb5d7d4b8c58e2e.css.map*/
,
"main-f11c7eb5d7d4b8c58e2e.css.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"main.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"main.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
"runtime.js": "CONTENTS IGNORED IN SNAPSHOT TEST",
"runtime.js.map": "CONTENTS IGNORED IN SNAPSHOT TEST",
}
`;
Expand Down
Loading

0 comments on commit 3abefdc

Please sign in to comment.