@react-perfscope/webpack 0.7.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -29,7 +29,12 @@ var ReactPerfscopePlugin = class {
29
29
  void _opts;
30
30
  }
31
31
  apply(compiler) {
32
- if (compiler.options.mode !== "development") return;
32
+ if (compiler.options.mode !== "development") {
33
+ console.warn(
34
+ `[react-perfscope] skipping: webpack mode is '${compiler.options.mode ?? "undefined \u2192 production"}' \u2014 the profiler only mounts when mode is 'development'.`
35
+ );
36
+ return;
37
+ }
33
38
  const EntryPlugin = compiler.webpack.EntryPlugin;
34
39
  new EntryPlugin(
35
40
  compiler.context,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Compiler } from 'webpack'\n\nexport interface ReactPerfscopePluginOptions {\n // Reserved for Phase 6.\n}\n\n/**\n * Webpack plugin that adds `react-perfscope/auto` as an additional entry in\n * development mode. The auto module bootstraps recorder + render collector\n * + UI mount at runtime.\n */\nexport class ReactPerfscopePlugin {\n constructor(_opts?: ReactPerfscopePluginOptions) {\n void _opts\n }\n\n apply(compiler: Compiler): void {\n if (compiler.options.mode !== 'development') return\n const EntryPlugin = compiler.webpack.EntryPlugin\n // EntryPlugin's options arg can be `string | EntryOptions`. Passing an\n // empty EntryOptions makes this an additional \"global\" entry (loaded\n // alongside the named entries). Webpack 5's typing accepts {} here.\n new EntryPlugin(\n compiler.context,\n 'react-perfscope/auto',\n {} as ConstructorParameters<typeof EntryPlugin>[2]\n ).apply(compiler)\n ensureJsProfilingHeader(compiler)\n }\n}\n\n/**\n * The JS Self-Profiling API (used to attribute long tasks to the developer's\n * own functions) only initializes when the document is served with a\n * `Document-Policy: js-profiling` response header. webpack-dev-server reads\n * `compiler.options.devServer` when no options are passed to it explicitly\n * (the `webpack serve` CLI path), so we merge the header in here. It's a no-op\n * where the browser lacks the API, and we never overwrite a user-set value.\n *\n * webpack-dev-server's `headers` can be an object map or an array of\n * `{ key, value }` entries — handle both shapes.\n */\nfunction ensureJsProfilingHeader(compiler: Compiler): void {\n const KEY = 'Document-Policy'\n const VALUE = 'js-profiling'\n // `devServer` is contributed by webpack-dev-server's type augmentation and\n // isn't part of webpack's core Configuration; treat it loosely.\n const options = compiler.options as unknown as {\n devServer?: {\n headers?: Record<string, string> | Array<{ key: string; value: string }>\n }\n }\n const devServer = (options.devServer ??= {})\n if (devServer.headers === undefined) {\n devServer.headers = { [KEY]: VALUE }\n return\n }\n if (Array.isArray(devServer.headers)) {\n if (!devServer.headers.some((h) => h.key === KEY)) {\n devServer.headers.push({ key: KEY, value: VALUE })\n }\n return\n }\n if (!(KEY in devServer.headers)) {\n devServer.headers[KEY] = VALUE\n }\n}\n\nexport default ReactPerfscopePlugin\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAAY,OAAqC;AAC/C,SAAK;AAAA,EACP;AAAA,EAEA,MAAM,UAA0B;AAC9B,QAAI,SAAS,QAAQ,SAAS,cAAe;AAC7C,UAAM,cAAc,SAAS,QAAQ;AAIrC,QAAI;AAAA,MACF,SAAS;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH,EAAE,MAAM,QAAQ;AAChB,4BAAwB,QAAQ;AAAA,EAClC;AACF;AAaA,SAAS,wBAAwB,UAA0B;AACzD,QAAM,MAAM;AACZ,QAAM,QAAQ;AAGd,QAAM,UAAU,SAAS;AAKzB,QAAM,YAAa,QAAQ,cAAR,QAAQ,YAAc,CAAC;AAC1C,MAAI,UAAU,YAAY,QAAW;AACnC,cAAU,UAAU,EAAE,CAAC,GAAG,GAAG,MAAM;AACnC;AAAA,EACF;AACA,MAAI,MAAM,QAAQ,UAAU,OAAO,GAAG;AACpC,QAAI,CAAC,UAAU,QAAQ,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,GAAG;AACjD,gBAAU,QAAQ,KAAK,EAAE,KAAK,KAAK,OAAO,MAAM,CAAC;AAAA,IACnD;AACA;AAAA,EACF;AACA,MAAI,EAAE,OAAO,UAAU,UAAU;AAC/B,cAAU,QAAQ,GAAG,IAAI;AAAA,EAC3B;AACF;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Compiler } from 'webpack'\n\nexport interface ReactPerfscopePluginOptions {\n // Reserved for Phase 6.\n}\n\n/**\n * Webpack plugin that adds `react-perfscope/auto` as an additional entry in\n * development mode. The auto module bootstraps recorder + render collector\n * + UI mount at runtime.\n */\nexport class ReactPerfscopePlugin {\n constructor(_opts?: ReactPerfscopePluginOptions) {\n void _opts\n }\n\n apply(compiler: Compiler): void {\n if (compiler.options.mode !== 'development') {\n // webpack defaults an unset mode to 'production', so `webpack serve`\n // without mode: 'development' would otherwise silently produce no\n // panel — say why we skipped. (Production builds log this line too;\n // one build-time console line is a fair price for the diagnosability.)\n console.warn(\n `[react-perfscope] skipping: webpack mode is '${compiler.options.mode ?? 'undefined → production'}' — the profiler only mounts when mode is 'development'.`\n )\n return\n }\n const EntryPlugin = compiler.webpack.EntryPlugin\n // EntryPlugin's options arg can be `string | EntryOptions`. Passing an\n // empty EntryOptions makes this an additional \"global\" entry (loaded\n // alongside the named entries). Webpack 5's typing accepts {} here.\n new EntryPlugin(\n compiler.context,\n 'react-perfscope/auto',\n {} as ConstructorParameters<typeof EntryPlugin>[2]\n ).apply(compiler)\n ensureJsProfilingHeader(compiler)\n }\n}\n\n/**\n * The JS Self-Profiling API (used to attribute long tasks to the developer's\n * own functions) only initializes when the document is served with a\n * `Document-Policy: js-profiling` response header. webpack-dev-server reads\n * `compiler.options.devServer` when no options are passed to it explicitly\n * (the `webpack serve` CLI path), so we merge the header in here. It's a no-op\n * where the browser lacks the API, and we never overwrite a user-set value.\n *\n * webpack-dev-server's `headers` can be an object map or an array of\n * `{ key, value }` entries — handle both shapes.\n */\nfunction ensureJsProfilingHeader(compiler: Compiler): void {\n const KEY = 'Document-Policy'\n const VALUE = 'js-profiling'\n // `devServer` is contributed by webpack-dev-server's type augmentation and\n // isn't part of webpack's core Configuration; treat it loosely.\n const options = compiler.options as unknown as {\n devServer?: {\n headers?: Record<string, string> | Array<{ key: string; value: string }>\n }\n }\n const devServer = (options.devServer ??= {})\n if (devServer.headers === undefined) {\n devServer.headers = { [KEY]: VALUE }\n return\n }\n if (Array.isArray(devServer.headers)) {\n if (!devServer.headers.some((h) => h.key === KEY)) {\n devServer.headers.push({ key: KEY, value: VALUE })\n }\n return\n }\n if (!(KEY in devServer.headers)) {\n devServer.headers[KEY] = VALUE\n }\n}\n\nexport default ReactPerfscopePlugin\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAAY,OAAqC;AAC/C,SAAK;AAAA,EACP;AAAA,EAEA,MAAM,UAA0B;AAC9B,QAAI,SAAS,QAAQ,SAAS,eAAe;AAK3C,cAAQ;AAAA,QACN,gDAAgD,SAAS,QAAQ,QAAQ,6BAAwB;AAAA,MACnG;AACA;AAAA,IACF;AACA,UAAM,cAAc,SAAS,QAAQ;AAIrC,QAAI;AAAA,MACF,SAAS;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH,EAAE,MAAM,QAAQ;AAChB,4BAAwB,QAAQ;AAAA,EAClC;AACF;AAaA,SAAS,wBAAwB,UAA0B;AACzD,QAAM,MAAM;AACZ,QAAM,QAAQ;AAGd,QAAM,UAAU,SAAS;AAKzB,QAAM,YAAa,QAAQ,cAAR,QAAQ,YAAc,CAAC;AAC1C,MAAI,UAAU,YAAY,QAAW;AACnC,cAAU,UAAU,EAAE,CAAC,GAAG,GAAG,MAAM;AACnC;AAAA,EACF;AACA,MAAI,MAAM,QAAQ,UAAU,OAAO,GAAG;AACpC,QAAI,CAAC,UAAU,QAAQ,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,GAAG;AACjD,gBAAU,QAAQ,KAAK,EAAE,KAAK,KAAK,OAAO,MAAM,CAAC;AAAA,IACnD;AACA;AAAA,EACF;AACA,MAAI,EAAE,OAAO,UAAU,UAAU;AAC/B,cAAU,QAAQ,GAAG,IAAI;AAAA,EAC3B;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/dist/index.js CHANGED
@@ -4,7 +4,12 @@ var ReactPerfscopePlugin = class {
4
4
  void _opts;
5
5
  }
6
6
  apply(compiler) {
7
- if (compiler.options.mode !== "development") return;
7
+ if (compiler.options.mode !== "development") {
8
+ console.warn(
9
+ `[react-perfscope] skipping: webpack mode is '${compiler.options.mode ?? "undefined \u2192 production"}' \u2014 the profiler only mounts when mode is 'development'.`
10
+ );
11
+ return;
12
+ }
8
13
  const EntryPlugin = compiler.webpack.EntryPlugin;
9
14
  new EntryPlugin(
10
15
  compiler.context,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Compiler } from 'webpack'\n\nexport interface ReactPerfscopePluginOptions {\n // Reserved for Phase 6.\n}\n\n/**\n * Webpack plugin that adds `react-perfscope/auto` as an additional entry in\n * development mode. The auto module bootstraps recorder + render collector\n * + UI mount at runtime.\n */\nexport class ReactPerfscopePlugin {\n constructor(_opts?: ReactPerfscopePluginOptions) {\n void _opts\n }\n\n apply(compiler: Compiler): void {\n if (compiler.options.mode !== 'development') return\n const EntryPlugin = compiler.webpack.EntryPlugin\n // EntryPlugin's options arg can be `string | EntryOptions`. Passing an\n // empty EntryOptions makes this an additional \"global\" entry (loaded\n // alongside the named entries). Webpack 5's typing accepts {} here.\n new EntryPlugin(\n compiler.context,\n 'react-perfscope/auto',\n {} as ConstructorParameters<typeof EntryPlugin>[2]\n ).apply(compiler)\n ensureJsProfilingHeader(compiler)\n }\n}\n\n/**\n * The JS Self-Profiling API (used to attribute long tasks to the developer's\n * own functions) only initializes when the document is served with a\n * `Document-Policy: js-profiling` response header. webpack-dev-server reads\n * `compiler.options.devServer` when no options are passed to it explicitly\n * (the `webpack serve` CLI path), so we merge the header in here. It's a no-op\n * where the browser lacks the API, and we never overwrite a user-set value.\n *\n * webpack-dev-server's `headers` can be an object map or an array of\n * `{ key, value }` entries — handle both shapes.\n */\nfunction ensureJsProfilingHeader(compiler: Compiler): void {\n const KEY = 'Document-Policy'\n const VALUE = 'js-profiling'\n // `devServer` is contributed by webpack-dev-server's type augmentation and\n // isn't part of webpack's core Configuration; treat it loosely.\n const options = compiler.options as unknown as {\n devServer?: {\n headers?: Record<string, string> | Array<{ key: string; value: string }>\n }\n }\n const devServer = (options.devServer ??= {})\n if (devServer.headers === undefined) {\n devServer.headers = { [KEY]: VALUE }\n return\n }\n if (Array.isArray(devServer.headers)) {\n if (!devServer.headers.some((h) => h.key === KEY)) {\n devServer.headers.push({ key: KEY, value: VALUE })\n }\n return\n }\n if (!(KEY in devServer.headers)) {\n devServer.headers[KEY] = VALUE\n }\n}\n\nexport default ReactPerfscopePlugin\n"],"mappings":";AAWO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAAY,OAAqC;AAC/C,SAAK;AAAA,EACP;AAAA,EAEA,MAAM,UAA0B;AAC9B,QAAI,SAAS,QAAQ,SAAS,cAAe;AAC7C,UAAM,cAAc,SAAS,QAAQ;AAIrC,QAAI;AAAA,MACF,SAAS;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH,EAAE,MAAM,QAAQ;AAChB,4BAAwB,QAAQ;AAAA,EAClC;AACF;AAaA,SAAS,wBAAwB,UAA0B;AACzD,QAAM,MAAM;AACZ,QAAM,QAAQ;AAGd,QAAM,UAAU,SAAS;AAKzB,QAAM,YAAa,QAAQ,cAAR,QAAQ,YAAc,CAAC;AAC1C,MAAI,UAAU,YAAY,QAAW;AACnC,cAAU,UAAU,EAAE,CAAC,GAAG,GAAG,MAAM;AACnC;AAAA,EACF;AACA,MAAI,MAAM,QAAQ,UAAU,OAAO,GAAG;AACpC,QAAI,CAAC,UAAU,QAAQ,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,GAAG;AACjD,gBAAU,QAAQ,KAAK,EAAE,KAAK,KAAK,OAAO,MAAM,CAAC;AAAA,IACnD;AACA;AAAA,EACF;AACA,MAAI,EAAE,OAAO,UAAU,UAAU;AAC/B,cAAU,QAAQ,GAAG,IAAI;AAAA,EAC3B;AACF;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Compiler } from 'webpack'\n\nexport interface ReactPerfscopePluginOptions {\n // Reserved for Phase 6.\n}\n\n/**\n * Webpack plugin that adds `react-perfscope/auto` as an additional entry in\n * development mode. The auto module bootstraps recorder + render collector\n * + UI mount at runtime.\n */\nexport class ReactPerfscopePlugin {\n constructor(_opts?: ReactPerfscopePluginOptions) {\n void _opts\n }\n\n apply(compiler: Compiler): void {\n if (compiler.options.mode !== 'development') {\n // webpack defaults an unset mode to 'production', so `webpack serve`\n // without mode: 'development' would otherwise silently produce no\n // panel — say why we skipped. (Production builds log this line too;\n // one build-time console line is a fair price for the diagnosability.)\n console.warn(\n `[react-perfscope] skipping: webpack mode is '${compiler.options.mode ?? 'undefined → production'}' — the profiler only mounts when mode is 'development'.`\n )\n return\n }\n const EntryPlugin = compiler.webpack.EntryPlugin\n // EntryPlugin's options arg can be `string | EntryOptions`. Passing an\n // empty EntryOptions makes this an additional \"global\" entry (loaded\n // alongside the named entries). Webpack 5's typing accepts {} here.\n new EntryPlugin(\n compiler.context,\n 'react-perfscope/auto',\n {} as ConstructorParameters<typeof EntryPlugin>[2]\n ).apply(compiler)\n ensureJsProfilingHeader(compiler)\n }\n}\n\n/**\n * The JS Self-Profiling API (used to attribute long tasks to the developer's\n * own functions) only initializes when the document is served with a\n * `Document-Policy: js-profiling` response header. webpack-dev-server reads\n * `compiler.options.devServer` when no options are passed to it explicitly\n * (the `webpack serve` CLI path), so we merge the header in here. It's a no-op\n * where the browser lacks the API, and we never overwrite a user-set value.\n *\n * webpack-dev-server's `headers` can be an object map or an array of\n * `{ key, value }` entries — handle both shapes.\n */\nfunction ensureJsProfilingHeader(compiler: Compiler): void {\n const KEY = 'Document-Policy'\n const VALUE = 'js-profiling'\n // `devServer` is contributed by webpack-dev-server's type augmentation and\n // isn't part of webpack's core Configuration; treat it loosely.\n const options = compiler.options as unknown as {\n devServer?: {\n headers?: Record<string, string> | Array<{ key: string; value: string }>\n }\n }\n const devServer = (options.devServer ??= {})\n if (devServer.headers === undefined) {\n devServer.headers = { [KEY]: VALUE }\n return\n }\n if (Array.isArray(devServer.headers)) {\n if (!devServer.headers.some((h) => h.key === KEY)) {\n devServer.headers.push({ key: KEY, value: VALUE })\n }\n return\n }\n if (!(KEY in devServer.headers)) {\n devServer.headers[KEY] = VALUE\n }\n}\n\nexport default ReactPerfscopePlugin\n"],"mappings":";AAWO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAAY,OAAqC;AAC/C,SAAK;AAAA,EACP;AAAA,EAEA,MAAM,UAA0B;AAC9B,QAAI,SAAS,QAAQ,SAAS,eAAe;AAK3C,cAAQ;AAAA,QACN,gDAAgD,SAAS,QAAQ,QAAQ,6BAAwB;AAAA,MACnG;AACA;AAAA,IACF;AACA,UAAM,cAAc,SAAS,QAAQ;AAIrC,QAAI;AAAA,MACF,SAAS;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH,EAAE,MAAM,QAAQ;AAChB,4BAAwB,QAAQ;AAAA,EAClC;AACF;AAaA,SAAS,wBAAwB,UAA0B;AACzD,QAAM,MAAM;AACZ,QAAM,QAAQ;AAGd,QAAM,UAAU,SAAS;AAKzB,QAAM,YAAa,QAAQ,cAAR,QAAQ,YAAc,CAAC;AAC1C,MAAI,UAAU,YAAY,QAAW;AACnC,cAAU,UAAU,EAAE,CAAC,GAAG,GAAG,MAAM;AACnC;AAAA,EACF;AACA,MAAI,MAAM,QAAQ,UAAU,OAAO,GAAG;AACpC,QAAI,CAAC,UAAU,QAAQ,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,GAAG;AACjD,gBAAU,QAAQ,KAAK,EAAE,KAAK,KAAK,OAAO,MAAM,CAAC;AAAA,IACnD;AACA;AAAA,EACF;AACA,MAAI,EAAE,OAAO,UAAU,UAAU;AAC/B,cAAU,QAAQ,GAAG,IAAI;AAAA,EAC3B;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-perfscope/webpack",
3
- "version": "0.7.0",
3
+ "version": "1.0.0",
4
4
  "description": "webpack plugin that auto-mounts react-perfscope in dev.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -42,6 +42,9 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
+ "engines": {
46
+ "node": ">=18"
47
+ },
45
48
  "scripts": {
46
49
  "build": "tsup && node scripts/prepend-dts-refs.mjs",
47
50
  "typecheck": "tsc --noEmit"