This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(package): use Babel and pika-pack
- Loading branch information
1 parent
bc99151
commit 81772f4
Showing
13 changed files
with
838 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ docs/src/exampleSources | |
docs/dist/ | ||
dll/ | ||
node_modules/ | ||
pkg/ | ||
stats/ | ||
.vscode/ |
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
38 changes: 38 additions & 0 deletions
38
packages/internal-tooling/pika-plugin-bundle-types/README.md
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,38 @@ | ||
# @pika/plugin-build-types | ||
|
||
> A [@pika/pack](https://github.com/pikapkg/pack) build plugin. | ||
> Generates defintions with TypeScript and then creates a bundle from your TypeScript type definitions, using [DTS Bundle Generator](https://github.com/timocov/dts-bundle-generator). | ||
|
||
## Install | ||
|
||
```sh | ||
# npm: | ||
npm install @stardust-ui/internal-tooling --save-dev | ||
# yarn: | ||
yarn add @stardust-ui/internal-tooling --dev | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
```json | ||
{ | ||
"name": "example-package-json", | ||
"version": "1.0.0", | ||
"@pika/pack": { | ||
"pipeline": [ | ||
["@pika/plugin-standard-pkg"], | ||
["@stardust-ui/internal-tooling/pika-plugin-bundle-types"] | ||
] | ||
} | ||
} | ||
``` | ||
|
||
For more information about @pika/pack & help getting started, [check out the main project repo](https://github.com/pikapkg/pack). | ||
|
||
|
||
## Result | ||
|
||
1. Generates a single file with TypeScript definitions for your package build: `dist-types/` | ||
1. Adds a "types" entrypoint to your built `package.json` manifest. |
63 changes: 63 additions & 0 deletions
63
packages/internal-tooling/pika-plugin-bundle-types/index.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,63 @@ | ||
const { generateDtsBundle } = require('dts-bundle-generator') | ||
const execa = require('execa') | ||
const path = require('path') | ||
const fs = require('fs') | ||
const rimraf = require('rimraf') | ||
|
||
const build = async ({ cwd, out, reporter }) => { | ||
const tsBin = path.resolve(__dirname, '..', 'node_modules/.bin/tsc') | ||
const tsConfig = path.join(cwd, 'tsconfig.json') | ||
|
||
if (!fs.existsSync(tsConfig)) { | ||
console.error( | ||
['\n', '⚠️ dist-types/: ', 'Ensure that your package contains "tsconfig.json" file.'].join( | ||
' ', | ||
), | ||
) | ||
throw new Error(`Failed to build: dist-types/`) | ||
} | ||
|
||
const declarationOutputDir = path.join(out, 'dist-declarations') | ||
const declarationOutputFiles = [ | ||
path.join(declarationOutputDir, 'index.d.ts'), | ||
path.join(declarationOutputDir, 'src/index.d.ts'), | ||
] | ||
|
||
const typingsOutputDir = path.join(out, 'dist-types') | ||
const typingsOutputFile = path.join(typingsOutputDir, 'index.d.ts') | ||
|
||
await (async () => { | ||
await execa( | ||
tsBin, | ||
[ | ||
'-d', | ||
'--declarationMap', | ||
'false', | ||
'--declarationDir', | ||
declarationOutputDir, | ||
'--skipLibCheck', | ||
'--emitDeclarationOnly', | ||
], | ||
{ cwd }, | ||
) | ||
|
||
const declarationOutputFile = declarationOutputFiles.find(file => fs.existsSync(file)) | ||
const definitionBundle = generateDtsBundle([{ filePath: declarationOutputFile }]) | ||
|
||
rimraf.sync(declarationOutputDir) | ||
|
||
fs.mkdirSync(typingsOutputDir) | ||
fs.writeFileSync(typingsOutputFile, definitionBundle) | ||
})() | ||
|
||
reporter.created(declarationOutputDir, 'types') | ||
} | ||
|
||
const manifest = manifest => { | ||
manifest.types = 'dist-types/index.d.ts' | ||
} | ||
|
||
module.exports = { | ||
build, | ||
manifest, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default as Unstable_NestingAuto } from './NestingAuto' | ||
export { GetRefs, NodeRef } from './types' | ||
export * from './types' |
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
Oops, something went wrong.