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
f8a7e6e
commit fa1d372
Showing
28 changed files
with
609 additions
and
221 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### Browsers that we support | ||
|
||
>0.2% | ||
not dead | ||
not ie < 11 | ||
not op_mini all |
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
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
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 definitions with TypeScript and then creates a bundle from your TypeScript type definitions, using [rollup-plugin-dts](https://github.com/Swatinem/rollup-plugin-dts). | ||
|
||
## 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. |
56 changes: 56 additions & 0 deletions
56
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,56 @@ | ||
const path = require('path') | ||
const fs = require('fs') | ||
const { rollup } = require('rollup') | ||
const { dts } = require('rollup-plugin-dts') | ||
|
||
const build = async ({ cwd, manifest, out, reporter }) => { | ||
const tsConfig = path.join(cwd, 'tsconfig.json') | ||
|
||
if (manifest.types) { | ||
console.info( | ||
[ | ||
'\n', | ||
'ℹ️ dist-types/: ', | ||
'Your "package.json" contains "types" field, generation is skipped.', | ||
].join(' '), | ||
) | ||
return | ||
} | ||
|
||
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 typingsOutputDir = path.join(out, 'dist-types') | ||
const typingsOutputFile = path.join(typingsOutputDir, 'index.d.ts') | ||
|
||
await (async () => { | ||
const result = await rollup({ | ||
// TODO: make this list configurable | ||
external: ['fela', 'lodash', 'react', 'prop-types', 'react-dom'], | ||
input: path.resolve(cwd, 'src', 'index.ts'), | ||
plugins: [dts({ tsconfig: tsConfig })], | ||
}) | ||
|
||
await result.write({ | ||
file: typingsOutputFile, | ||
format: 'es', | ||
}) | ||
})() | ||
|
||
reporter.created(typingsOutputFile, 'types') | ||
} | ||
|
||
const manifest = manifest => { | ||
manifest.types = 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
10 changes: 10 additions & 0 deletions
10
packages/react-component-event-listener/tsconfig.build.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,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"isolatedModules": false, | ||
"outDir": "pkg/dist-types", | ||
"rootDir": "src" | ||
}, | ||
"include": ["src"] | ||
} |
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
10 changes: 10 additions & 0 deletions
10
packages/react-component-nesting-registry/tsconfig.build.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,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"isolatedModules": false, | ||
"outDir": "pkg/dist-types", | ||
"rootDir": "src" | ||
}, | ||
"include": ["src"] | ||
} |
Oops, something went wrong.