Skip to content
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

Update package.json #27

Merged
merged 2 commits into from
May 25, 2022
Merged

Update package.json #27

merged 2 commits into from
May 25, 2022

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/vite-ssg@0.17.10_2a1f4eb68d7efe0f1402d91afc414ace/node_modules/vite-ssg/dist/node/cli.cjs:180:87)
    at async Object.handler (/Users/mykolas/Documents/Projects/the_cheat/node_modules/.pnpm/vite-ssg@0.17.10_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/vite-ssg@0.17.10_2a1f4eb68d7efe0f1402d91afc414ace/node_modules/vite-ssg/dist/node/cli.cjs:180:87)
    at async Object.handler (/Users/mykolas/Documents/Projects/the_cheat/node_modules/.pnpm/vite-ssg@0.17.10_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.

package.json Outdated Show resolved Hide resolved
Co-authored-by: Samuel MARLHENS <11817371+smarlhens@users.noreply.github.com>
@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