Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
chore(package): use Babel and pika-pack
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed May 28, 2019
1 parent f09083d commit bb388ca
Show file tree
Hide file tree
Showing 31 changed files with 639 additions and 376 deletions.
6 changes: 6 additions & 0 deletions .browserslistrc
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ coverage/
dist/
dll/
node_modules/
pkg/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ docs/src/exampleSources
docs/dist/
dll/
node_modules/
pkg/
stats/
.vscode/
108 changes: 0 additions & 108 deletions build/gulp/tasks/bundle.ts

This file was deleted.

3 changes: 2 additions & 1 deletion build/gulp/tasks/test-circulars/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import config from '../../../../config'

const reactPackageDist = (filePath: string) => config.paths.packageDist('react', 'es', filePath)
const reactPackageDist = (filePath: string) =>
config.paths.packages('react', 'pkg', 'dist-src', filePath)

export const cyclesToSkip = [
[reactPackageDist('components/Tree/Tree.js'), reactPackageDist('components/Tree/TreeItem.js')],
Expand Down
2 changes: 1 addition & 1 deletion build/gulp/tasks/test-circulars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import config from '../../../../config'
import { cyclesToSkip } from './config'
import { buildWebpackConfig, configureCircularDependencyCheckPlugin, isCycleToSkip } from './utils'

const entryFilePath = config.paths.packageDist('react', 'es', 'index.js')
const entryFilePath = config.paths.packages('react', 'pkg', 'dist-src', 'index.js')
const outputFilePath = path.resolve(__dirname, 'result.js')

task('test:circulars:run', done => {
Expand Down
4 changes: 4 additions & 0 deletions build/gulp/tasks/test-circulars/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import CircularDependencyPlugin from 'circular-dependency-plugin'
import { webpack as lernaAliases } from 'lerna-alias'

import config from '../../../../config'

Expand Down Expand Up @@ -44,5 +45,8 @@ export const buildWebpackConfig = ({
filename: path.basename(outputFilePath),
},
plugins,
resolve: {
alias: lernaAliases({ sourceDirectory: 'pkg/dist-web' }),
},
}
}
2 changes: 1 addition & 1 deletion build/gulp/tasks/test-projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const packStardustPackages = async (logger: Function): Promise<PackedPackages> =
await Promise.all(
Object.keys(stardustPackages).map(async (packageName: string) => {
const filename = tmp.tmpNameSync({ prefix: `stardust-`, postfix: '.tgz' })
const directory = stardustPackages[packageName]
const directory = path.resolve(stardustPackages[packageName], 'pkg')

await runIn(directory)(`yarn pack --filename ${filename}`)
logger(`✔️Package "${packageName}" was packed to ${filename}`)
Expand Down
2 changes: 2 additions & 0 deletions build/webpack.config.stats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CleanWebpackPlugin from 'clean-webpack-plugin'
import fs from 'fs'
import { webpack as lernaAliases } from 'lerna-alias'
import path from 'path'
import webpack from 'webpack'
import config from '../config'
Expand Down Expand Up @@ -64,6 +65,7 @@ const makeConfig = (srcPath, name) => ({
new webpack.DefinePlugin(config.compiler_globals),
],
resolve: {
alias: lernaAliases({ sourceDirectory: 'pkg/dist-web' }),
extensions: ['.ts', '.tsx', '.js', '.json'],
},
performance: {
Expand Down
6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ const { task, series, parallel } = require('gulp')
const path = require('path')
const tsPaths = require('tsconfig-paths')

const config = require('./config').default
const { compilerOptions } = require('./build/tsconfig.docs.json')
const config = require('./config').default
const sh = require('./build/gulp/sh').default

// add node_modules/.bin to the path so we can invoke .bin CLIs in tasks
process.env.PATH =
Expand All @@ -16,9 +17,10 @@ tsPaths.register({
paths: compilerOptions.paths,
})

task('bundle:all-packages', () => sh('lerna run build'))

// load tasks in order of dependency usage
require('./build/gulp/tasks/dll')
require('./build/gulp/tasks/bundle')
require('./build/gulp/tasks/docs')
require('./build/gulp/tasks/screener')
require('./build/gulp/tasks/stats')
Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"scripts": {
"build": "gulp build",
"build:bundle": "gulp bundle:all-packages",
"build:bundle": "lerna run build",
"build:docs": "gulp --series dll build:docs",
"ci": "yarn lint && yarn prettier && yarn test --strict",
"clean:cache": "gulp clean:cache",
Expand All @@ -18,11 +18,11 @@
"precommit": "lint-staged",
"prepush": "gulp git:prepush",
"postcommit": "git update-index --again",
"prerelease": "yarn ci && cross-env NODE_ENV=production yarn build",
"postrelease": "yarn deploy:docs",
"release:major": "yarn prerelease && lerna publish major && yarn postrelease",
"release:minor": "yarn prerelease && lerna publish minor && yarn postrelease",
"release:patch": "yarn prerelease && lerna publish patch && yarn postrelease",
"prerelease": "yarn ci",
"postrelease": "cross-env NODE_ENV=production yarn build && lerna publish from-package --contents pkg && yarn deploy:docs",
"release:major": "yarn prerelease && lerna version major && yarn postrelease",
"release:minor": "yarn prerelease && lerna version minor && yarn postrelease",
"release:patch": "yarn prerelease && lerna version patch && yarn postrelease",
"prestart": "yarn satisfied",
"start": "cross-env SKIP_ERRORS=true gulp --series dll docs",
"stats:build": "gulp stats",
Expand Down Expand Up @@ -92,7 +92,6 @@
"gulp-plumber": "^1.2.0",
"gulp-remember": "^1.0.1",
"gulp-transform": "^3.0.5",
"gulp-typescript": "^5.0.0",
"gulp-util": "^3.0.8",
"html-webpack-plugin": "^3.2.0",
"husky": "^0.14.3",
Expand Down
24 changes: 12 additions & 12 deletions packages/docs-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
"version": "0.31.0",
"author": "Oleksandr Fediashov <a@fedyashov.com>",
"bugs": "https://github.com/stardust-ui/react/issues",
"@pika/pack": {
"pipeline": [
["@pika/plugin-standard-pkg", { "exclude": ["test/**/*"] }],
["@pika/plugin-build-node"],
["@pika/plugin-build-web"],
["@stardust-ui/internal-tooling/pika-plugin-bundle-types"]
]
},
"dependencies": {
"@babel/runtime-corejs2": "^7.4.5",
"object.values": "^1.1.0",
"prismjs": "^1.16.0",
"prop-types": "^15.6.1",
"tslib": "^1.9.3"
"prop-types": "^15.6.1"
},
"files": [
"dist"
],
"homepage": "https://github.com/stardust-ui/react/tree/master/packages/docs-components",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"peerDependencies": {
"react": "^16.8.0",
"react-dom": "^16.8.0"
Expand All @@ -27,8 +29,6 @@
},
"repository": "stardust-ui/react.git",
"scripts": {
"build": "gulp bundle:package:no-umd --package docs-components"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"build": "cross-env NODE_ENV=production pika-pack build"
}
}
2 changes: 1 addition & 1 deletion packages/docs-components/src/knobs/useKnobValues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as values from 'object.values'
import values from 'object.values'
import * as React from 'react'

import KnobsContext from './KnobContext'
Expand Down
5 changes: 4 additions & 1 deletion packages/internal-tooling/babel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ module.exports = {
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-runtime',
['@babel/plugin-transform-runtime', { corejs: 2 }],
],
env: {
development: {
plugins: ['react-hot-loader/babel'],
},
production: {
plugins: ['lodash'],
},
test: {
presets: [['@babel/preset-env', { modules: 'commonjs' }]],
},
Expand Down
14 changes: 12 additions & 2 deletions packages/internal-tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@pika/pack": "^0.3.7",
"@pika/plugin-build-node": "^0.4.0",
"@pika/plugin-build-web": "^0.4.0",
"@pika/plugin-standard-pkg": "^0.4.0",
"@types/jest": "^24.0.11",
"@types/jest-axe": "^2.2.3",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"babel-jest": "^24.5.0",
"babel-plugin-lodash": "^3.3.4",
"cross-env": "^5.2.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.1.0",
Expand All @@ -24,12 +30,16 @@
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.6.0",
"jest": "^24.5.0",
"jest-axe": "^3.1.1"
"jest-axe": "^3.1.1",
"rollup": "^1.11.3",
"rollup-plugin-dts": "^0.15.1",
"typescript": "^3.3.3333"
},
"files": [
"babel",
"eslint",
"jest"
"jest",
"pika-plugin-bundle-types"
],
"publishConfig": {
"access": "public"
Expand Down
38 changes: 38 additions & 0 deletions packages/internal-tooling/pika-plugin-bundle-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# @stardust-ui/internal-tooling/pika-plugin-bundle-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.

0 comments on commit bb388ca

Please sign in to comment.