Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // import "fs";
- var fs = require("fs");
- const extensions = ['.js', '.ts']
- integrate("base.ts", 'result.js')
- function integrate(from, to){
- var content = fs.readFileSync(from).toString();
- content = removeLazy(content)
- var content = importInsert(content);
- fs.writeFileSync(to, content)
- }
- function removeLazy(content){
- return content.replace(/\/\*-lazy\*\/[\s\S]*?\/\*lazy-\*\//, '');
- }
- function importInsert(content){
- let regex = /import \* as (?<module>\w+) from \"\.\/(?<filename>\w+)\"/g;
- return content.replace(regex, packer)
- }
- function packer(match, module, fileName, offset, source){
- for(let ext of extensions){
- if (fs.existsSync(fileName + ext))
- {
- fileName = fileName + ext;
- break;
- }
- }
- var content = fs.readFileSync(fileName).toString()
- // content = Convert(content)
- return content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement