Skip to content

Commit e33ca30

Browse files
perf(core): export createCJSModule() to allow its use in the handleModule option
closes issue #70
1 parent 12543f7 commit e33ca30

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

docs/faq.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,26 @@ vue.use(myPlugin);
4141
If your plugin is hosted elsewhere (on a different origin), you have to define your own `option.pathResolve`.
4242
See https://github.com/FranckFreiburger/vue3-sfc-loader/blob/main/docs/examples.md#use-remote-components
4343

44+
45+
## How to speed-up loading when using large 3rd party libraries (like babylon.js, three.js, PixiJS, ...)
46+
47+
When you need to use a large 3rd party library that has **no further dependencies** and has an **CJS or UMD version** available, you can load it directly using the `handleModule` option.
48+
49+
example:
50+
```javascript
51+
52+
const { loadModule, createCJSModule } = window['vue3-sfc-loader'];
53+
54+
const options = {
55+
...
56+
async handleModule(type, getContentData, path, options) {
57+
58+
if ( path.toString().endsWith('babylon.max.js') )
59+
return createCJSModule(type, await getContentData(false), options)
60+
61+
return undefined;
62+
},
63+
...
64+
```
65+
66+
(see https://github.com/FranckFreiburger/vue3-sfc-loader/issues/70)

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const version : string = process.env.VERSION;
3232
export { vueVersion } from './createSFCModule'
3333

3434

35+
export { createCJSModule } from './tools'
3536

3637
/**
3738
* @internal

0 commit comments

Comments
 (0)