Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/consumer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"author": "Power Bot Kit Team",
"homepage": "https://github.com/PowerBotKit/powerbot/tree/develop/packages/consumer#readme",
"license": "MIT",
"main": "./index.js",
"types": "./index.d.ts",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand All @@ -26,5 +24,11 @@
"adaptivecards-templating": "^2.2.0",
"js-yaml": "^4.1.0",
"redis": "^3.0.2"
},
"exports": {
".": {
"require": "./src/index.js",
"import": "./lib/index.js"
}
}
}
1 change: 0 additions & 1 deletion packages/consumer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"baseUrl": ".",
"target": "es6",
"lib": ["es6", "esnext", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
Expand Down
23 changes: 21 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"author": "Power Bot Kit Team",
"homepage": "https://github.com/PowerBotKit/powerbot/tree/develop/packages/core#readme",
"license": "MIT",
"main": "./index.js",
"types": "./index.d.ts",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand All @@ -27,5 +25,26 @@
},
"devDependencies": {
"@types/redis": "^2.8.32"
},
"exports": {
".": {
"require": "./src/index.js",
"import": "./lib/index.js"
},
"./template": {
"types": "./src/template/index.d.ts",
"require": "./src/template/index.js",
"import": "./lib/template/index.js"
}
},
"typesVersions": {
"*": {
"*": [
"./src/index.d.ts"
],
"template": [
"./src/template/index.d.ts"
]
}
}
}
1 change: 0 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"baseUrl": ".",
"target": "esnext",
"lib": ["es6", "esnext", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
Expand Down
8 changes: 6 additions & 2 deletions packages/distributor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"author": "Power Bot Kit Team",
"homepage": "https://github.com/PowerBotKit/powerbot/tree/develop/packages/distributor#readme",
"license": "MIT",
"main": "./index.js",
"types": "./index.d.ts",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand All @@ -33,5 +31,11 @@
"devDependencies": {
"@types/restify": "^8.5.4",
"nodemon": "^2.0.13"
},
"exports": {
".": {
"require": "./src/index.js",
"import": "./lib/index.js"
}
}
}
1 change: 0 additions & 1 deletion packages/distributor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"baseUrl": ".",
"target": "es6",
"lib": ["es6", "esnext", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
Expand Down
1 change: 0 additions & 1 deletion packages/examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"baseUrl": ".",
"target": "esnext",
"lib": ["es6", "esnext", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
Expand Down
57 changes: 46 additions & 11 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,53 @@ const shelljs = require('shelljs');

const { fetchTargets, fetchTopologicalSorting } = require('./utils');

function buildES6(target) {
const { code } = shelljs.exec(
`yarn tsc --project ${path.join(
target.location,
'tsconfig.json'
)} --outDir ${path.resolve('./dist', target.folderName, 'lib')}`
);

if (code !== 0) {
throw new Error(`fail to compile the ${target.name}`);
}
}

function buildCommonjs(target) {
const { code } = shelljs.exec(
`yarn tsc --project ${path.join(
target.location,
'tsconfig.json'
)} --outDir ${path.resolve(
'./dist',
target.folderName,
'src'
)} --module commonjs`
);

if (code !== 0) {
throw new Error(`fail to compile the ${target.name}`);
}
}

async function updatePackageJson(target) {
const packageJsonPath = `${path.resolve(
'./dist',
target.folderName,
'package.json'
)}`;
const json = await fsEx.readJson(packageJsonPath);
json.main = './src/index.js';
json.types = './src/index.d.ts';
json.module = './lib/index.js';
await fsEx.writeJson(packageJsonPath, json, { spaces: 2 });
}

async function buildTarget(target) {
if (target.private !== true) {
const { code } = shelljs.exec(
`yarn tsc --project ${path.join(
target.location,
'tsconfig.json'
)} --outDir ${path.resolve('./dist', target.folderName)}`
);

if (code !== 0) {
throw new Error(`fail to compile the ${target.name}`);
}
buildES6(target);
buildCommonjs(target);
const files = ['package.json', 'README.md', 'LICENSE'];
const copyTasks = files
.map(file => {
Expand All @@ -38,7 +73,7 @@ async function buildTarget(target) {
.map(f => fs.copyFile(f.src, f.dest));
await Promise.all(copyTasks);
console.log(`${colors.blue(target.name)} ${colors.green('success')} 🚀`);

updatePackageJson(target);
await fs.rm(`${path.resolve('./node_modules/' + target.name)}`, {
force: true,
recursive: true
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"target": "es6",
"lib": ["es6", "esnext", "dom"],
"module": "commonjs",
"module": "es6",
"moduleResolution": "node",
"sourceMap": false,
"experimentalDecorators": true,
Expand Down