Skip to content

v0.4.0 #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e81ed3c
Move all packages into one
pomber Mar 4, 2022
94a6ec8
Fix typescript
pomber Mar 6, 2022
feba575
Add examples
pomber Mar 6, 2022
aed73bb
More typescript and rollup
pomber Mar 6, 2022
a65f3e2
Change root build
pomber Mar 6, 2022
49ad0ec
Better package exports
pomber Mar 6, 2022
4be8a20
Examples package jsons
pomber Mar 6, 2022
6abaadd
Adapt examples
pomber Mar 6, 2022
3c9f3f7
Patch mdx bundler
pomber Mar 24, 2022
8964076
Reset code box-sizing
pomber Mar 27, 2022
d99ba02
Add build script to examples
pomber Mar 27, 2022
3ea6ac5
Add test script [skip ci]
pomber Mar 27, 2022
13d428f
Update release.yml
pomber Mar 27, 2022
4b940f2
Merge pull request #147 from code-hike/monopackage
pomber Mar 27, 2022
c876789
Ditch mdx-bundler
pomber Mar 27, 2022
d029668
Try again
pomber Mar 27, 2022
edd2d99
And again
pomber Mar 27, 2022
b3b0c14
Try include files
pomber Mar 28, 2022
e25436e
Move to static props
pomber Mar 28, 2022
c9eef1a
Remove nft
pomber Mar 28, 2022
f4f8bc3
Styling
pomber Apr 10, 2022
c619e7f
Add debug link
pomber Apr 10, 2022
42f5a9c
Remove stuff
pomber Apr 10, 2022
ff73d54
Merge pull request #149 from code-hike/ch-test-site
pomber Apr 10, 2022
285c03a
Add index.browser.mjs
pomber Apr 10, 2022
ea2f836
Add browser example
pomber Apr 10, 2022
8cc8db8
Merge pull request #154 from code-hike/browser-example
pomber Apr 10, 2022
62e1438
Update version
pomber Apr 10, 2022
56a17ba
Fix longest line trim
pomber Apr 12, 2022
6989142
Merge pull request #155 from code-hike/fix-longestline-trim
pomber Apr 12, 2022
99e69b4
Rename esm to .mjs
pomber Apr 15, 2022
e6a2f13
Update demo
pomber Apr 15, 2022
16db849
Merge pull request #157 from code-hike/mjs-exports
pomber Apr 15, 2022
5110fab
Add docusaurus example
pomber Apr 18, 2022
44ddc11
Fix transparent color
pomber Apr 18, 2022
ab84287
Fix broken links
pomber Apr 18, 2022
f346520
Fix rollup warnings
pomber Apr 18, 2022
8b2228f
Merge pull request #158 from code-hike/docusaurus-example
pomber Apr 19, 2022
b300c02
Export internals
pomber Apr 19, 2022
3e82231
Create nextjs_bundle_analysis.yml
pomber Apr 20, 2022
4660d37
Add bundle-test
pomber Apr 20, 2022
6e65f8e
Update and rename nextjs_bundle_analysis.yml to bundle_analysis.yml
pomber Apr 20, 2022
f2c8e83
Merge pull request #159 from code-hike/export-internal
pomber Apr 20, 2022
e5088a2
Move imports to the end
pomber Apr 20, 2022
702ec28
Update bundle_analysis.yml
pomber Apr 20, 2022
1483cfe
Test bundle analyzer
pomber Apr 20, 2022
871eada
Only import if using code hike
pomber Apr 20, 2022
128998f
Add import depending on usage
pomber Apr 20, 2022
c5a6a24
Bundle client deps
pomber Apr 21, 2022
509154a
Add scrollytelling to next example
pomber Apr 21, 2022
5f08ee0
Merge pull request #160 from code-hike/smart-import
pomber Apr 21, 2022
a01263f
Add missing scritps
pomber Apr 22, 2022
b4445c4
Add support for bash-like comments
pomber Apr 22, 2022
0a40a80
Merge pull request #163 from code-hike/python-comments
pomber Apr 22, 2022
e8a0e2f
Fix preview width
pomber Apr 28, 2022
b9b2237
Merge pull request #165 from code-hike/fix-preview-width
pomber Apr 28, 2022
374d73d
Merge branch 'main' into next
pomber Apr 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/bundle_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: 'Bundle Analysis'

on:
pull_request:
push:
branches:
- next # change this if your default branch is named differently
workflow_dispatch:

defaults:
run:
# change this if your nextjs app does not live at the root of the repo
working-directory: .

jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: yarn-deps-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-deps-${{ hashFiles('yarn.lock') }}

- name: Build library
run: |
yarn install --frozen-lockfile 2>&1 | grep -v '^[warning|info]'
yarn build:lib

- name: Restore next build
uses: actions/cache@v2
id: restore-build-cache
env:
cache-name: cache-next-build
with:
# if you use a custom build directory, replace all instances of `.next` in this file with your build directory
# ex: if your app builds to `dist`, replace `.next` with `dist`
path: ./examples/bundle-test/.next/cache
# change this if you prefer a more strict cache
key: ${{ runner.os }}-build-${{ env.cache-name }}

- name: Build next.js app
working-directory: ./examples/bundle-test
# change this if your site requires a custom build command
run: yarn build

# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
- name: Analyze bundle
working-directory: ./examples/bundle-test
run: npx -p nextjs-bundle-analysis report

