Skip to content

Commit

Permalink
RICT-5442 - Fix Workers Configuration to take inputs into considerati…
Browse files Browse the repository at this point in the history
…on (#177)

* RICT-5442 - Fix Workers Configuration to take inputs into consideration

* Upgrade versions

* Update ViewGenerator.targets

* Update Helpers.ts
  • Loading branch information
heldergoncalves92 authored Feb 22, 2024
1 parent cebd8f1 commit 45294b8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageVersion Include="WebViewControl-WPF" Version="$(WebViewVersion)" />
<PackageVersion Include="WebViewControl-WPF-ARM64" Version="$(WebViewVersion)" />

<PackageVersion Include="ViewGenerator" Version="1.1.42" />
<PackageVersion Include="ViewGenerator" Version="1.1.43" />
<PackageVersion Include="ViewGeneratorCore" Version="1.0.229" />

<PackageVersion Include="NLog" Version="4.6.2" />
Expand Down
2 changes: 1 addition & 1 deletion ViewGenerator/ViewGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyTitle>ViewGenerator</AssemblyTitle>
<Product>ViewGenerator</Product>
<Description>Generates .NET View bindings from typescript</Description>
<Version>1.1.43</Version>
<Version>1.1.44</Version>
<PackageId>ViewGenerator</PackageId>
<PackageTags>Library</PackageTags>

Expand Down
2 changes: 1 addition & 1 deletion ViewGenerator/build/ViewGenerator.targets
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

<!-- Workers related target -->
<Target Name="VG_GenerateWorkersBundle" >
<Exec Command="node &quot;$(ViewPackerToolScript)&quot; --config=&quot;$(ViewGeneratorToolsPath)/webpack/webpack_workers.config.js&quot; --mode=$(WP_Mode) --devtool=$(WP_DevTool) --env useCache=$(WP_UseCache)" />
<Exec Command="node &quot;$(ViewPackerToolScript)&quot; --config=&quot;$(ViewGeneratorToolsPath)/webpack/webpack_workers.config.js&quot; --mode=$(WP_Mode) --devtool=$(WP_DevTool) --env useCache=$(WP_UseCache) --env entryPath='@(Workers)'" />
</Target>

<!-- /// -->
Expand Down
17 changes: 17 additions & 0 deletions ViewGenerator/tools/webpack/Helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Dictionary, sanitizeCommandLineParam} from "./Plugins/Utils";

const getEntryName = (entryPath: string): string => {
const fileExtensionLen: number = entryPath.length - entryPath.lastIndexOf(".");
return entryPath.slice(entryPath.replace(/\//g, '\\').lastIndexOf("\\") + 1, -fileExtensionLen);
};

export function getEntries(entries: string): Dictionary<string>{
const entryMap: Dictionary<string> = {};
const sanitizeEntries = sanitizeCommandLineParam(entries);

sanitizeEntries.split(";").map(entryPath => {
entryMap[getEntryName(entryPath)] = './' + entryPath;
});

return entryMap;
}
15 changes: 3 additions & 12 deletions ViewGenerator/tools/webpack/webpack_stylesheets.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@ import { Configuration } from "webpack";

import MiniCssExtractPluginCleanup from "./Plugins/MiniCssExtractPluginCleanup";
import { CssPlaceholder, JsMapPlaceholder, OutputDirectoryDefault } from "./Plugins/Resources";
import { Dictionary, getCurrentDirectory, sanitizeCommandLineParam } from "./Plugins/Utils"
import { getCurrentDirectory, sanitizeCommandLineParam } from "./Plugins/Utils"

import getResourcesRuleSet from "./Rules/Files";
import SassRuleSet from "./Rules/Sass";
import { getEntries } from "./Helpers";

const config = (env) => {

const getEntryName = (entryPath: string): string => {
const fileExtensionLen: number = entryPath.length - entryPath.lastIndexOf(".");
return entryPath.slice(entryPath.replace(/\//g, '\\').lastIndexOf("\\") + 1, -fileExtensionLen);
};

let entries: string = sanitizeCommandLineParam(env.entryPath);
let entryMap: Dictionary<string> = {};
entries.split(";").map(entryPath => entryMap[getEntryName(entryPath)] = './' + entryPath)

const stylesheetsConfig: Configuration = {
entry: entryMap,
entry: getEntries(env.entryPath),

output: {
path: getCurrentDirectory(),
Expand Down
22 changes: 7 additions & 15 deletions ViewGenerator/tools/webpack/webpack_workers.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { sync } from "glob";
import { parse, resolve } from "path";
import { resolve } from "path";
import { getCurrentDirectory } from "./Plugins/Utils";
import {Configuration} from "webpack";
import { Configuration } from "webpack";
import { getEntries } from "./Helpers";

const config = (env) => {

let entryMap = {};

sync("**/*.worker.js", { follow: true }).forEach(f => {
let entryName: string = parse(f).name;
entryMap[entryName] = "./" + f;
});

const workersConfig: Configuration = {
entry: entryMap,
entry: getEntries(env.entryPath),

optimization: {
minimize: true
Expand All @@ -24,15 +16,15 @@ const config = (env) => {
path: resolve(getCurrentDirectory(), "Generated")
},
};

if (env.useCache === "true") {
workersConfig.cache = {
type: 'filesystem',
allowCollectingMemory: true,
name: "workersCache"
name: "workersCache"
}
}

return workersConfig;
};

Expand Down

0 comments on commit 45294b8

Please sign in to comment.