diff --git a/buildsystem-config.ts b/buildsystem-config.ts index 1e2b5449e..c8c5f66d4 100644 --- a/buildsystem-config.ts +++ b/buildsystem-config.ts @@ -9,7 +9,6 @@ import { WritePackageJSON, Publish, PublishNightly, - CreateResolutionPackageFiles, } from "@pnp/buildsystem"; import { Logger, @@ -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" }, @@ -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", @@ -121,14 +106,13 @@ function PnPPublish(flags?: string[]): (b: BuildTimeline) => BuildTimeline { const commonBehaviors = [ PnPLogging(logLevel), -] +]; export default [{ name: "build", distFolder, targets: [ resolve("./packages/tsconfig.json"), - resolve("./packages/tsconfig-commonjs.json"), ], behaviors: [PnPBuild(), ...commonBehaviors], }, @@ -145,7 +129,6 @@ export default [{ distFolder, targets: [ resolve("./packages/tsconfig.json"), - resolve("./packages/tsconfig-commonjs.json"), ], behaviors: [PnPBuild(), PnPPackage(), ...commonBehaviors], }, @@ -154,7 +137,6 @@ export default [{ distFolder, targets: [ resolve("./packages/tsconfig.json"), - resolve("./packages/tsconfig-commonjs.json"), ], behaviors: [PnPBuild(), PnPPackage(), PnPPublish(commonPublishTags), ...commonBehaviors], }, @@ -163,7 +145,6 @@ export default [{ distFolder, targets: [ resolve("./packages/tsconfig.json"), - resolve("./packages/tsconfig-commonjs.json"), ], behaviors: [PnPBuild(), PnPPackage(), PnPPublish([...commonPublishTags, "--tag", "beta"]), ...commonBehaviors], }, @@ -172,7 +153,6 @@ export default [{ distFolder, targets: [ resolve("./packages/tsconfig.json"), - resolve("./packages/tsconfig-commonjs.json"), ], behaviors: [PnPBuild(), PnPPackage(), PublishNightly([...commonPublishTags], "v4nightly"), ...commonBehaviors], }]; diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 995aac1eb..be33142ea 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../tsconfig.json", "compilerOptions": { "rootDir": ".", - "outDir": "../build/packages/esm" + "outDir": "../build/packages" }, "include": [], "references": [ diff --git a/tools/buildsystem/index.ts b/tools/buildsystem/index.ts index f77389f8b..38095fb4d 100644 --- a/tools/buildsystem/index.ts +++ b/tools/buildsystem/index.ts @@ -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, diff --git a/tools/buildsystem/package.json b/tools/buildsystem/package.json index 3831780a6..fd057e00c 100644 --- a/tools/buildsystem/package.json +++ b/tools/buildsystem/package.json @@ -1,6 +1,6 @@ { "name": "@pnp/buildsystem", - "version": "4.0.0-beta10", + "version": "4.0.0", "bin": { "pnpbuild": "bin/buildsystem.js" }, diff --git a/tools/buildsystem/src/behaviors/copy-asset-files.ts b/tools/buildsystem/src/behaviors/copy-asset-files.ts index 394bdb56e..49ac8e3dd 100644 --- a/tools/buildsystem/src/behaviors/copy-asset-files.ts +++ b/tools/buildsystem/src/behaviors/copy-asset-files.ts @@ -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 */ diff --git a/tools/buildsystem/src/behaviors/copy-package-files.ts b/tools/buildsystem/src/behaviors/copy-package-files.ts index c8de6da66..a1bf4801d 100644 --- a/tools/buildsystem/src/behaviors/copy-package-files.ts +++ b/tools/buildsystem/src/behaviors/copy-package-files.ts @@ -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; @@ -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); diff --git a/tools/buildsystem/src/behaviors/create-resolution-package-files.ts b/tools/buildsystem/src/behaviors/create-resolution-package-files.ts deleted file mode 100644 index 984ee29af..000000000 --- a/tools/buildsystem/src/behaviors/create-resolution-package-files.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { TimelinePipe } from "@pnp/core"; -import { resolve } from "path"; -import { BuildTimeline } from "../build-timeline.js"; -import buildWriteFile from "../lib/write-file.js"; - -/** - * Because the TypeScript team will not make a simple change we have to add package.json's to each package's module sub/folder to ensure the resolution works with just *.js extensions. - * - * It is stupid this has to exist, but well here we are. - * @returns - */ -export function CreateResolutionPackageFiles(): TimelinePipe { - - return (instance: BuildTimeline) => { - - instance.on.package(async function (this: BuildTimeline) { - - this.log("Creating Resolution package.json files.", 1); - - const { targets } = this.context; - - const promises = []; - - targets.forEach((target) => { - - target.packages.forEach((pkg) => { - - const filePath = resolve(pkg.resolvedPkgDistRoot, pkg.relativePkgDistModulePath, "package.json"); - - let pkgFile = { - name: pkg.name, - type: /commonjs/i.test(target.parsedTSConfig.compilerOptions.module) ? "commonjs" : "module", - } - - this.log(`Writing module resolution package.json for ${filePath} as ${pkgFile.type}`, 0); - - promises.push(buildWriteFile(filePath, JSON.stringify(pkgFile))); - }); - }); - - await Promise.all(promises); - }); - - return instance; - } -} diff --git a/tools/buildsystem/src/behaviors/write-packagejson.ts b/tools/buildsystem/src/behaviors/write-packagejson.ts index 0142a73e0..d3e999a4c 100644 --- a/tools/buildsystem/src/behaviors/write-packagejson.ts +++ b/tools/buildsystem/src/behaviors/write-packagejson.ts @@ -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; diff --git a/tools/buildsystem/src/build-timeline.ts b/tools/buildsystem/src/build-timeline.ts index 92a96d94f..9ea6f6e18 100644 --- a/tools/buildsystem/src/build-timeline.ts +++ b/tools/buildsystem/src/build-timeline.ts @@ -43,7 +43,7 @@ export class BuildTimeline extends Timeline { 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 { @@ -72,7 +72,7 @@ export class BuildTimeline extends Timeline { }, 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((resolve, reject) => { // we overwrite any pre-existing internal events as a