- name: Upload bundle
uses: actions/upload-artifact@v2
with:
name: bundle
path: ./examples/bundle-test/.next/analyze/__bundle_analysis.json

- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2
if: success() && github.event.number
with:
workflow: bundle_analysis.yml
branch: ${{ github.event.pull_request.base.ref }}
path: ./examples/bundle-test/.next/analyze/base

# And here's the second place - this runs after we have both the current and
# base branch bundle stats, and will compare them to determine what changed.
# There are two configurable arguments that come from package.json:
#
# - budget: optional, set a budget (bytes) against which size changes are measured
# it's set to 350kb here by default, as informed by the following piece:
# https://infrequently.org/2021/03/the-performance-inequality-gap/
#
# - red-status-percentage: sets the percent size increase where you get a red
# status indicator, defaults to 20%
#
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
# entry in your package.json file.
- name: Compare with base branch bundle
working-directory: ./examples/bundle-test
if: success() && github.event.number
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare

- name: Get comment body
working-directory: ./examples/bundle-test
id: get-comment-body
if: success() && github.event.number
run: |
body=$(cat .next/analyze/__bundle_analysis_comment.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body

- name: Find Comment
uses: peter-evans/find-comment@v1
if: success() && github.event.number
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: '<!-- __NEXTJS_BUNDLE -->'

- name: Create Comment
uses: peter-evans/[email protected]
if: success() && github.event.number && steps.fc.outputs.comment-id == 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}

- name: Update Comment
uses: peter-evans/[email protected]
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 10 # 👈 Required to retrieve git history

- name: Prepare repository
run: git fetch --unshallow --tags
Expand All @@ -35,6 +33,7 @@ jobs:
run: |
yarn install --frozen-lockfile 2>&1 | grep -v '^[warning|info]'
yarn build
yarn test
yarn release
# - name: Publish to Chromatic
# uses: chromaui/action@v1
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ yarn-error.log
.vscode
storybook-static
packages/playground/out
packages/starter
packages/starter

# Contentlayer
.contentlayer
9 changes: 0 additions & 9 deletions .gitpod.yml

This file was deleted.

11 changes: 11 additions & 0 deletions examples/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"semi": false,
"overrides": [
{
"files": "*.md",
"options": {
"parser": "mdx"
}
}
]
}
42 changes: 42 additions & 0 deletions examples/browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<title>Code Hike in the browser</title>
<link
rel="stylesheet"
href="https://esm.sh/@code-hike/[email protected]/dist/index.css"
/>
</head>
<body>
<div id="root"></div>

<script type="module">
import React from "https://esm.sh/react"
import ReactDOM from "https://esm.sh/react-dom"
import { evaluate } from "https://esm.sh/@mdx-js/mdx?dev"
import * as runtime from "https://esm.sh/react/jsx-runtime.js"

import { remarkCodeHike } from "https://esm.sh/@code-hike/[email protected]/dist/index.browser.mjs"
import { CH } from "https://esm.sh/@code-hike/[email protected]/components"
import theme from "https://esm.sh/[email protected]/themes/nord.json" assert { type: "json" }

const mdx = `# Test

~~~python hello.py mark=1[22:30]
print("Rendered with Code Hike")
~~~
`

const { default: Content } = await evaluate(mdx, {
...runtime,
remarkPlugins: [[remarkCodeHike, { autoImport: false, theme }]],
})

const App = () => {
return React.createElement(Content, { components: { CH } })
}

ReactDOM.render(React.createElement(App), document.getElementById("root"))
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions examples/bundle-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.next
13 changes: 13 additions & 0 deletions examples/bundle-test/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { remarkCodeHike } = require("@code-hike/mdx")
const theme = require("shiki/themes/nord.json")

const withMDX = require("@next/mdx")({
extension: /\.mdx?$/,
options: {
remarkPlugins: [[remarkCodeHike, { theme }]],
},
})

module.exports = withMDX({
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
})
23 changes: 23 additions & 0 deletions examples/bundle-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "bundle-test",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "next",
"build": "next build"
},
"dependencies": {
"@code-hike/mdx": "^0.3.0",
"@mdx-js/loader": "^2.0.0",
"@next/mdx": "^12.1.0",
"next": "^12.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"nextBundleAnalysis": {
"budget": 358400,
"budgetPercentIncreaseRed": 20,
"showDetails": true,
"minimumChangeThreshold": 0
}
}
7 changes: 7 additions & 0 deletions examples/bundle-test/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "@code-hike/mdx/styles"

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}

export default MyApp
8 changes: 8 additions & 0 deletions examples/bundle-test/pages/js-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function Page() {
return (
<div>
<h1>Hello</h1>
Lorem ipsum dolor sit amet. Consectetur adipiscing elit.
</div>
)
}
9 changes: 9 additions & 0 deletions examples/bundle-test/pages/just-code.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Hello world

```js focus=2,4[10:13]
function lorem(ipsum, dolor = 1) {
const sit = ipsum == null ? 0 : ipsum.sit
dolor = sit - amet(dolor)
return sit ? consectetur(ipsum) : []
}
```
3 changes: 3 additions & 0 deletions examples/bundle-test/pages/no-ch-mdx.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Hello

Lorem ipsum dolor sit amet. Consectetur adipiscing elit.
Loading