Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spfx-fast-serve

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spfx-fast-serve - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

6

CHANGELOG.md
# Change Log
## [2.0.2] - 06 May 2021
### Features
- simplified localized resource resolution process
## [2.0.1] - 05 May 2021

@@ -4,0 +10,0 @@

76

lib/templates/latest/webpack.js

@@ -233,3 +233,2 @@ const path = require("path");

const modulesMap = {};
const localizedPathMap = {};
const originalEntries = Object.keys(originalWebpackConfig.entry);

@@ -247,4 +246,2 @@

}
extractLocalizedPaths(jsModule.loaderConfig.scriptResources, localizedPathMap, localizedResources);
}

@@ -263,17 +260,8 @@ }

baseConfig.devServer.proxy = [{
target: host,
secure: false,
context: createProxyContext(localizedPathMap),
pathRewrite: pathRewrite(localizedPathMap)
}];
addCopyLocalizedResources(localizedResources);
if (settings.cli.isLibraryComponent) {
addCopyPlugin(localizedResources);
}
return baseConfig;
}
function addCopyPlugin(localizedResources) {
function addCopyLocalizedResources(localizedResources) {
const patterns = [];

@@ -298,62 +286,2 @@ for (const resourceKey in localizedResources) {

function extractLocalizedPaths(scriptResources, localizedPathMap, localizedResources) {
const resourceKeys = Object.keys(localizedResources);
for (const resourceKey of resourceKeys) {
if (!scriptResources[resourceKey]) {
continue;
}
const resource = scriptResources[resourceKey];
if (resource.path) {
const jsPath = resource.path;
const fileNameWithoutExt = path.basename(jsPath, ".js");
const underscoreIndex = fileNameWithoutExt.lastIndexOf("_");
const localeCode = fileNameWithoutExt.substr(underscoreIndex + 1);
localizedPathMap[jsPath] = {
locale: localeCode.toLowerCase(),
mapPath: localizedResources[resourceKey].replace(/^lib/gi, "src").replace("{locale}", localeCode.toLowerCase()) // src/webparts/helloWorld/loc/{locale}.js
};
}
if (resource.paths) {
for (const localeCode in resource.paths) {
const jsPath = resource.paths[localeCode];
localizedPathMap[jsPath] = {
locale: localeCode.toLowerCase(),
mapPath: localizedResources[resourceKey].replace(/^lib/gi, "src").replace("{locale}", localeCode.toLowerCase()) // src/webparts/helloWorld/loc/{locale}.js
};
}
}
}
}
function pathRewrite(localizedPathMap) {
return function (requestPath) {
const fileName = path.basename(requestPath);
// we should rewrite localized resource path
if (localizedPathMap[fileName]) {
const resource = localizedPathMap[fileName];
return "/" + resource.mapPath;
}
return requestPath;
}
}
// rewrite only .js files - all localization files
function createProxyContext(localizedPathMap) {
return function (requestPath) {
const fileName = path.basename(requestPath);
// if localized resource - HelloWorldWebPartStrings_en-us_<guid>.js - rewrite
if (localizedPathMap[fileName]) {
return true;
}
return false;
}
}
function getEntryPoints(entry) {

@@ -360,0 +288,0 @@ // fix: ".js" entry needs to be ".ts"

{
"name": "spfx-fast-serve",
"version": "2.0.1",
"version": "2.0.2",
"author": "Sergei Sergeev (https://github.com/s-KaiNet)",

@@ -5,0 +5,0 @@ "description": "Improve your SharePoint Framework development by speeding up 'serve' command",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc