rsbuild-plugin-google-analytics 1.0.3 → 1.0.4

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
@@ -1,69 +1,66 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- pluginGoogleAnalytics: () => pluginGoogleAnalytics
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ pluginGoogleAnalytics: ()=>pluginGoogleAnalytics
24
28
  });
25
- module.exports = __toCommonJS(src_exports);
26
- var pluginGoogleAnalytics = ({
27
- id,
28
- enable = true
29
- }) => ({
30
- name: "rsbuild-plugin-google-analytics",
31
- setup(api) {
32
- if (!enable) {
33
- return;
34
- }
35
- if (!id) {
36
- throw new Error(
37
- "[rsbuild-plugin-google-analytics] Google tag ID is required!"
38
- );
39
- }
40
- api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig }) => {
41
- const extraConfig = {
42
- html: {
43
- tags: [
44
- {
45
- tag: "script",
46
- attrs: {
47
- async: true,
48
- src: `https://www.googletagmanager.com/gtag/js?id=${id}`
49
- }
50
- },
51
- {
52
- tag: "script",
53
- children: `
29
+ const pluginGoogleAnalytics = ({ id, enable = true })=>({
30
+ name: 'rsbuild-plugin-google-analytics',
31
+ setup (api) {
32
+ if (!enable) return;
33
+ if (!id) throw new Error('[rsbuild-plugin-google-analytics] Google tag ID is required!');
34
+ api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig })=>{
35
+ const extraConfig = {
36
+ html: {
37
+ tags: [
38
+ {
39
+ tag: "script",
40
+ attrs: {
41
+ async: true,
42
+ src: `https://www.googletagmanager.com/gtag/js?id=${id}`
43
+ }
44
+ },
45
+ {
46
+ tag: "script",
47
+ children: `
54
48
  window.dataLayer = window.dataLayer || [];
55
49
  function gtag(){dataLayer.push(arguments);}
56
50
  gtag('js', new Date());
57
51
  gtag('config', '${id}');`
58
- }
59
- ]
52
+ }
53
+ ]
54
+ }
55
+ };
56
+ return mergeRsbuildConfig(extraConfig, userConfig);
57
+ });
60
58
  }
61
- };
62
- return mergeRsbuildConfig(extraConfig, userConfig);
63
59
  });
64
- }
65
- });
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- pluginGoogleAnalytics
60
+ exports.pluginGoogleAnalytics = __webpack_exports__.pluginGoogleAnalytics;
61
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
62
+ "pluginGoogleAnalytics"
63
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
64
+ Object.defineProperty(exports, '__esModule', {
65
+ value: true
69
66
  });
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
-
3
- type PluginGoogleAnalyticsOptions = {
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ export type PluginGoogleAnalyticsOptions = {
4
3
  /**
5
4
  * Google tag ID.
6
5
  */
@@ -11,6 +10,4 @@ type PluginGoogleAnalyticsOptions = {
11
10
  */
12
11
  enable?: boolean;
13
12
  };
14
- declare const pluginGoogleAnalytics: ({ id, enable, }: PluginGoogleAnalyticsOptions) => RsbuildPlugin;
15
-
16
- export { type PluginGoogleAnalyticsOptions, pluginGoogleAnalytics };
13
+ export declare const pluginGoogleAnalytics: ({ id, enable, }: PluginGoogleAnalyticsOptions) => RsbuildPlugin;
package/dist/index.js CHANGED
@@ -1,44 +1,32 @@
1
- // src/index.ts
2
- var pluginGoogleAnalytics = ({
3
- id,
4
- enable = true
5
- }) => ({
6
- name: "rsbuild-plugin-google-analytics",
7
- setup(api) {
8
- if (!enable) {
9
- return;
10
- }
11
- if (!id) {
12
- throw new Error(
13
- "[rsbuild-plugin-google-analytics] Google tag ID is required!"
14
- );
15
- }
16
- api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig }) => {
17
- const extraConfig = {
18
- html: {
19
- tags: [
20
- {
21
- tag: "script",
22
- attrs: {
23
- async: true,
24
- src: `https://www.googletagmanager.com/gtag/js?id=${id}`
25
- }
26
- },
27
- {
28
- tag: "script",
29
- children: `
1
+ const pluginGoogleAnalytics = ({ id, enable = true })=>({
2
+ name: 'rsbuild-plugin-google-analytics',
3
+ setup (api) {
4
+ if (!enable) return;
5
+ if (!id) throw new Error('[rsbuild-plugin-google-analytics] Google tag ID is required!');
6
+ api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig })=>{
7
+ const extraConfig = {
8
+ html: {
9
+ tags: [
10
+ {
11
+ tag: "script",
12
+ attrs: {
13
+ async: true,
14
+ src: `https://www.googletagmanager.com/gtag/js?id=${id}`
15
+ }
16
+ },
17
+ {
18
+ tag: "script",
19
+ children: `
30
20
  window.dataLayer = window.dataLayer || [];
31
21
  function gtag(){dataLayer.push(arguments);}
32
22
  gtag('js', new Date());
33
23
  gtag('config', '${id}');`
34
- }
35
- ]
24
+ }
25
+ ]
26
+ }
27
+ };
28
+ return mergeRsbuildConfig(extraConfig, userConfig);
29
+ });
36
30
  }
37
- };
38
- return mergeRsbuildConfig(extraConfig, userConfig);
39
31
  });
40
- }
41
- });
42
- export {
43
- pluginGoogleAnalytics
44
- };
32
+ export { pluginGoogleAnalytics };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsbuild-plugin-google-analytics",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "repository": "https://github.com/rspack-contrib/rsbuild-plugin-google-analytics",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,27 +17,30 @@
17
17
  "files": [
18
18
  "dist"
19
19
  ],
20
+ "scripts": {
21
+ "build": "rslib build",
22
+ "dev": "rslib build --watch",
23
+ "prepare": "npm run build",
24
+ "bump": "npx bumpp"
25
+ },
20
26
  "devDependencies": {
21
- "@rsbuild/core": "^1.0.4",
22
- "@types/node": "^20.16.5",
23
- "prettier": "^3.3.3",
24
- "tsup": "^8.2.4",
25
- "typescript": "^5.6.2"
27
+ "@rsbuild/core": "^1.4.12",
28
+ "@rslib/core": "^0.11.0",
29
+ "@types/node": "^22.17.0",
30
+ "prettier": "^3.6.2",
31
+ "typescript": "^5.9.2"
26
32
  },
27
33
  "peerDependencies": {
28
- "@rsbuild/core": "0.x || 1.x || ^1.0.1-beta.0"
34
+ "@rsbuild/core": "1.x"
29
35
  },
30
36
  "peerDependenciesMeta": {
31
37
  "@rsbuild/core": {
32
38
  "optional": true
33
39
  }
34
40
  },
41
+ "packageManager": "pnpm@10.14.0",
35
42
  "publishConfig": {
36
43
  "access": "public",
37
44
  "registry": "https://registry.npmjs.org/"
38
- },
39
- "scripts": {
40
- "build": "tsup",
41
- "dev": "tsup --watch"
42
45
  }
43
- }
46
+ }
package/dist/index.d.cts DELETED
@@ -1,16 +0,0 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
-
3
- type PluginGoogleAnalyticsOptions = {
4
- /**
5
- * Google tag ID.
6
- */
7
- id: string;
8
- /**
9
- * Whether to enable Google Analytics.
10
- * @default true
11
- */
12
- enable?: boolean;
13
- };
14
- declare const pluginGoogleAnalytics: ({ id, enable, }: PluginGoogleAnalyticsOptions) => RsbuildPlugin;
15
-
16
- export { type PluginGoogleAnalyticsOptions, pluginGoogleAnalytics };