Skip to content

Commit

Permalink
removing commonjs builds
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-rodgers committed Feb 7, 2022
1 parent 3814570 commit ffda229
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 368 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"**/node_modules": true,
"coverage": true,
".nyc_output": true,
"build": true,
"dist": true,
"build": false,
"dist": false,
"site": true,
"buildsystem-config.js": true
},
Expand Down
71 changes: 6 additions & 65 deletions buildsystem-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export default <ConfigCollection>[

// these tsconfig files will all be transpiled per the settings in the file
buildTargets: [
resolve("./packages/tsconfig.esm.json"),
resolve("./packages/tsconfig.cjs.json"),
resolve("./packages/tsconfig.json"),
],

postBuildTasks: [
Expand All @@ -36,8 +35,8 @@ export default <ConfigCollection>[

packageTargets: [
{
outDir: resolve("./dist/packages/esm"),
target: resolve("./packages/tsconfig.esm.json"),
outDir: resolve("./dist/packages"),
target: resolve("./packages/tsconfig.json"),
tasks: [
Tasks.Package.createCopyTargetFiles(),
Tasks.Package.copyStaticAssets,
Expand Down Expand Up @@ -67,61 +66,6 @@ export default <ConfigCollection>[
}),
],
},
{
outDir: resolve("./dist/packages/commonjs"),
target: resolve("./packages/tsconfig.cjs.json"),
tasks: [
Tasks.Package.createCopyTargetFiles("", "", [function (file, _enconding, cb) {
// we need to rewrite all the requires that use @pnp/something to be @pnp/something-commonjs

if (/\.js$|\.d\.ts$/i.test(file.path)) {

const content: string = file.contents.toString("utf8");
file.contents = Buffer.from(content.replace(/"\@pnp\/(\w*?)([\/|"])/ig, `"@pnp/$1-commonjs$2`));
}

cb(null, file);
}]),
Tasks.Package.copyStaticAssets,
Tasks.Package.createWritePackageFiles(p => {

const newP = Object.assign({}, p, {
funding: {
"type": "individual",
"url": "https://github.com/sponsors/patrick-rodgers/",
},
type: "commonjs",
});

// selective imports don't work in commonjs or matter for nodejs
// so we retarget main to the preset for these libraries (and update typings pointer)
if (newP.name.match(/\/sp$|\/graph$/)) {
newP.main = "./presets/all.js";
newP.typings = "./presets/all";
}

// update name field to include -commonjs
newP.name = `${newP.name}-commonjs`;

// and we need to rewrite the dependencies to point to the commonjs ones
if (newP.dependencies) {
const newDeps = {};
for (const key in newP.dependencies) {

if (key.startsWith("@pnp/")) {
newDeps[`${key}-commonjs`] = newP.dependencies[key];
} else {
newDeps[key] = newP.dependencies[key];
}
}

newP.dependencies = newDeps;
}

return newP;
}),
],
},
],

postPackageTasks: [],
Expand All @@ -133,8 +77,7 @@ export default <ConfigCollection>[
role: "publish",

packageRoots: [
resolve("./dist/packages/esm"),
resolve("./dist/packages/commonjs"),
resolve("./dist/packages"),
],

prePublishTasks: [],
Expand Down Expand Up @@ -174,8 +117,7 @@ export default <ConfigCollection>[
role: "publish",

packageRoots: [
resolve("./dist/packages/esm"),
resolve("./dist/packages/commonjs"),
resolve("./dist/packages"),
],

prePublishTasks: [],
Expand All @@ -191,8 +133,7 @@ export default <ConfigCollection>[
role: "publish",

packageRoots: [
resolve("./dist/packages/esm"),
resolve("./dist/packages/commonjs"),
resolve("./dist/packages"),
],

prePublishTasks: [Tasks.Publish.updateV3NightlyVersion],
Expand Down
10 changes: 0 additions & 10 deletions packages/core/tsconfig.cjs.json

This file was deleted.

10 changes: 0 additions & 10 deletions packages/core/tsconfig.esm.json

This file was deleted.

9 changes: 8 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"extends": "./tsconfig.esm.json"
"extends": "../tsconfig.json",
"include": [
"./**/*.ts"
],
"compilerOptions": {
"esModuleInterop": true
},
"references": []
}
20 changes: 0 additions & 20 deletions packages/graph/tsconfig.cjs.json

This file was deleted.

20 changes: 0 additions & 20 deletions packages/graph/tsconfig.esm.json

This file was deleted.

21 changes: 19 additions & 2 deletions packages/graph/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{
"extends": "./tsconfig.esm.json"
}
"extends": "../tsconfig.json",
"include": [
"./**/*.ts",
"../core/**/*.ts",
"../logging/**/*.ts",
"../queryable/**/*.ts"
],
"references": [
{
"path": "../core/tsconfig.json"
},
{
"path": "../logging/tsconfig.json"
},
{
"path": "../queryable/tsconfig.json"
}
]
}
7 changes: 0 additions & 7 deletions packages/logging/tsconfig.cjs.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/logging/tsconfig.esm.json

This file was deleted.

8 changes: 6 additions & 2 deletions packages/logging/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "./tsconfig.esm.json"
}
"extends": "../tsconfig.json",
"include": [
"./**/*.ts"
],
"references": []
}
12 changes: 0 additions & 12 deletions packages/msaljsclient/tsconfig.cjs.json

This file was deleted.

12 changes: 0 additions & 12 deletions packages/msaljsclient/tsconfig.esm.json

This file was deleted.

13 changes: 11 additions & 2 deletions packages/msaljsclient/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"extends": "./tsconfig.esm.json"
}
"extends": "../tsconfig.json",
"include": [
"./**/*.ts",
"../queryable/**/*.ts"
],
"references": [
{
"path": "../queryable/tsconfig.json"
}
]
}
28 changes: 0 additions & 28 deletions packages/nodejs/tsconfig.cjs.json

This file was deleted.

28 changes: 0 additions & 28 deletions packages/nodejs/tsconfig.esm.json

This file was deleted.

29 changes: 27 additions & 2 deletions packages/nodejs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
{
"extends": "./tsconfig.esm.json"
}
"extends": "../tsconfig.json",
"include": [
"./**/*.ts",
"../core/**/*.ts",
"../graph/**/*.ts",
"../queryable/**/*.ts",
"../logging/**/*.ts",
"../sp/**/*.ts"
],
"references": [
{
"path": "../core/tsconfig.json"
},
{
"path": "../graph/tsconfig.json"
},
{
"path": "../logging/tsconfig.json"
},
{
"path": "../queryable/tsconfig.json"
},
{
"path": "../sp/tsconfig.json"
}
]
}
Loading

0 comments on commit ffda229

Please sign in to comment.