Skip to content

Commit

Permalink
buildsystem 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-rodgers committed Feb 27, 2024
1 parent 2ae54c6 commit 65f1cca
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 84 deletions.
26 changes: 3 additions & 23 deletions buildsystem-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
WritePackageJSON,
Publish,
PublishNightly,
CreateResolutionPackageFiles,
} from "@pnp/buildsystem";
import {
Logger,
Expand Down Expand Up @@ -48,12 +47,11 @@ function PnPPackage(): (b: BuildTimeline) => BuildTimeline {
CopyAssetFiles(".", ["LICENSE"])(instance);
CopyAssetFiles("./packages", ["readme.md"])(instance);
CopyPackageFiles("built", ["**/*.d.ts", "**/*.js", "**/*.js.map", "**/*.d.ts.map"])(instance);
CreateResolutionPackageFiles()(instance),
WritePackageJSON((p) => {
return Object.assign({}, p, {
type: "module",
main: "./esm/index.js",
typings: "./esm/index",
main: "./index.js",
typings: "./index",
engines: {
node: ">=18.12.0"
},
Expand All @@ -69,19 +67,6 @@ function PnPPackage(): (b: BuildTimeline) => BuildTimeline {
type: "git",
url: "git:github.com/pnp/pnpjs"
},
exports: {
".": {
"import": {
"types": "./esm/index",
"default": "./esm/index.js"
},
"require": {
"types": "./commonjs/index",
"default": "./commonjs/index.js"
},
"default": "./esm/index.js"
}
},
maintainers: [
{
name: "patrick-rodgers",
Expand Down Expand Up @@ -121,14 +106,13 @@ function PnPPublish(flags?: string[]): (b: BuildTimeline) => BuildTimeline {

const commonBehaviors = [
PnPLogging(logLevel),
]
];

export default <BuildSchema[]>[{
name: "build",
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), ...commonBehaviors],
},
Expand All @@ -145,7 +129,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), ...commonBehaviors],
},
Expand All @@ -154,7 +137,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), PnPPublish(commonPublishTags), ...commonBehaviors],
},
Expand All @@ -163,7 +145,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), PnPPublish([...commonPublishTags, "--tag", "beta"]), ...commonBehaviors],
},
Expand All @@ -172,7 +153,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), PublishNightly([...commonPublishTags], "v4nightly"), ...commonBehaviors],
}];
2 changes: 1 addition & 1 deletion packages/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "../build/packages/esm"
"outDir": "../build/packages"
},
"include": [],
"references": [
Expand Down
1 change: 0 additions & 1 deletion tools/buildsystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export { Publish } from "./src/behaviors/publish.js";
export { ReplaceVersion, IReplaceVersionOptions } from "./src/behaviors/replace-version.js";
export { Webpack } from "./src/behaviors/webpack.js";
export { WritePackageJSON } from "./src/behaviors/write-packagejson.js";
export { CreateResolutionPackageFiles } from "./src/behaviors/create-resolution-package-files.js";

export {
BuildObserver,
Expand Down
2 changes: 1 addition & 1 deletion tools/buildsystem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pnp/buildsystem",
"version": "4.0.0-beta10",
"version": "4.0.0",
"bin": {
"pnpbuild": "bin/buildsystem.js"
},
Expand Down
1 change: 1 addition & 0 deletions tools/buildsystem/src/behaviors/copy-asset-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import buildCopyFile from "../lib/copy-file.js";

/**
* Copies files from a single location and to each project's dist folder
* @param path cwd path for the globby command
* @param pattern glob patterns for files (see https://www.npmjs.com/package/globby)
* @returns
*/
Expand Down
13 changes: 11 additions & 2 deletions tools/buildsystem/src/behaviors/copy-package-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ export function CopyPackageFiles(source: "src" | "built", pattern: string[]): Ti
cwd: fileSourceRoot,
});

// a.push(...temp.map(t => ({
// src: resolve(fileSourceRoot, t),
// dest: resolve(pkg.resolvedPkgDistRoot, source === "built" ? pkg.relativePkgDistModulePath : "", t),
// })));

a.push(...temp.map(t => ({
src: resolve(fileSourceRoot, t),
dest: resolve(pkg.resolvedPkgDistRoot, source === "built" ? pkg.relativePkgDistModulePath : "", t),
dest: resolve(pkg.resolvedPkgDistRoot, t),
})));

return a;
Expand All @@ -43,7 +48,11 @@ export function CopyPackageFiles(source: "src" | "built", pattern: string[]): Ti
}, Promise.resolve<{ src: string, dest: string }[]>([]));

this.log(`CopyPackageFiles found ${files.length} files for pattern ${stringPattern} in target '${target.tsconfigPath}'`);


for (let i = 0; i < files.length; i++) {
this.log(`CopyPackageFiles found ${files[i]}`, 0);
}

await Promise.all(files.map(f => buildCopyFile(f.src, f.dest)));

this.log(`Completing CopyPackageFiles with pattern ${stringPattern} on target '${target.tsconfigPath}'`, 1);
Expand Down
46 changes: 0 additions & 46 deletions tools/buildsystem/src/behaviors/create-resolution-package-files.ts

This file was deleted.

9 changes: 1 addition & 8 deletions tools/buildsystem/src/behaviors/write-packagejson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@ export function WritePackageJSON(transform?: (p: any) => typeof p): TimelinePipe

let pkgFile = importJSON(resolve(pkg.resolvedPkgSrcRoot, "package.json"));

this.log(`Updating package version at ${pkgFile} to ${version}`, 1);
this.log(`Updating package version at ${pkg.resolvedPkgSrcRoot} to ${version}`, 1);

pkgFile.version = version;

// update our peer dependencies and dependencies placeholder if needed
for (const key in pkgFile.peerDependencies) {
if (pkgFile.peerDependencies[key] === "0.0.0-PLACEHOLDER") {
pkgFile.peerDependencies[key] = version;
}
}

for (const key in pkgFile.dependencies) {
if (pkgFile.dependencies[key] === "0.0.0-PLACEHOLDER") {
pkgFile.dependencies[key] = version;
Expand Down
4 changes: 2 additions & 2 deletions tools/buildsystem/src/build-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class BuildTimeline extends Timeline<typeof BuildMoments> {
throw Error("No observers registered for this request. (https://pnp.github.io/pnpjs/queryable/queryable#no-observers-registered-for-this-request)");
}

// // schedule the execution after we return the promise below in the next event loop
// schedule the execution after we return the promise below in the next event loop
setTimeout(async () => {

try {
Expand Down Expand Up @@ -72,7 +72,7 @@ export class BuildTimeline extends Timeline<typeof BuildMoments> {

}, 0);

// // this is the promise that the calling code will recieve and await
// this is the promise that the calling code will recieve and await
let promise = new Promise<void>((resolve, reject) => {

// we overwrite any pre-existing internal events as a
Expand Down

0 comments on commit 65f1cca

Please sign in to comment.