vite-plugin-garfish-mf 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -8
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +0 -8
- package/dist/index.d.mts +0 -8
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install --save-dev vite-plugin-garfish-mf
|
|
|
12
12
|
|
|
13
13
|
### Getting Started
|
|
14
14
|
|
|
15
|
-
Add the plugin to sub-application's Vite configuration shown below (make sure the plugin is placed after the **react
|
|
15
|
+
Add the plugin to sub-application's Vite configuration shown below (make sure the plugin is placed after the **react** or **vue** plugin, if present):
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
18
|
// vite.config.js
|
|
@@ -24,18 +24,11 @@ import garfish from "vite-plugin-garfish-mf";
|
|
|
24
24
|
export default defineConfig({
|
|
25
25
|
plugins: [react(), garfish({
|
|
26
26
|
base: "http://localhost:3000",
|
|
27
|
-
sandbox: true
|
|
28
27
|
})
|
|
29
28
|
],
|
|
30
29
|
});
|
|
31
30
|
```
|
|
32
31
|
|
|
33
|
-
| Property | Prequire | Type | Default | Description |
|
|
34
|
-
| :---------: | :------: | :-----: | :-----------------------: | :--------------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
-
| **base** | [x] | string | **http://localhost:5173** | Base origin where the sub-application is served. Overrides server.port and server.origin |
|
|
36
|
-
| **sandbox** | [ ] | boolean | **true** | Enable this when running the sub-application inside a [Sandbox](https://www.garfishjs.org/api/run.html#sandbox) environment |
|
|
37
|
-
|
|
38
|
-
|
|
39
32
|
### How It Works
|
|
40
33
|
|
|
41
34
|
- Overrides Vite’s dev server origin so the sub-app can be correctly loaded by Garfish
|
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ function injectGarfishProvider(script$, publicPath) {
|
|
|
41
41
|
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/plugin.ts
|
|
44
|
-
const vitePluginGarfish = ({ base = "http://localhost:5173",
|
|
44
|
+
const vitePluginGarfish = ({ base = "http://localhost:5173", esModule = false }) => {
|
|
45
45
|
let config;
|
|
46
46
|
let isUseWithReact;
|
|
47
47
|
return [
|
|
@@ -71,7 +71,7 @@ const vitePluginGarfish = ({ base = "http://localhost:5173", sandbox = true, esM
|
|
|
71
71
|
transformIndexHtml(html) {
|
|
72
72
|
const $ = (0, cheerio.load)(html);
|
|
73
73
|
const moduleScripts$ = $("body script[src][type], head script[src]");
|
|
74
|
-
|
|
74
|
+
injectGarfishProvider(moduleScripts$.last(), base);
|
|
75
75
|
moduleScripts$.each((_, script$) => void scriptTransform($(script$), base));
|
|
76
76
|
if (isUseWithReact) {
|
|
77
77
|
const reactHMRScript = $("script:not([src])[type=module]").filter((_, el) => {
|
|
@@ -87,7 +87,7 @@ const vitePluginGarfish = ({ base = "http://localhost:5173", sandbox = true, esM
|
|
|
87
87
|
enforce: "post",
|
|
88
88
|
apply: "serve",
|
|
89
89
|
async transform(code) {
|
|
90
|
-
if (esModule) return null;
|
|
90
|
+
if (!esModule) return null;
|
|
91
91
|
const result = await (0, _swc_core.transform)(code, {
|
|
92
92
|
jsc: {
|
|
93
93
|
target: "es2018",
|
package/dist/index.d.cts
CHANGED
|
@@ -8,13 +8,6 @@ type Options = {
|
|
|
8
8
|
* More info https://vite.dev/config/shared-options#base
|
|
9
9
|
*/
|
|
10
10
|
base: string;
|
|
11
|
-
/**
|
|
12
|
-
* Set to `true` if you are running sub-app in sandbox environment
|
|
13
|
-
*
|
|
14
|
-
* Read more: https://www.garfishjs.org/api/run.html#sandbox
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
sandbox?: boolean;
|
|
18
11
|
/**
|
|
19
12
|
* Set to `true` if you are using plugin [GarfishEsModule](https://www.npmjs.com/package/@garfish/es-module)
|
|
20
13
|
*
|
|
@@ -23,7 +16,6 @@ type Options = {
|
|
|
23
16
|
};
|
|
24
17
|
declare const vitePluginGarfish: ({
|
|
25
18
|
base,
|
|
26
|
-
sandbox,
|
|
27
19
|
esModule
|
|
28
20
|
}: Options) => Plugin[];
|
|
29
21
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -8,13 +8,6 @@ type Options = {
|
|
|
8
8
|
* More info https://vite.dev/config/shared-options#base
|
|
9
9
|
*/
|
|
10
10
|
base: string;
|
|
11
|
-
/**
|
|
12
|
-
* Set to `true` if you are running sub-app in sandbox environment
|
|
13
|
-
*
|
|
14
|
-
* Read more: https://www.garfishjs.org/api/run.html#sandbox
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
sandbox?: boolean;
|
|
18
11
|
/**
|
|
19
12
|
* Set to `true` if you are using plugin [GarfishEsModule](https://www.npmjs.com/package/@garfish/es-module)
|
|
20
13
|
*
|
|
@@ -23,7 +16,6 @@ type Options = {
|
|
|
23
16
|
};
|
|
24
17
|
declare const vitePluginGarfish: ({
|
|
25
18
|
base,
|
|
26
|
-
sandbox,
|
|
27
19
|
esModule
|
|
28
20
|
}: Options) => Plugin[];
|
|
29
21
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -41,7 +41,7 @@ function injectGarfishProvider(script$, publicPath) {
|
|
|
41
41
|
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/plugin.ts
|
|
44
|
-
const vitePluginGarfish = ({ base = "http://localhost:5173",
|
|
44
|
+
const vitePluginGarfish = ({ base = "http://localhost:5173", esModule = false }) => {
|
|
45
45
|
let config;
|
|
46
46
|
let isUseWithReact;
|
|
47
47
|
return [
|
|
@@ -71,7 +71,7 @@ const vitePluginGarfish = ({ base = "http://localhost:5173", sandbox = true, esM
|
|
|
71
71
|
transformIndexHtml(html) {
|
|
72
72
|
const $ = load(html);
|
|
73
73
|
const moduleScripts$ = $("body script[src][type], head script[src]");
|
|
74
|
-
|
|
74
|
+
injectGarfishProvider(moduleScripts$.last(), base);
|
|
75
75
|
moduleScripts$.each((_, script$) => void scriptTransform($(script$), base));
|
|
76
76
|
if (isUseWithReact) {
|
|
77
77
|
const reactHMRScript = $("script:not([src])[type=module]").filter((_, el) => {
|
|
@@ -87,7 +87,7 @@ const vitePluginGarfish = ({ base = "http://localhost:5173", sandbox = true, esM
|
|
|
87
87
|
enforce: "post",
|
|
88
88
|
apply: "serve",
|
|
89
89
|
async transform(code) {
|
|
90
|
-
if (esModule) return null;
|
|
90
|
+
if (!esModule) return null;
|
|
91
91
|
const result = await transform(code, {
|
|
92
92
|
jsc: {
|
|
93
93
|
target: "es2018",
|