@vcmap/plugin-cli 3.0.0 → 3.0.1
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/package.json +1 -1
- package/src/build.js +1 -1
- package/src/hostingHelpers.js +2 -2
- package/src/packageJsonHelpers.js +12 -4
- package/src/serve.js +9 -1
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -44,7 +44,7 @@ export async function getLibraryPaths(pluginName) {
|
|
|
44
44
|
* @returns {Promise<void>}
|
|
45
45
|
*/
|
|
46
46
|
export default async function buildModule(options) {
|
|
47
|
-
const entry =
|
|
47
|
+
const entry = getEntry();
|
|
48
48
|
const pluginName = await getPluginName();
|
|
49
49
|
const libraryPaths = await getLibraryPaths(pluginName);
|
|
50
50
|
const distPath = path.join(getContext(), 'dist');
|
package/src/hostingHelpers.js
CHANGED
|
@@ -5,7 +5,7 @@ import fs from 'fs';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { logger } from '@vcsuite/cli-logger';
|
|
7
7
|
import { getContext, resolveContext } from './context.js';
|
|
8
|
-
import { getPluginName
|
|
8
|
+
import { getPluginName } from './packageJsonHelpers.js';
|
|
9
9
|
import { promiseExec, getDirname } from './pluginCliHelper.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -119,7 +119,7 @@ export async function printVcmapUiVersion() {
|
|
|
119
119
|
export async function reWriteAppConfig(appConfig, pluginConfig, production) {
|
|
120
120
|
const name = await getPluginName();
|
|
121
121
|
pluginConfig.name = name;
|
|
122
|
-
pluginConfig.entry = production ? 'dist/index.js' :
|
|
122
|
+
pluginConfig.entry = production ? 'dist/index.js' : 'src/index.js';
|
|
123
123
|
appConfig.modules = appConfig.modules ?? [];
|
|
124
124
|
appConfig.modules.forEach((config) => {
|
|
125
125
|
if (Array.isArray(config.plugins)) {
|
|
@@ -41,13 +41,21 @@ export async function getPluginName() {
|
|
|
41
41
|
return name;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Whether this is considered a TS plugin or not
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
export function isTS() {
|
|
49
|
+
const indexTs = resolveContext('src', 'index.ts');
|
|
50
|
+
return existsSync(indexTs);
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
/**
|
|
45
54
|
* Gets the entry of the package
|
|
46
|
-
* @returns {
|
|
55
|
+
* @returns {string}
|
|
47
56
|
*/
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
if (existsSync(isTS)) {
|
|
57
|
+
export function getEntry() {
|
|
58
|
+
if (isTS()) {
|
|
51
59
|
return 'src/index.ts';
|
|
52
60
|
}
|
|
53
61
|
return 'src/index.js';
|
package/src/serve.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
printVcmapUiVersion,
|
|
17
17
|
resolveMapUi,
|
|
18
18
|
} from './hostingHelpers.js';
|
|
19
|
-
import { getPackageJson, getPluginName } from './packageJsonHelpers.js';
|
|
19
|
+
import { getPackageJson, getPluginName, isTS } from './packageJsonHelpers.js';
|
|
20
20
|
import { getVcmConfigJs } from './pluginCliHelper.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -65,6 +65,13 @@ async function getProxy(protocol, port) {
|
|
|
65
65
|
delete proxy[hasThisPlugin];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
if (isTS()) {
|
|
69
|
+
proxy['/src/index.js'] = {
|
|
70
|
+
target: `http://localhost:${port}`,
|
|
71
|
+
rewrite: () => '/src/index.ts',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
// exampleData is not part of the @vcmap/ui package and must be proxied therefore
|
|
69
76
|
proxy['^/exampleData'] = {
|
|
70
77
|
target: 'https://raw.githubusercontent.com/virtualcitySYSTEMS/map-ui/main',
|
|
@@ -107,6 +114,7 @@ export default async function serve(options) {
|
|
|
107
114
|
|
|
108
115
|
logger.info('Starting development server...');
|
|
109
116
|
const proxy = await getProxy('http', port);
|
|
117
|
+
|
|
110
118
|
const { peerDependencies } = await getPackageJson();
|
|
111
119
|
|
|
112
120
|
const optimizationIncludes = [
|