Skip to content

Commit 5dda6e1

Browse files
committed
fix: rollup, reading undefined
1 parent 80bec65 commit 5dda6e1

13 files changed

+51
-503
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ node_modules
33
dist
44
dist-ssr
55
*.local
6-
.nuxt
6+
.nuxt
7+
.output

demo/app.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
<script setup lang="ts">
2-
import { NotionRenderer, getPageBlocks } from "vue3-notion"
2+
import { getPageBlocks } from "vue3-notion"
33
import { onMounted, ref } from "vue"
44
import { useNuxtApp } from "#app"
5-
const blockMap = ref()
5+
import "../src/style.css"
6+
7+
const nuxtApp = useNuxtApp()
8+
const { data } = await useAsyncData("count", () => getPageBlocks("2e22de6b770e4166be301490f6ffd420"))
69
710
onMounted(async () => {
811
// react-notion tester: 2e22de6b770e4166be301490f6ffd420
912
// equation tester: 2a1d5226d68246deba627012081693f9
1013
// table tester: bd1de400a8b349dc824f4f00e61d0797
1114
// todo tester: 235057194b954a60ace89c052a65d102
12-
console.log(useNuxtApp())
13-
blockMap.value = await getPageBlocks("2e22de6b770e4166be301490f6ffd420")
1415
})
1516
</script>
1617

1718
<template>
18-
<div v-if="blockMap">
19-
<NotionRenderer :blockMap="blockMap" fullPage prism katex todo />
19+
<div v-if="data">
20+
<NotionRenderer :blockMap="data" fullPage prism katex todo />
2021
</div>
2122
</template>

demo/nuxt.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ export default defineNuxtConfig({
1414
// build: {
1515
// transpile: ["vue3-notion"],
1616
// },
17-
buildModules: ["vue3-notion/nuxt"],
17+
buildModules: ["../nuxt"],
1818
})

demo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
},
1111
"dependencies": {
1212
"nuxt3": "3.0.0-27274229.29599f0",
13-
"vue3-notion": "^0.0.8"
13+
"vue3-notion": "^0.0.9"
1414
}
1515
}

demo/tsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./.nuxt/tsconfig.json",
3+
"compilerOptions": {
4+
"target": "esnext",
5+
"module": "esnext",
6+
"moduleResolution": "node",
7+
"strict": true,
8+
"jsx": "preserve",
9+
"sourceMap": true,
10+
"resolveJsonModule": true,
11+
"esModuleInterop": true,
12+
"allowSyntheticDefaultImports": true,
13+
"lib": ["esnext", "dom"],
14+
"types": ["@nuxt/types"]
15+
}
16+
}

demo/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -5298,10 +5298,10 @@ vue-style-loader@^4.1.3:
52985298
hash-sum "^1.0.2"
52995299
loader-utils "^1.0.2"
53005300

5301-
vue3-notion@^0.0.8:
5302-
version "0.0.8"
5303-
resolved "https://registry.yarnpkg.com/vue3-notion/-/vue3-notion-0.0.%3Cspan%20class="x x-first x-last">8.tgz#3cfab03a40a00d799f57d74721c8b8db26c0a4e4"
5304-
integrity sha512-HH0JpvA1GeYAGIivmnid014Q2VkUOmsYACSi5qSl9lZNMDOS4psgE4IGdvGvcC/CKS/rMQE7/4aSpzng6991yQ==
5301+
vue3-notion@^0.0.9:
5302+
version "0.0.9"
5303+
resolved "https://registry.yarnpkg.com/vue3-notion/-/vue3-notion-0.0.%3Cspan%20class="x x-first x-last">9.tgz#251db1ba123a86aab1f5870ab538bd889ae3ea51"
5304+
integrity sha512-zKnuTfVDteoVJ4ZPv9bILZI2CU28WjrlZSPKfsrvF2Kku4OgDryRRi217upJjan2Bcibb15ae5+HgEzOO3gzlA==
53055305
dependencies:
53065306
fragment-for-vue "^1.0.1"
53075307
katex "^0.15.1"

nuxt/index.ts

-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default defineNuxtModule({
88
setup(options, nuxt) {
99
const filename = fileURLToPath(import.meta.url)
1010
const __dirname = dirname(filename)
11-
console.log(__dirname)
1211
addPluginTemplate({
1312
src: resolve(__dirname, "plugin.ts"),
1413
filename: "vue3-notion.ts",
@@ -22,5 +21,3 @@ export default defineNuxtModule({
2221
})
2322
},
2423
})
25-
26-
module.exports.meta = require("../package.json")

nuxt/plugin.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import VueNotion from "vue3-notion"
22
import { getPageBlocks, getPageTable } from "vue3-notion"
3-
import "vue3-notion/dist/style.css"
43

54
export default (nuxtApp) => {
65
const notion = { getPageBlocks, getPageTable }

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue3-notion",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "Vue 3 Unofficial Notion Renderer",
55
"repository": "github:zernonia/vue3-notion",
66
"main": "dist/library.ts",
@@ -28,7 +28,6 @@
2828
"fragment-for-vue": "^1.0.1",
2929
"katex": "^0.15.1",
3030
"prismjs": "^1.25.0",
31-
"unbuild": "^0.6.7",
3231
"vue": "^3.2.26"
3332
},
3433
"devDependencies": {
@@ -51,6 +50,9 @@
5150
"vue-tsc": "^0.29.8"
5251
},
5352
"peerDependencies": {
54-
"vue": "^3.2.20"
53+
"vue": "^3.2.20",
54+
"fragment-for-vue": "^1.0.1",
55+
"katex": "^0.15.1",
56+
"prismjs": "^1.25.0"
5557
}
5658
}

rollup.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const plugins = [
2222
replace({
2323
"process.env.NODE_ENV": JSON.stringify("production"),
2424
"process.env.ES_BUILD": JSON.stringify("false"),
25+
preventAssignment: true,
2526
}),
2627
alias({
2728
entries: {
@@ -40,6 +41,7 @@ export default [
4041
format: "esm",
4142
name: "Vue3Notion",
4243
file: "dist/library.ts",
44+
exports: "named",
4345
},
4446
],
4547
external,
@@ -53,6 +55,7 @@ export default [
5355
format: "cjs",
5456
name: "Vue3Notion",
5557
file: "dist/library.ssr.ts",
58+
exports: "named",
5659
globals,
5760
},
5861
],
@@ -67,6 +70,7 @@ export default [
6770
format: "iife",
6871
name: "Vue3Notion",
6972
file: "dist/min.js",
73+
exports: "named",
7074
globals,
7175
},
7276
plugins: [vue(), ...plugins],

src/blocks/code.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const langClass = computed(() => {
1717
})
1818
1919
const supported = computed(() => {
20-
return Prism.languages[lang.value]
20+
return Prism?.languages[lang.value]
2121
})
2222
</script>
2323

src/blocks/helpers/prism.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const props = defineProps({
1818
})
1919
2020
const { code, inline, language } = toRefs(props)
21-
const prismLanguage = Prism.languages[language.value]
21+
const prismLanguage = computed(() => Prism?.languages[language.value])
2222
const className = computed(() => `language-${language.value}`)
2323
2424
const d = computed(() => Prism.highlight(code?.value, prismLanguage, "en"))

0 commit comments

Comments
 (0)