diff --git a/docs/api/.nojekyll b/docs/api/.nojekyll
new file mode 100644
index 0000000..e2ac661
--- /dev/null
+++ b/docs/api/.nojekyll
@@ -0,0 +1 @@
+TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
\ No newline at end of file
diff --git a/docs/api/README.md b/docs/api/README.md
index 7d03267..be391fd 100644
--- a/docs/api/README.md
+++ b/docs/api/README.md
@@ -1,421 +1,412 @@
-**[vue3-sfc-loader](README.md)**
-
-> Globals
+vue3-sfc-loader
# vue3-sfc-loader
-## Index
-
-### Type aliases
-
-* [AbstractPath](README.md#abstractpath)
-* [Cache](README.md#cache)
-* [ContentData](README.md#contentdata)
-* [CustomBlock](README.md#customblock)
-* [CustomBlockCallback](README.md#customblockcallback)
-* [File](README.md#file)
-* [LangProcessor](README.md#langprocessor)
-* [Module](README.md#module)
-* [ModuleCacheId](README.md#modulecacheid)
-* [ModuleExport](README.md#moduleexport)
-* [ModuleHandler](README.md#modulehandler)
-* [Options](README.md#options)
-* [PathContext](README.md#pathcontext)
-* [PathResolve](README.md#pathresolve)
-* [Resource](README.md#resource)
+## Table of contents
+
+### Type Aliases
+
+- [AbstractPath](README.md#abstractpath)
+- [Cache](README.md#cache)
+- [ContentData](README.md#contentdata)
+- [CustomBlock](README.md#customblock)
+- [CustomBlockCallback](README.md#customblockcallback)
+- [File](README.md#file)
+- [LangProcessor](README.md#langprocessor)
+- [Module](README.md#module)
+- [ModuleCacheId](README.md#modulecacheid)
+- [ModuleExport](README.md#moduleexport)
+- [ModuleHandler](README.md#modulehandler)
+- [Options](README.md#options)
+- [PathContext](README.md#pathcontext)
+- [PathResolve](README.md#pathresolve)
+- [Resource](README.md#resource)
### Variables
-* [version](README.md#version)
-* [vueVersion](README.md#vueversion)
+- [version](README.md#version)
+- [vueVersion](README.md#vueversion)
### Functions
-* [buildTemplateProcessor](README.md#buildtemplateprocessor)
-* [createSFCModule](README.md#createsfcmodule)
-* [defaultGetResource](README.md#defaultgetresource)
-* [defaultPathResolve](README.md#defaultpathresolve)
-* [handleModuleInternal](README.md#handlemoduleinternal)
-* [loadModule](README.md#loadmodule)
-* [loadModuleInternal](README.md#loadmoduleinternal)
+- [buildTemplateProcessor](README.md#buildtemplateprocessor)
+- [loadModule](README.md#loadmodule)
-### Object literals
+## Type Aliases
-* [targetBrowserBabelPlugins](README.md#targetbrowserbabelplugins)
+### AbstractPath
-## Type aliases
+Ƭ **AbstractPath**: `Object`
-### AbstractPath
+An abstract way to specify a path. It could be a simple string or a object like an URL. An AbstractPath must always be convertible to a string.
-Ƭ **AbstractPath**: { toString: () => string }
+#### Type declaration
-*Defined in [types.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L32)*
+| Name | Type |
+| :------ | :------ |
+| `toString` | () => `string` |
-An abstract way to specify a path. It could be a simple string or a object like an URL. An AbstractPath must always be convertible to a string.
+#### Defined in
-#### Type declaration:
-
-Name | Type |
------- | ------ |
-`toString` | () => string |
+[types.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L32)
___
-### Cache
+### Cache
+
+Ƭ **Cache**: `Object`
-Ƭ **Cache**: { get: (key: string) => Promise ; set: (key: string, value: string) => Promise }
+#### Type declaration
-*Defined in [types.ts:20](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L20)*
+| Name | Type |
+| :------ | :------ |
+| `get` | (`key`: `string`) => `Promise`\<`string`\> |
+| `set` | (`key`: `string`, `value`: `string`) => `Promise`\<`void`\> |
-#### Type declaration:
+#### Defined in
-Name | Type |
------- | ------ |
-`get` | (key: string) => Promise |
-`set` | (key: string, value: string) => Promise |
+[types.ts:20](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L20)
___
-### ContentData
+### ContentData
-Ƭ **ContentData**: string \| ArrayBuffer
+Ƭ **ContentData**: `string` \| `ArrayBuffer`
-*Defined in [types.ts:71](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L71)*
+#### Defined in
-___
+[types.ts:71](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L71)
-### CustomBlock
+___
-Ƭ **CustomBlock**: { attrs: Record ; content: string ; type: string }
+### CustomBlock
-*Defined in [types.ts:109](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L109)*
+Ƭ **CustomBlock**: `Object`
A custom block
-#### Type declaration:
+#### Type declaration
-Name | Type |
------- | ------ |
-`attrs` | Record |
-`content` | string |
-`type` | string |
+| Name | Type |
+| :------ | :------ |
+| `attrs` | `Record`\<`string`, `string` \| ``true``\> |
+| `content` | `string` |
+| `type` | `string` |
-___
+#### Defined in
+
+[types.ts:109](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L109)
-### CustomBlockCallback
+___
-Ƭ **CustomBlockCallback**: (component: [ModuleExport](README.md#moduleexport)) => void
+### CustomBlockCallback
-*Defined in [types.ts:103](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L103)*
+Ƭ **CustomBlockCallback**: (`component`: [`ModuleExport`](README.md#moduleexport)) => `void`
CustomBlockCallback function type
-___
+#### Type declaration
-### File
+▸ (`component`): `void`
-Ƭ **File**: { getContentData: (asBinary: Boolean) => Promise<[ContentData](README.md#contentdata)\> ; type: string }
+##### Parameters
-*Defined in [types.ts:77](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L77)*
+| Name | Type |
+| :------ | :------ |
+| `component` | [`ModuleExport`](README.md#moduleexport) |
-Represents a file content and the extension name.
+##### Returns
-#### Type declaration:
+`void`
-Name | Type | Description |
------- | ------ | ------ |
-`getContentData` | (asBinary: Boolean) => Promise<[ContentData](README.md#contentdata)\> | The content data accessor (request data as text of binary) |
-`type` | string | The content type (file extension name, eg. '.svg' ) |
+#### Defined in
-___
+[types.ts:103](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L103)
-### LangProcessor
+___
-Ƭ **LangProcessor**: (source: string, preprocessOptions?: any) => Promise \| string
+### File
-*Defined in [types.ts:439](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L439)*
+Ƭ **File**: `Object`
-___
+Represents a file content and the extension name.
-### Module
+#### Type declaration
-Ƭ **Module**: { exports: [ModuleExport](README.md#moduleexport) }
+| Name | Type | Description |
+| :------ | :------ | :------ |
+| `getContentData` | (`asBinary`: `Boolean`) => `Promise`\<[`ContentData`](README.md#contentdata)\> | The content data accessor (request data as text of binary) |
+| `type` | `string` | The content type (file extension name, eg. '.svg' ) |
-*Defined in [types.ts:128](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L128)*
+#### Defined in
-This just represents a loaded js module
+[types.ts:77](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L77)
-#### Type declaration:
+___
-Name | Type |
------- | ------ |
-`exports` | [ModuleExport](README.md#moduleexport) |
+### LangProcessor
-___
+Ƭ **LangProcessor**: (`source`: `string`, `preprocessOptions?`: `any`) => `Promise`\<`string`\> \| `string`
-### ModuleCacheId
+#### Type declaration
-Ƭ **ModuleCacheId**: string
+▸ (`source`, `preprocessOptions?`): `Promise`\<`string`\> \| `string`
-*Defined in [types.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L26)*
+##### Parameters
-___
+| Name | Type |
+| :------ | :------ |
+| `source` | `string` |
+| `preprocessOptions?` | `any` |
-### ModuleExport
+##### Returns
-Ƭ **ModuleExport**: {} \| null
+`Promise`\<`string`\> \| `string`
-*Defined in [types.ts:123](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L123)*
+#### Defined in
-This just represents a loaded js module exports
+[types.ts:446](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L446)
___
-### ModuleHandler
+### Module
-Ƭ **ModuleHandler**: (type: string, getContentData: File[\"getContentData\"], path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| null\>
+Ƭ **Module**: `Object`
-*Defined in [types.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L68)*
+This just represents a loaded js module
-Used by the library when it needs to handle a does not know how to handle a given file type (eg. `.json` files).
+#### Type declaration
-**`param`** The type of the file. It can be anything, but must be '.vue', '.js' or '.mjs' for vue, js and esm files.
+| Name | Type |
+| :------ | :------ |
+| `exports` | [`ModuleExport`](README.md#moduleexport) |
-**`param`** The method to get the content data of a file (text or binary). see [[ File['getContentData'] ]]
+#### Defined in
-**`param`** The path of the file
+[types.ts:128](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L128)
-**`param`** The options
+___
-**example:**
+### ModuleCacheId
-```javascript
- ...
- ...
-```
+Ƭ **ModuleCacheId**: `string`
-___
+#### Defined in
-### Options
-
-Ƭ **Options**: { additionalBabelParserPlugins?: babel\_ParserPlugin[] ; additionalBabelPlugins?: Record ; compiledCache?: [Cache](README.md#cache) ; delimiters?: [string, string] ; devMode?: boolean ; handleModule?: [ModuleHandler](README.md#modulehandler) ; isCustomElement: (tag: string) => boolean \| undefined ; moduleCache: Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> ; pathResolve: [PathResolve](README.md#pathresolve) ; whitespace?: \"preserve\" \| \"condense\" ; addStyle: (style: string, scopeId: string \| undefined) => void ; createCJSModule: (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) ; customBlockHandler?: (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> ; getFile: (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> ; getResource: (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) ; loadModule?: (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> ; log?: (type: string, ...data: any[]) => void ; processStyles: (srcRaw: string, lang: string \| undefined, filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise }
-
-*Defined in [types.ts:139](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L139)*
-
-#### Type declaration:
-
-Name | Type | Description |
------- | ------ | ------ |
-`additionalBabelParserPlugins?` | babel\_ParserPlugin[] | Additional babel parser plugins. [TBD] ```javascript ... ... ``` |
-`additionalBabelPlugins?` | Record | Additional babel plugins. [TBD] ```javascript ... ... ``` |
-`compiledCache?` | [Cache](README.md#cache) | [get](README.md#get)() and [set](README.md#set)() functions of this object are called when the lib needs to save or load already compiled code. get and set functions must return a `Promise` (or can be `async`). Since compilation consume a lot of CPU, is is always a good idea to provide this object. **example:** In the following example, we cache the compiled code in the browser's local storage. Note that local storage is a limited place (usually 5MB). Here we handle space limitation in a very basic way. Maybe (not tested), the following libraries may help you to gain more space [pako](https://github.com/nodeca/pako), [lz-string](https://github.com/pieroxy/lz-string/) ```javascript ... compiledCache: { set(key, str) { // naive storage space management for (;;) { try { // doc: https://developer.mozilla.org/en-US/docs/Web/API/Storage window.localStorage.setItem(key, str); break; } catch(ex) { // here we handle DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'XXX' exceeded the quota window.localStorage.removeItem(window.localStorage.key(0)); } } }, get(key) { return window.localStorage.getItem(key); }, }, ... ``` |
-`delimiters?` | [string, string] | Sets the delimiters used for text interpolation within the template. Typically this is used to avoid conflicting with server-side frameworks that also use mustache syntax. ```javascript ... `; // --> const options = { moduleCache: { vue: Vue }, getFile: () => vueContent, addStyle: () => {}, delimiters: ['[[[[', ']]]]'], } const app = Vue.createApp(Vue.defineAsyncComponent(() => window['vue3-sfc-loader'].loadModule('file.vue', options))); app.mount(document.body); ... ``` |
-`devMode?` | boolean | Set development mode prevent minification, allow debugger statement, |
-`handleModule?` | [ModuleHandler](README.md#modulehandler) | Handle additional module types (eg. '.svg', '.json' ). see [ModuleHandler](README.md#modulehandler) |
-`isCustomElement` | (tag: string) => boolean \| undefined | Specifies a check method to recognize native custom elements. see. https://vuejs.org/api/application.html#app-config-compileroptions-iscustomelement note: this option has no effect on vue2 |
-`moduleCache` | Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> | Initial cache that will contain resolved dependencies. All new modules go here. `vue` must initially be contained in this object. [moduleCache](README.md#modulecache) is mandatory and should be shared between options objects used for you application (note that you can also pass the same options object through multiple loadModule calls) It is recommended to provide a prototype-less object (`Object.create(null)`) to avoid potential conflict with `Object` properties (constructor, __proto__, hasOwnProperty, ...). * The library take the ownership of [moduleCache](README.md#modulecache) when [loadModule](README.md#loadmodule) is called. See also [[options.loadModule]]. **example:** ```javascript ... moduleCache: Object.assign(Object.create(null), { vue: Vue, }), ... ``` |
-`pathResolve` | [PathResolve](README.md#pathresolve) | Abstact path handling *(optional)* |
-`whitespace?` | \"preserve\" \| \"condense\" | Whitespace handling strategy see https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler#options |
-`addStyle` | (style: string, scopeId: string \| undefined) => void | - |
-`createCJSModule` | (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) | - |
-`customBlockHandler?` | (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> | - |
-`getFile` | (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> | - |
-`getResource` | (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) | - |
-`loadModule?` | (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> | - |
-`log?` | (type: string, ...data: any[]) => void | - |
-`processStyles` | (srcRaw: string, lang: string \| undefined, filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise | - |
+[types.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L26)
___
-### PathContext
+### ModuleExport
-Ƭ **PathContext**: { refPath: [AbstractPath](README.md#abstractpath) \| undefined ; relPath: [AbstractPath](README.md#abstractpath) }
+Ƭ **ModuleExport**: {} \| ``null``
-*Defined in [types.ts:41](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L41)*
-
-A PathContext represents a path (relPath) relative to an abolute path (refPath)
-Note that relPath is not necessary relative, but when it is, relPath is relative to refPath.
+This just represents a loaded js module exports
-#### Type declaration:
+#### Defined in
-Name | Type | Description |
------- | ------ | ------ |
-`refPath` | [AbstractPath](README.md#abstractpath) \| undefined | reference path |
-`relPath` | [AbstractPath](README.md#abstractpath) | relative to @refPath |
+[types.ts:123](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L123)
___
-### PathResolve
+### ModuleHandler
-Ƭ **PathResolve**: (pathCx: [PathContext](README.md#pathcontext)) => [AbstractPath](README.md#abstractpath)
+Ƭ **ModuleHandler**: (`type`: `string`, `getContentData`: [`File`](README.md#file)[``"getContentData"``], `path`: [`AbstractPath`](README.md#abstractpath), `options`: [`Options`](README.md#options)) => `Promise`\<[`ModuleExport`](README.md#moduleexport) \| ``null``\>
-*Defined in [types.ts:50](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L50)*
+Used by the library when it needs to handle a does not know how to handle a given file type (eg. `.json` files).
-relative to absolute module path resolution
+#### Type declaration
-___
+▸ (`type`, `getContentData`, `path`, `options`): `Promise`\<[`ModuleExport`](README.md#moduleexport) \| ``null``\>
-### Resource
+##### Parameters
-Ƭ **Resource**: { getContent: () => Promise<[File](README.md#file)\> ; id: [ModuleCacheId](README.md#modulecacheid) ; path: [AbstractPath](README.md#abstractpath) }
+| Name | Type | Description |
+| :------ | :------ | :------ |
+| `type` | `string` | The type of the file. It can be anything, but must be '.vue', '.js' or '.mjs' for vue, js and esm files. |
+| `getContentData` | [`File`](README.md#file)[``"getContentData"``] | The method to get the content data of a file (text or binary). see [[ File['getContentData'] ]] |
+| `path` | [`AbstractPath`](README.md#abstractpath) | The path of the file |
+| `options` | [`Options`](README.md#options) | The options **example:** ```javascript ... ... ``` |
-*Defined in [types.ts:88](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L88)*
+##### Returns
-Represents a resource.
+`Promise`\<[`ModuleExport`](README.md#moduleexport) \| ``null``\>
-#### Type declaration:
+#### Defined in
-Name | Type | Description |
------- | ------ | ------ |
-`getContent` | () => Promise<[File](README.md#file)\> | asynchronously get the content of the resource. Once you got the content, you can asynchronously get the data through the getContentData(asBinary) method. |
-`id` | [ModuleCacheId](README.md#modulecacheid) | 'abstract' unique id of the resource. This id is used as the key of the [[Options.moduleCache]] |
-`path` | [AbstractPath](README.md#abstractpath) | file path of the resource |
+[types.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L68)
-## Variables
+___
-### version
+### Options
+
+Ƭ **Options**: `Object`
+
+#### Type declaration
+
+| Name | Type | Description |
+| :------ | :------ | :------ |
+| `additionalBabelParserPlugins?` | `babel_ParserPlugin`[] | Additional babel parser plugins. [TBD] ```javascript ... ... ``` |
+| `additionalBabelPlugins?` | `Record`\<`string`, `any`\> | Additional babel plugins. [TBD] ```javascript ... ... ``` |
+| `compiledCache?` | [`Cache`](README.md#cache) | [[get]]() and [[set]]() functions of this object are called when the lib needs to save or load already compiled code. get and set functions must return a `Promise` (or can be `async`). Since compilation consume a lot of CPU, is is always a good idea to provide this object. **example:** In the following example, we cache the compiled code in the browser's local storage. Note that local storage is a limited place (usually 5MB). Here we handle space limitation in a very basic way. Maybe (not tested), the following libraries may help you to gain more space [pako](https://github.com/nodeca/pako), [lz-string](https://github.com/pieroxy/lz-string/) ```javascript ... compiledCache: { set(key, str) { // naive storage space management for (;;) { try { // doc: https://developer.mozilla.org/en-US/docs/Web/API/Storage window.localStorage.setItem(key, str); break; } catch(ex) { // here we handle DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'XXX' exceeded the quota window.localStorage.removeItem(window.localStorage.key(0)); } } }, get(key) { return window.localStorage.getItem(key); }, }, ... ``` |
+| `delimiters?` | [`string`, `string`] | Sets the delimiters used for text interpolation within the template. Typically this is used to avoid conflicting with server-side frameworks that also use mustache syntax. ```javascript ... `; // --> const options = { moduleCache: { vue: Vue }, getFile: () => vueContent, addStyle: () => {}, delimiters: ['[[[[', ']]]]'], } const app = Vue.createApp(Vue.defineAsyncComponent(() => window['vue3-sfc-loader'].loadModule('file.vue', options))); app.mount(document.body); ... ``` |
+| `devMode?` | `boolean` | Set development mode prevent minification, allow debugger statement, |
+| `getPathname` | (`path`: `string`) => `string` | by default, remove the search string in situation where you need to keep the path intact, use `getPathname: path => path` |
+| `handleModule?` | [`ModuleHandler`](README.md#modulehandler) | Handle additional module types (eg. '.svg', '.json' ). see [[ModuleHandler]] |
+| `isCustomElement` | (`tag`: `string`) => `boolean` \| `undefined` | Specifies a check method to recognize native custom elements. see. https://vuejs.org/api/application.html#app-config-compileroptions-iscustomelement note: this option has no effect on vue2 |
+| `moduleCache` | `Record`\<[`ModuleCacheId`](README.md#modulecacheid), `LoadingType`\<[`ModuleExport`](README.md#moduleexport)\> \| [`ModuleExport`](README.md#moduleexport)\> | Initial cache that will contain resolved dependencies. All new modules go here. `vue` must initially be contained in this object. [[moduleCache]] is mandatory and should be shared between options objects used for you application (note that you can also pass the same options object through multiple loadModule calls) It is recommended to provide a prototype-less object (`Object.create(null)`) to avoid potential conflict with `Object` properties (constructor, __proto__, hasOwnProperty, ...). * The library take the ownership of [[moduleCache]] when [[loadModule]] is called. See also [[options.loadModule]]. **example:** ```javascript ... moduleCache: Object.assign(Object.create(null), { vue: Vue, }), ... ``` |
+| `pathResolve` | [`PathResolve`](README.md#pathresolve) | Abstact path handling *(optional)* |
+| `whitespace?` | ``"preserve"`` \| ``"condense"`` | Whitespace handling strategy see https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler#options |
+| `addStyle` | (`style`: `string`, `scopeId`: `string`) => `void` | Called by the library when CSS style must be added in the HTML document. |
+| `createCJSModule` | (`refPath`: [`AbstractPath`](README.md#abstractpath), `source`: `string`, `options`: [`Options`](README.md#options)) => [`Module`](README.md#module) | creates a CommonJS module from JS source string. *(optional)* |
+| `customBlockHandler?` | (`block`: [`CustomBlock`](README.md#customblock), `filename`: [`AbstractPath`](README.md#abstractpath), `options`: [`Options`](README.md#options)) => `Promise`\<[`CustomBlockCallback`](README.md#customblockcallback)\> | Called for each custom block. |
+| `getFile` | (`path`: [`AbstractPath`](README.md#abstractpath)) => `Promise`\<[`File`](README.md#file) \| [`ContentData`](README.md#contentdata)\> | Called by the library when it needs a file. |
+| `getResource` | (`pathCx`: [`PathContext`](README.md#pathcontext), `options`: [`Options`](README.md#options)) => [`Resource`](README.md#resource) | Abstact resource handling *(optional)* |
+| `loadModule?` | (`path`: [`AbstractPath`](README.md#abstractpath), `options`: [`Options`](README.md#options)) => `Promise`\<{}\> | Called when the lib requires a module. Do return `undefined` to let the library handle this. |
+| `log?` | (`type`: `string`, ...`data`: `any`[]) => `void` | Called by the library when there is somthing to log (eg. scripts compilation errors, template compilation errors, template compilation tips, style compilation errors, ...) |
+| `processStyles` | (`srcRaw`: `string`, `lang`: `string`, `filename`: [`AbstractPath`](README.md#abstractpath), `options`: [`Options`](README.md#options)) => `Promise`\<`string`\> | |
+
+#### Defined in
+
+[types.ts:139](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L139)
-• `Const` **version**: string = process.env.VERSION as string
+___
-*Defined in [tools.ts:49](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L49)*
+### PathContext
-*Defined in [index.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L26)*
+Ƭ **PathContext**: `Object`
-the version of the library (process.env.VERSION is set by webpack, at compile-time)
+A PathContext represents a path (relPath) relative to an abolute path (refPath)
+Note that relPath is not necessary relative, but when it is, relPath is relative to refPath.
-___
+#### Type declaration
-### vueVersion
+| Name | Type | Description |
+| :------ | :------ | :------ |
+| `refPath` | [`AbstractPath`](README.md#abstractpath) \| `undefined` | reference path |
+| `relPath` | [`AbstractPath`](README.md#abstractpath) | relative to **`Ref Path`** |
-• `Const` **vueVersion**: string = process.env.VUE\_VERSION as string
+#### Defined in
-*Defined in [index.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L32)*
+[types.ts:41](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L41)
-the version of Vue that is expected by the library
+___
-## Functions
+### PathResolve
-### buildTemplateProcessor
+Ƭ **PathResolve**: (`pathCx`: [`PathContext`](README.md#pathcontext), `options`: [`Options`](README.md#options)) => [`AbstractPath`](README.md#abstractpath)
-▸ **buildTemplateProcessor**(`processor`: [LangProcessor](README.md#langprocessor)): object
+relative to absolute module path resolution
-*Defined in [index.ts:194](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L194)*
+#### Type declaration
-Convert a function to template processor interface (consolidate)
+▸ (`pathCx`, `options`): [`AbstractPath`](README.md#abstractpath)
-#### Parameters:
+##### Parameters
-Name | Type |
------- | ------ |
-`processor` | [LangProcessor](README.md#langprocessor) |
+| Name | Type |
+| :------ | :------ |
+| `pathCx` | [`PathContext`](README.md#pathcontext) |
+| `options` | [`Options`](README.md#options) |
-**Returns:** object
+##### Returns
-Name | Type |
------- | ------ |
-`render` | (source: string, preprocessOptions: string, cb: (\_err: any, \_res: any) => void) => void |
+[`AbstractPath`](README.md#abstractpath)
-___
+#### Defined in
-### createSFCModule
+[types.ts:50](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L50)
-▸ **createSFCModule**(`source`: string, `filename`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>
+___
-*Defined in [createSFCModule.ts:3](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/createSFCModule.ts#L3)*
+### Resource
-#### Parameters:
+Ƭ **Resource**: `Object`
-Name | Type |
------- | ------ |
-`source` | string |
-`filename` | [AbstractPath](README.md#abstractpath) |
-`options` | [Options](README.md#options) |
+Represents a resource.
-**Returns:** Promise<[ModuleExport](README.md#moduleexport)\>
+#### Type declaration
-___
+| Name | Type | Description |
+| :------ | :------ | :------ |
+| `getContent` | () => `Promise`\<[`File`](README.md#file)\> | asynchronously get the content of the resource. Once you got the content, you can asynchronously get the data through the getContentData(asBinary) method. |
+| `id` | [`ModuleCacheId`](README.md#modulecacheid) | 'abstract' unique id of the resource. This id is used as the key of the [[Options.moduleCache]] |
+| `path` | [`AbstractPath`](README.md#abstractpath) | file path of the resource |
+
+#### Defined in
-### defaultGetResource
+[types.ts:88](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/types.ts#L88)
-▸ **defaultGetResource**(`pathCx`: [PathContext](README.md#pathcontext), `options`: [Options](README.md#options)): [Resource](README.md#resource)
+## Variables
-*Defined in [index.ts:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L74)*
+### version
-Default getResource implementation
-by default, getContent() use the file extension as file type.
+• `Const` **version**: `string`
-#### Parameters:
+the version of the library (process.env.VERSION is set by webpack, at compile-time)
-Name | Type |
------- | ------ |
-`pathCx` | [PathContext](README.md#pathcontext) |
-`options` | [Options](README.md#options) |
+#### Defined in
-**Returns:** [Resource](README.md#resource)
+[index.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/index.ts#L26)
___
-### defaultPathResolve
+### vueVersion
-▸ `Const`**defaultPathResolve**(`__namedParameters`: { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) }): string \| [AbstractPath](README.md#abstractpath)
+• `Const` **vueVersion**: `string`
-*Defined in [index.ts:51](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L51)*
+the version of Vue that is expected by the library
-Default resolve implementation
-resolve() should handle 3 situations :
- - resolve a relative path ( eg. import './details.vue' )
- - resolve an absolute path ( eg. import '/components/card.vue' )
- - resolve a module name ( eg. import { format } from 'date-fns' )
+#### Defined in
-#### Parameters:
+[index.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/index.ts#L32)
-Name | Type |
------- | ------ |
-`__namedParameters` | { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) } |
+## Functions
-**Returns:** string \| [AbstractPath](README.md#abstractpath)
+### buildTemplateProcessor
-___
+▸ **buildTemplateProcessor**(`processor`): `Object`
-### handleModuleInternal
+Convert a function to template processor interface (consolidate)
-▸ **handleModuleInternal**(`type`: string, `getContentData`: File[\"getContentData\"], `path`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
+#### Parameters
-*Defined in [tools.ts:399](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L399)*
+| Name | Type |
+| :------ | :------ |
+| `processor` | [`LangProcessor`](README.md#langprocessor) |
-Default implementation of handleModule
+#### Returns
-#### Parameters:
+`Object`
-Name | Type |
------- | ------ |
-`type` | string |
-`getContentData` | File[\"getContentData\"] |
-`path` | [AbstractPath](README.md#abstractpath) |
-`options` | [Options](README.md#options) |
+| Name | Type |
+| :------ | :------ |
+| `render` | (`source`: `string`, `preprocessOptions`: `string`, `cb`: (`_err`: `any`, `_res`: `any`) => `void`) => `void` |
-**Returns:** Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
+#### Defined in
-___
+[index.ts:213](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/index.ts#L213)
-### loadModule
+___
-▸ **loadModule**(`path`: [AbstractPath](README.md#abstractpath), `options?`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>
+### loadModule
-*Defined in [index.ts:155](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L155)*
+▸ **loadModule**(`path`, `options?`): `Promise`\<[`ModuleExport`](README.md#moduleexport)\>
This is the main function.
This function is intended to be used only to load the entry point of your application.
If for some reason you need to use it in your components, be sure to share at least the options.`moduleCache` object between all calls.
-#### Parameters:
+#### Parameters
+
+| Name | Type | Description |
+| :------ | :------ | :------ |
+| `path` | [`AbstractPath`](README.md#abstractpath) | The path of the `.vue` file. If path is not a path (eg. an string ID), your [[getFile]] function must return a [[File]] object. |
+| `options` | [`Options`](README.md#options) | The options |
-Name | Type | Default value | Description |
------- | ------ | ------ | ------ |
-`path` | [AbstractPath](README.md#abstractpath) | - | The path of the `.vue` file. If path is not a path (eg. an string ID), your [getFile](README.md#getfile) function must return a [File](README.md#file) object. |
-`options` | [Options](README.md#options) | throwNotDefined('options') | The options |
+#### Returns
-**Returns:** Promise<[ModuleExport](README.md#moduleexport)\>
+`Promise`\<[`ModuleExport`](README.md#moduleexport)\>
A Promise of the component
@@ -450,29 +441,6 @@ A Promise of the component
```
-___
-
-### loadModuleInternal
-
-▸ **loadModuleInternal**(`pathCx`: [PathContext](README.md#pathcontext), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>
-
-*Defined in [tools.ts:276](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L276)*
-
-#### Parameters:
-
-Name | Type |
------- | ------ |
-`pathCx` | [PathContext](README.md#pathcontext) |
-`options` | [Options](README.md#options) |
-
-**Returns:** Promise<[ModuleExport](README.md#moduleexport)\>
-
-## Object literals
-
-### targetBrowserBabelPlugins
-
-▪ `Const` **targetBrowserBabelPlugins**: object
-
-*Defined in [tools.ts:211](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L211)*
+#### Defined in
-#### Properties:
+[index.ts:171](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/d633c5e/src/index.ts#L171)
diff --git a/docs/examples.md b/docs/examples.md
index 7058642..b8158d7 100644
--- a/docs/examples.md
+++ b/docs/examples.md
@@ -25,7 +25,7 @@ find [more examples here](https://github.com/FranckFreiburger/vue3-sfc-loader/di
# Examples
-:warning: **beware**, the following examples are sticky to version *0.9.4*. For your use, you would prefer the [latest version](../README.md#dist)
+:warning: **beware**, the following examples are sticky to version *0.9.5*. For your use, you would prefer the [latest version](../README.md#dist)
**Try the examples locally**
Since most browsers do not allow you to access local filesystem, you can start a small [express](https://expressjs.com/) server to run these examples.
@@ -68,7 +68,7 @@ In the following examples, for convenience, we just returns static content as fi
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+