Skip to content

Commit

Permalink
update build config
Browse files Browse the repository at this point in the history
  • Loading branch information
timlrx committed Oct 22, 2022
1 parent 8d91f08 commit 1d9d815
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 30 deletions.
7 changes: 7 additions & 0 deletions .changeset/curvy-clocks-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@pliny/cli': patch
'@pliny/installer': patch
'pliny': patch
---

update build config
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ packages/pliny/seo
packages/pliny/ui
packages/pliny/utils
packages/pliny/chunk-*
packages/pliny/*.js
packages/pliny/*.d.ts

# misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion packages/installer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
"publishConfig": {
"access": "public"
}
}
}
12 changes: 7 additions & 5 deletions packages/installer/src/generators/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Enquirer from 'enquirer'
import { EventEmitter } from 'events'
import * as fs from 'fs-extra'
import j from 'jscodeshift'
import prettier from 'prettier'
import { create as createStore, Store } from 'mem-fs'
import { create as createEditor, Editor } from 'mem-fs-editor'
import { baseLogger, log } from '../logging'
Expand Down Expand Up @@ -49,7 +50,7 @@ const alwaysIgnoreFiles = [
'node_modules',
'.contentlayer',
]
const ignoredExtensions = ['.ico', '.png', '.jpg', 'jpeg']
const ignoredExtensions = ['.ico', '.png', '.jpg', '.jpeg']
const tsExtension = /\.(tsx?)$/
const codeFileExtensions = /\.(tsx?|jsx?)$/

Expand Down Expand Up @@ -163,6 +164,7 @@ export abstract class Generator<
this.store = createStore()
this.fs = createEditor(this.store)
this.enquirer = new Enquirer()
this.prettier = prettier
this.useTs =
typeof this.options.useTs === 'undefined'
? fs.existsSync(path.resolve('tsconfig.json'))
Expand Down Expand Up @@ -258,9 +260,7 @@ export abstract class Generator<
const additionalFilesToIgnore = this.filesToIgnore()
return ![...alwaysIgnoreFiles, ...additionalFilesToIgnore].includes(name)
})
try {
this.prettier = await import('prettier')
} catch {}

const prettierOptions = await this.prettier?.resolveConfig(sourcePath)

for (const filePath of paths) {
Expand Down Expand Up @@ -292,7 +292,9 @@ export abstract class Generator<
}
}
// Copy back node_modules
fs.moveSync(`${sourcePath}/node_modules`, `${this.options.destinationRoot}/node_modules`)
fs.moveSync(`${sourcePath}/node_modules`, `${this.getTargetDirectory()}/node_modules`, {
overwrite: true,
})
}

async preCommit(): Promise<void> {
Expand Down
19 changes: 11 additions & 8 deletions packages/pliny/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
"version": "0.0.6-beta.5",
"type": "module",
"exports": {
"./analytics": "./analytics/index.js",
"./comments": "./comments/index.js",
"./search": "./search/index.js",
"./config": "./config/index.js",
"./mdx-components": "./mdx-components/index.js",
"./mdx-plugins": "./mdx-plugins/index.js",
"./newsletter": "./newsletter/index.js",
"./seo": "./seo/index.js",
"./analytics": "./analytics.js",
"./analytics/*": "./analytics/*",
"./comments": "./comments.js",
"./comments/*": "./comments/*",
"./mdx-components": "./mdx-components.js",
"./mdx-plugins": "./mdx-plugins.js",
"./mdx-plugins/*": "./mdx-plugins/*",
"./newsletter": "./newsletter.js",
"./newsletter/*": "./newsletter/*",
"./search": "./search.js",
"./search/*": "./search/*",
"./ui/*": "./ui/*",
"./utils/*": "./utils/*"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/pliny/react-import.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/pliny/src/analytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './analytics/index'
1 change: 1 addition & 0 deletions packages/pliny/src/comments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './comments/index'
27 changes: 23 additions & 4 deletions packages/pliny/src/comments/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import dynamic from 'next/dynamic.js'
import { Disqus, DisqusConfig, DisqusProps } from './Disqus'
import { Giscus, GiscusConfig, GiscusProps } from './Giscus'
Expand Down Expand Up @@ -46,6 +45,26 @@ export interface CommentsProps {
slug?: string
}

const UtterancesComponent = dynamic<UtterancesProps>(
() => {
return import('./Utterances').then((mod) => mod.Utterances)
},
{ ssr: false }
)
const GiscusComponent = dynamic<GiscusProps>(
() => {
return import('./Giscus').then((mod) => mod.Giscus)
},
{ ssr: false }
)

const DisqusComponent = dynamic<DisqusProps>(
() => {
return import('./Disqus').then((mod) => mod.Disqus)
},
{ ssr: false }
)

/**
* Supports Giscus, Utterances or Disqus
* If you want to use a comments provider you have to add it to the
Expand All @@ -58,11 +77,11 @@ export interface CommentsProps {
export const Comments = ({ commentsConfig, slug }: CommentsProps) => {
switch (commentsConfig.provider) {
case 'giscus':
return <Giscus {...commentsConfig.giscusConfig} />
return <GiscusComponent {...commentsConfig.giscusConfig} />
case 'utterances':
return <Utterances {...commentsConfig.utterancesConfig} />
return <UtterancesComponent {...commentsConfig.utterancesConfig} />
case 'disqus':
return <Disqus slug={slug} {...commentsConfig.disqusConfig} />
return <DisqusComponent slug={slug} {...commentsConfig.disqusConfig} />
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AnalyticsConfig } from '../analytics'
import type { CommentsConfig } from '../comments'
import type { NewsletterConfig } from '../newsletter'
import type { SearchConfig } from '../search'
import type { AnalyticsConfig } from './analytics'
import type { CommentsConfig } from './comments'
import type { NewsletterConfig } from './newsletter'
import type { SearchConfig } from './search'

export interface CoreConfig {
title: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react'
import * as _jsx_runtime from 'react/jsx-runtime'
import ReactDOM from 'react-dom'
import { ComponentMap } from 'mdx-bundler/client'
import { coreContent } from '../utils/contentlayer'
import type { MDXDocument } from '../utils/contentlayer'
import { coreContent } from './utils/contentlayer'
import type { MDXDocument } from './utils/contentlayer'

export type { ComponentMap }

Expand Down
1 change: 1 addition & 0 deletions packages/pliny/src/mdx-plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './mdx-plugins/index'
1 change: 1 addition & 0 deletions packages/pliny/src/newsletter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './newsletter/index'
1 change: 1 addition & 0 deletions packages/pliny/src/search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './search/index'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from 'next/head.js'
import { useRouter } from 'next/router.js'
import type { CoreConfig } from '../config'
import { CoreContent, MDXBlog, MDXAuthor } from '../utils/contentlayer'
import type { CoreConfig } from './config'
import { CoreContent, MDXBlog, MDXAuthor } from './utils/contentlayer'

interface CommonSEOProps {
title: string
Expand Down
1 change: 0 additions & 1 deletion packages/pliny/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { defineConfig } from 'tsup'
export default defineConfig({
entry: ['src/**/*'],
format: 'esm',
// inject: ['./react-import.js'],
splitting: true,
treeshake: true,
dts: true,
Expand Down

0 comments on commit 1d9d815

Please sign in to comment.