Fix windows not being able to build new Feature packages (#7220)

* Add missing dev script

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Inline all shared scripts to make them work in all environments

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Switch to using deterministic fake for path.join in unit test

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Make multi export config for webpack not fail when used in windows

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

---------

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen authored and GitHub committed 2023-02-23 10:54:35 +02:00
1 parent f212c90b1a
commit a7181047d5
8 files changed
+20 -27

No files matched your search

@@ -15,9 +15,6 @@
},
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
"bin": {
"lens-test": "bin/test.sh"
},
"dependencies": {
"@swc/core": "^1.3.20",
"@swc/jest": "^0.2.23",
@@ -1,2 +0,0 @@
set -e
webpack $@
@@ -1 +0,0 @@
rm -rfv build
+1 -5
View File
@@ -15,12 +15,8 @@
},
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
"bin": {
"lens-build": "bin/build.sh",
"lens-remove-build": "bin/remove-build.sh"
},
"scripts": {
"test:unit": "lens-test"
"test:unit": "jest --coverage --runInBand"
},
"dependencies": {
"@types/webpack-env": "^1.18.0",
@@ -14,7 +14,7 @@ const {
} = require("lodash/fp");
const { pipeline } = require("@ogre-tools/fp");
module.exports = (packageJson, dependencies = { nodeConfig, reactConfig }) => {
module.exports = (packageJson, dependencies = { nodeConfig, reactConfig, joinPath: path.join }) => {
if (!packageJson.lensMultiExportConfig) {
throw new Error(
`Tried to get multi export config for package "${packageJson.name}" but configuration is missing.`
@@ -80,7 +80,9 @@ module.exports = (packageJson, dependencies = { nodeConfig, reactConfig }) => {
};
const toExpectedExport = (externalImportPath) => {
const entrypointPath = `./${path.join(
const posixJoinForPackageJson = path.posix.join;
const entrypointPath = `./${posixJoinForPackageJson(
"./dist",
externalImportPath,
"index.js"
@@ -89,7 +91,7 @@ const toExpectedExport = (externalImportPath) => {
return [
externalImportPath,
{
types: `./${path.join("./dist", externalImportPath, "index.d.ts")}`,
types: `./${posixJoinForPackageJson("./dist", externalImportPath, "index.d.ts")}`,
default: entrypointPath,
import: entrypointPath,
@@ -114,7 +116,7 @@ const toExportSpecificWebpackConfigFor =
output: {
...baseConfig.output,
path: path.join(baseConfig.output.path, externalImportPath),
path: dependencies.joinPath(baseConfig.output.path, externalImportPath),
},
};
};
@@ -1,4 +1,7 @@
import getMultiExportConfig from "./get-multi-export-config";
import path from 'path';
const joinPathFake = path.posix.join;
describe("get-multi-export-config", () => {
let actual;
@@ -52,6 +55,7 @@ describe("get-multi-export-config", () => {
actual = getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
joinPath: joinPathFake,
});
expect(actual).toEqual([
@@ -93,6 +97,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@@ -106,6 +111,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@@ -119,6 +125,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@@ -132,6 +139,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config for package "some-name" but configuration is missing.'
@@ -145,6 +153,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config for package "some-name" but build types "some-invalid" were not any of "node", "react".'
@@ -159,6 +168,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config for package "some-name" but entrypoint was missing for "./some-entrypoint".'
@@ -20,11 +20,9 @@
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
"scripts": {
"build": "lens-build",
"build:remove": "lens-remove-build",
"code-style:fix": "lens-fix-code-style",
"code-style:verify": "lens-verify-code-style",
"test": "lens-test"
"build": "webpack",
"dev": "webpack --mode=development --watch",
"test": "jest --coverage --runInBand"
},
"peerDependencies": {
"@ogre-tools/fp": "^12.0.1",