Skip to content

Commit

Permalink
Merge pull request #117 from timlrx/v2
Browse files Browse the repository at this point in the history
Update build process to work around nextjs issue
  • Loading branch information
timlrx authored Jul 17, 2023
2 parents 145d961 + f428075 commit 7a509c4
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-dolphins-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pliny': patch
---

Split all files except ui components so that they are default exported
1 change: 1 addition & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"pliny": "0.0.10"
},
"changesets": [
"dry-dolphins-burn",
"fuzzy-apples-judge",
"giant-geckos-dress",
"good-cheetahs-tap",
Expand Down
6 changes: 6 additions & 0 deletions packages/pliny/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# pliny

## 0.1.0-beta.9

### Patch Changes

- e669506: Split all files except ui components so that they are default exported

## 0.1.0-beta.8

### Patch Changes
Expand Down
8 changes: 8 additions & 0 deletions packages/pliny/add-use-client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ import globby from 'globby'
fs.writeFileSync(path, insert + data)
}
}
// Handle ui differently as they are not split
const clientPaths = await globby(['ui/NewsletterForm.js', 'ui/Pre.js'])
for (const path of clientPaths) {
console.log(path)
const data = fs.readFileSync(path)
const insert = Buffer.from('"use client"\n')
fs.writeFileSync(path, insert + data)
}
})()
6 changes: 3 additions & 3 deletions packages/pliny/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pliny",
"description": "Main entry point for pliny components",
"homepage": "https://github.com/timlrx/pliny",
"version": "0.1.0-beta.8",
"version": "0.1.0-beta.9",
"type": "module",
"exports": {
"./*": "./*",
Expand All @@ -18,8 +18,8 @@
"**"
],
"scripts": {
"dev": "tsup-node --watch && cp -fR dist/* ./ && rimraf dist && node add-use-client.mjs && yarn copyfiles",
"build": "rimraf dist && tsup && cp -fR dist/* ./ && rimraf dist && node add-use-client.mjs && yarn copyfiles",
"dev": "tsup && cp -fR dist/* ./ && tsup --config tsup.ui.config.ts && rimraf dist && node add-use-client.mjs",
"build": "tsup && cp -fR dist/* ./ && tsup --config tsup.ui.config.ts && rimraf dist && node add-use-client.mjs && yarn copyfiles",
"copyfiles": "copyfiles -f public/algolia.css search"
},
"author": "Timothy Lin <[email protected]> (https://timlrx.com)",
Expand Down
1 change: 1 addition & 0 deletions packages/pliny/src/analytics/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const GA = ({ googleAnalyticsId }: GoogleAnalyticsProps) => {

// https://developers.google.com/analytics/devguides/collection/gtagjs/events
export const logEvent = (action, category, label, value) => {
// @ts-ignore
window.gtag?.('event', action, {
event_category: category,
event_label: label,
Expand Down
2 changes: 2 additions & 0 deletions packages/pliny/src/comments/Disqus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ export const Disqus = ({ shortname, slug }: DisqusProps) => {
const COMMENTS_ID = 'disqus_thread'

const LoadComments = useCallback(() => {
//@ts-ignore
window.disqus_config = function () {
this.page.url = window.location.href
this.page.identifier = slug
}
//@ts-ignore
if (window.DISQUS === undefined) {
const script = document.createElement('script')
script.src = 'https://' + shortname + '.disqus.com/embed.js'
Expand Down
1 change: 1 addition & 0 deletions packages/pliny/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'tsup'
export default defineConfig({
entry: ['src/**/*'],
format: 'esm',
clean: true,
splitting: true,
treeshake: true,
dts: true,
Expand Down
14 changes: 14 additions & 0 deletions packages/pliny/tsup.ui.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'tsup'

// Do not split UI files as we want to use default export
// https://github.com/vercel/next.js/issues/52415
export default defineConfig({
entry: ['src/ui/*'],
format: 'esm',
outDir: 'ui',
clean: true,
splitting: false,
treeshake: true,
dts: true,
silent: true,
})

0 comments on commit 7a509c4

Please sign in to comment.