-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): Fix plugin's type definition
Generate type.d file on dist folder to make plugin modules to resolve corresponding type definition file Fix #2483
- Loading branch information
Showing
15 changed files
with
82 additions
and
30 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,3 @@ | ||
{ | ||
"pluginPrefix": "billboardjs-plugin" | ||
} |
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
File renamed without changes.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {readJson} from "./util.js"; | ||
import {readJson} from "../util.js"; | ||
|
||
const pkg = readJson("package.json"); | ||
|
||
|
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 @@ | ||
/** | ||
* Copyright (c) 2017 ~ present NAVER Corp. | ||
* billboard.js project is licensed under the MIT license | ||
*/ | ||
import PluginClass from "../../types/plugin/{=PLUGIN-NAME}"; | ||
|
||
export default PluginClass; |
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,29 @@ | ||
/** | ||
* Generate plugin type definition file for dist folder. | ||
* Note: Need to be executed after 'dist', 'dist-esm' folders are generated. | ||
*/ | ||
import fs from "fs"; | ||
import {resolvePath, readFile, readJson, writeFile} from "./util.js"; | ||
|
||
const srcPath = resolvePath("../../src/Plugin/"); | ||
const distPath = resolvePath("../../dist/plugin/"); | ||
const distEsmPath = resolvePath("../../dist-esm/plugin/"); | ||
|
||
// read plugin type template | ||
const template = readFile("./template/plugin.d.txt"); | ||
|
||
// read the const to get plugin filename prefix | ||
const prefix = readJson("./const.json").pluginPrefix; | ||
|
||
// read the plugin directory | ||
fs.readdirSync(srcPath, { | ||
withFileTypes: true | ||
}) | ||
.filter(dirent => dirent.isDirectory()) | ||
.forEach(({name}) => { | ||
const fileName = `${prefix}-${name}.d.ts`; | ||
const content = template.replace(/{=PLUGIN-NAME}/, name) | ||
|
||
writeFile(`${distPath}/${fileName}`, content); | ||
writeFile(`${distEsmPath}/${fileName}`, content); | ||
}); |
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
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
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