@posthog/rollup-plugin 1.1.14 → 1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA2C,MAAM,QAAQ,CAAA;AAC7E,OAAO,EAAiC,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAI/E,MAAM,WAAW,0BAA0B;IACvC,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,UAAU,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;CACJ;AAiBD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,WAAW,EAAE,0BAA0B,GA4E1E,MAAM,CACd"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA2C,MAAM,QAAQ,CAAA;AAC7E,OAAO,EAAiC,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAI/E,MAAM,WAAW,0BAA0B;IACvC,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,UAAU,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;CACJ;AAiBD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,WAAW,EAAE,0BAA0B,GAoF1E,MAAM,CACd"}
package/dist/index.js CHANGED
@@ -29,12 +29,14 @@ function posthogRollupPlugin(userOptions) {
29
29
  if (options.file) basePaths.push(path.dirname(options.file));
30
30
  for(const fileName in bundle){
31
31
  const chunk = bundle[fileName];
32
- if ('chunk' === chunk.type) {
32
+ const isJsFile = /\.(js|mjs|cjs)$/.test(fileName);
33
+ if ('chunk' === chunk.type && isJsFile) {
33
34
  const chunkPath = path.resolve(...basePaths, fileName);
34
35
  chunks[chunkPath] = chunk;
35
36
  args.push('--file', chunkPath);
36
37
  }
37
38
  }
39
+ if (0 === Object.keys(chunks).length) return void console.log('No chunks found, skipping sourcemap processing for this stage. Your build may be multi-stage and this stage may not be relevant');
38
40
  if (posthogOptions.sourcemaps.project) args.push('--project', posthogOptions.sourcemaps.project);
39
41
  if (posthogOptions.sourcemaps.version) args.push('--version', posthogOptions.sourcemaps.version);
40
42
  if (posthogOptions.sourcemaps.deleteAfterUpload) args.push('--delete-after');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/rollup-plugin",
3
- "version": "1.1.14",
3
+ "version": "1.2.0",
4
4
  "description": "PostHog Rollup plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,8 +15,8 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
- "@posthog/cli": "~0.5.20",
19
- "@posthog/core": "1.14.0"
18
+ "@posthog/cli": "~0.5.26",
19
+ "@posthog/core": "1.14.1"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "rollup": ">= 4.0.0"
package/src/index.ts CHANGED
@@ -68,13 +68,21 @@ export default function posthogRollupPlugin(userOptions: PostHogRollupPluginOpti
68
68
 
69
69
  for (const fileName in bundle) {
70
70
  const chunk = bundle[fileName]
71
- if (chunk.type === 'chunk') {
71
+ const isJsFile = /\.(js|mjs|cjs)$/.test(fileName)
72
+ if (chunk.type === 'chunk' && isJsFile) {
72
73
  const chunkPath = path.resolve(...basePaths, fileName)
73
74
  chunks[chunkPath] = chunk
74
75
  args.push('--file', chunkPath)
75
76
  }
76
77
  }
77
78
 
79
+ if (Object.keys(chunks).length === 0) {
80
+ console.log(
81
+ 'No chunks found, skipping sourcemap processing for this stage. Your build may be multi-stage and this stage may not be relevant'
82
+ )
83
+ return
84
+ }
85
+
78
86
  if (posthogOptions.sourcemaps.project) {
79
87
  args.push('--project', posthogOptions.sourcemaps.project)
80
88
  }