Skip to content

Conversation

Neophen
Copy link
Contributor

@Neophen Neophen commented Feb 11, 2022

There is an issue when trying to use this with vite-ssg:

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
file:///Users/mykolas/Documents/Projects/the_cheat/.vite-ssg-temp/main.mjs:29
import hljsVuePlugin from "@highlightjs/vue-plugin";
       ^^^^^^^^^^^^^
SyntaxError: The requested module '@highlightjs/vue-plugin' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:193:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async build (/Users/mykolas/Documents/Projects/the_cheat/node_modules/.pnpm/[email protected]_2a1f4eb68d7efe0f1402d91afc414ace/node_modules/vite-ssg/dist/node/cli.cjs:180:87)
    at async Object.handler (/Users/mykolas/Documents/Projects/the_cheat/node_modules/.pnpm/[email protected]_2a1f4eb68d7efe0f1402d91afc414ace/node_modules/vite-ssg/dist/node/cli.cjs:314:3)

Adding these exports fixes it.

There is an issue when trying to use this with vite-ssg:
```
[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
file:///Users/mykolas/Documents/Projects/the_cheat/.vite-ssg-temp/main.mjs:29
import hljsVuePlugin from "@highlightjs/vue-plugin";
       ^^^^^^^^^^^^^
SyntaxError: The requested module '@highlightjs/vue-plugin' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:193:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async build (/Users/mykolas/Documents/Projects/the_cheat/node_modules/.pnpm/[email protected]_2a1f4eb68d7efe0f1402d91afc414ace/node_modules/vite-ssg/dist/node/cli.cjs:180:87)
    at async Object.handler (/Users/mykolas/Documents/Projects/the_cheat/node_modules/.pnpm/[email protected]_2a1f4eb68d7efe0f1402d91afc414ace/node_modules/vite-ssg/dist/node/cli.cjs:314:3)
```

Adding these exports fixes it.
package.json Outdated
"import": "./dist/highlightjs-vue.esm.min.js",
"types": "./dist/vue.d.ts"
},
"./*": "./*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line necessary?

Copy link

@smarlhens smarlhens May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodejs doc:

As a last resort, package encapsulation can be disabled entirely by creating an export for the root of the package "./*": "./*". This exposes every file in the package at the cost of disabling the encapsulation and potential tooling benefits this provides.

I'm not sure to understand why we need it, @Neophen can you elaborate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that is not neccasary :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove i& it's not necessary.

Co-authored-by: Samuel MARLHENS <[email protected]>
@joshgoebel joshgoebel merged commit f647a81 into highlightjs:main May 25, 2022
@Neophen Neophen deleted the patch-1 branch May 29, 2022 02:31
mklein994 added a commit to mklein994/playground-vue that referenced this pull request Oct 28, 2022
This fixes an issue with the dependency resolver not finding the correct
file. The commonJS one had an external reference to Vue, which doesn't
exist in this project, and was preventing tests with references to
`highlight.js` from even running. The ESM version doesn't, so it works
if it were specially aliased. Fortunately, this was fixed upstream here:
highlightjs/vue-plugin#27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants