You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modern bundlers will optimize out unused imported names. Importing the module directly will indicate that it is a side effect and should not be optimized out.
Fix#18
Copy file name to clipboardExpand all lines: README.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,14 +59,16 @@ Note: The plugin imports `highlight.js/lib/core` internally (but no languages).
59
59
You can also simply load all "common" languages at once (as of v11):
60
60
61
61
```js
62
-
importhljsfrom'highlight.js/lib/common';
62
+
import'highlight.js/lib/common';
63
63
importhljsVuePluginfrom"@highlightjs/vue-plugin";
64
64
65
65
constapp=createApp(App)
66
66
app.use(hljsVuePlugin)
67
67
app.mount('#app')
68
68
```
69
69
70
+
Note that the `highlight.js/lib/common` import does not import the `hljs` object because it registers common languages internally and modern web bundlers like `webpack` will optimize out unused imported names. If you want to customize the `hljs` object, you can import it like the [previous example](#using-es6-modules--bundling).
71
+
70
72
## Using component locally
71
73
72
74
```vue
@@ -78,7 +80,7 @@ app.mount('#app')
78
80
</template>
79
81
80
82
<script>
81
-
import hljs from 'highlight.js/lib/common';
83
+
import 'highlight.js/lib/common';
82
84
import hljsVuePlugin from "@highlightjs/vue-plugin";
0 commit comments