-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Build multiple modules instead of one index.js
- refactor: Move build command to build.sh note: this will allow multiple module build entry files - feat: Add indexify.js script, this will generate moduleName.js files note: this is because tsdx.config.js override do not generate js files - feat: Add tsdx.config.js to generate multiple esm, cjs modules - refactor: Move index file out from module folders refer jaredpalmer/tsdx#175 (comment) Important note: Base on the comment tsdx do not support multiple entry
- Loading branch information
Wilson Lim
committed
Feb 7, 2021
1 parent
65e46f0
commit b995027
Showing
12 changed files
with
97 additions
and
18,551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
echo "build multiple modules" | ||
tsdx build \ | ||
--entry=src/index.ts \ | ||
--entry=src/promise.ts \ | ||
--entry=src/validation.ts \ | ||
--entry=src/timeconvert.ts \ | ||
&& node ./scripts/flowgen.js \ | ||
&& node ./scripts/indexify.js \ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
'use strict' | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./__MODULE__.cjs.production.min.js') | ||
} else { | ||
module.exports = require('./__MODULE__.cjs.development.js') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var dirPath = path.resolve('./dist'); | ||
var filesList; | ||
|
||
console.log('generate module.js files') | ||
|
||
fs.readdir(dirPath, function(err, files) { | ||
filesList = files.filter(function(e) { | ||
return e.includes('esm.js.map'); | ||
}); | ||
console.log('built modules to convert:'); | ||
console.log(filesList); | ||
}); | ||
|
||
fs.readFile('./scripts/index.tpl', 'utf8', function(err, data) { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
|
||
filesList.forEach(element => { | ||
const moduleName = element.split('.')[0]; | ||
var result = data.replace(/__MODULE__/g, moduleName); | ||
console.log(`output to ./dist/${moduleName}.js`); | ||
fs.writeFile(`./dist/${moduleName}.js`, result, 'utf8', function(err) { | ||
if (err) return console.log(err); | ||
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import waitForTrue from './promise/waitForTrue'; | ||
import sleep from './promise/sleep'; | ||
|
||
export default { | ||
waitForTrue, | ||
sleep, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import isEmptyOrZero from './validation/isEmptyOrZero'; | ||
import versionCheck from './validation/versionCheck'; | ||
|
||
export default { | ||
isEmptyOrZero, | ||
versionCheck, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
rollup(config, options) { | ||
const outputDir = process.cwd() + '/dist/'; | ||
const extension = | ||
'.' + | ||
config.output.file | ||
.split('.') | ||
.slice(1) | ||
.join('.'); | ||
let filename = config.input.split('src/')[1]; // remove src/ | ||
filename = filename.split('.')[0]; // remove extension, if any | ||
|
||
config.output.file = outputDir + filename + extension; | ||
console.log(config.output.file); | ||
// replace / with __ for UMD names | ||
config.output.name = filename.replace('/', '__'); | ||
return config; | ||
}, | ||
}; |