Skip to content

Commit

Permalink
chore: use rollup-plugin-typescript2
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar committed Sep 13, 2021
1 parent a8ddcca commit f9124aa
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 130 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@
"zhihu-video-player"
],
"scripts": {
"format": "prettier --check \"packages/**/*.{js,json,md}\" \"*.{js,json,md}\"",
"format:fix": "prettier --write \"packages/**/*.{js,json,md}\" \"*.{js,json,md}\"",
"lint": "eslint 'packages/*/src/**/*.js' '*.js'",
"lint": "eslint .",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch --notify",
"build:lib": "lerna run build --ignore example --ignore website",
"build:lib": "lerna run build --scope griffith* --parallel",
"deploy:website": "lerna run --scope website deploy",
"build": "yarn build:lib",
"build:watch": "lerna run build --parallel --ignore example --ignore website --ignore griffith-standalone -- --watch",
"build:watch": "lerna run build --parallel --scope griffith* --ignore griffith-standalone -- --watch",
"release": "yarn build && lerna publish",
"start-server": "yarn workspace example run start",
"start": "yarn start-server"
Expand All @@ -57,6 +55,7 @@
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-typescript": "^8.2.5",
"@types/enzyme": "^3.10.9",
"@types/jest": "^27.0.1",
"@typescript-eslint/eslint-plugin": "^4.31.0",
Expand All @@ -81,6 +80,7 @@
"prettier": "^2.3.2",
"rollup": "^2.48.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"ts-migrate": "^0.1.22"
},
"husky": {
Expand Down
3 changes: 1 addition & 2 deletions packages/griffith-hls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browserslist": ["maintained node versions"],
"scripts": {
"prebuild": "rm -rf dist/**",
"build": "microbundle --tsconfig ../../tsconfig.build.json -f cjs,esm --no-sourcemap --no-compress --jsx React.createElement"
"build": "rollup -c ../../rollup.config.js"
},
"peerDependencies": {
"react": "^16.8 || ^17",
Expand Down
3 changes: 1 addition & 2 deletions packages/griffith-message/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browserslist": ["maintained node versions"],
"scripts": {
"prebuild": "rm -rf dist/**",
"build": "microbundle --tsconfig ../../tsconfig.build.json -f cjs,esm --no-sourcemap --no-compress"
"build": "rollup -c ../../rollup.config.js"
}
}
3 changes: 1 addition & 2 deletions packages/griffith-mp4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browserslist": ["maintained node versions"],
"scripts": {
"prebuild": "rm -rf dist/**",
"build": "microbundle --tsconfig ../../tsconfig.build.json -f cjs,esm --no-sourcemap --no-compress --jsx React.createElement"
"build": "rollup -c ../../rollup.config.js"
},
"devDependencies": {
"read-chunk": "^3.0.0"
Expand Down
1 change: 0 additions & 1 deletion packages/griffith-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"build": "rollup -c"
},
"devDependencies": {
"babel-loader": "^8.0.5",
"griffith": "^1.17.0",
"react": "^16.8",
"react-dom": "^16.8"
Expand Down
3 changes: 1 addition & 2 deletions packages/griffith-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browserslist": ["maintained node versions"],
"scripts": {
"prebuild": "rm -rf dist/**",
"build": "microbundle --tsconfig ../../tsconfig.build.json -f cjs,esm --no-sourcemap --no-compress"
"build": "rollup -c ../../rollup.config.js"
}
}
3 changes: 1 addition & 2 deletions packages/griffith/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browserslist": ["maintained node versions"],
"scripts": {
"prebuild": "rm -rf dist/**",
"build": "microbundle --tsconfig ../../tsconfig.build.json -f cjs,esm --no-sourcemap --no-compress --jsx React.createElement"
"build": "rollup -c ../../rollup.config.js"
},
"peerDependencies": {
"react": "^16.8 || ^17",
Expand Down
29 changes: 19 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path'
import babel from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'

const pkg = require(path.resolve(process.cwd(), 'package.json'))
import typescript from 'rollup-plugin-typescript2'
import findCacheDir from 'find-cache-dir'

const resolveCwd = path.resolve.bind(null, process.cwd())
const pkg = require(resolveCwd('package.json'))
const deps = Object.keys({...pkg.dependencies, ...pkg.peerDependencies})
const reExternal = new RegExp(`^(${deps.join('|')})($|/)`)

Expand All @@ -14,19 +14,28 @@ export default [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
{
file: pkg.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [
babel(require('./babel.config')),
// resolves `./directory` to `./directory/index.js`
resolve({only: [/\/packages\/.*/]}),
typescript({
cacheRoot: findCacheDir({
name: 'rollup-plugin-typescript2',
cwd: __dirname,
}),
tsconfigOverride: {
include: [resolveCwd('src/**/*')],
exclude: ['**/*.spec.*', '**/__tests__'],
compilerOptions: {
// reset to empty
paths: {},
},
},
}),
],
external: id => (deps.length ? reExternal.test(id) : false),
external: (id) => (deps.length ? reExternal.test(id) : false),
},
]
7 changes: 0 additions & 7 deletions tsconfig.build.json

This file was deleted.

103 changes: 8 additions & 95 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
/* Specify what JSX code is generated. */
"target": "ES6",
"jsx": "react",
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */

/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
/* Specify a set of entries that re-map imports to additional lookup locations. */
"module": "ESNext",
"paths": {
// link all packages without build step
"griffith-mp4": ["./packages/griffith-mp4/src/index.ts"],
Expand All @@ -38,72 +12,11 @@
"griffith-message": ["./packages/griffith-message/src/index.ts"],
"griffith": ["./packages/griffith/src/index.ts"]
},
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */

/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,

/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"declaration": true,
// import @types/react
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
36 changes: 34 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,14 @@
"@rollup/pluginutils" "^3.1.0"
magic-string "^0.25.7"

"@rollup/plugin-typescript@^8.2.5":
version "8.2.5"
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.2.5.tgz#e0319761b2b5105615e5a0c371ae05bc2984b7de"
integrity sha512-QL/LvDol/PAGB2O0S7/+q2HpSUNodpw7z6nGn9BfoVCPOZ0r4EALrojFU29Bkoi2Hr2jgTocTejJ5GGWZfOxbQ==
dependencies:
"@rollup/pluginutils" "^3.1.0"
resolve "^1.17.0"

"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
Expand All @@ -2242,6 +2250,14 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"

"@rollup/pluginutils@^4.1.0":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.1.1.tgz#1d4da86dd4eded15656a57d933fda2b9a08d47ec"
integrity sha512-clDjivHqWGXi7u+0d2r2sBi4Ie6VLEAzWMIkvJLnDmxoOhBYOTfzGbOQBA32THHm11/LiJbd01tJUpJsbshSWQ==
dependencies:
estree-walker "^2.0.1"
picomatch "^2.2.2"

"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
Expand Down Expand Up @@ -3365,7 +3381,7 @@ babel-jest@^27.1.0:
graceful-fs "^4.2.4"
slash "^3.0.0"

babel-loader@^8.0.0, babel-loader@^8.0.5:
babel-loader@^8.0.0:
version "8.0.5"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.0.5.tgz#225322d7509c2157655840bba52e46b6c2f2fe33"
integrity sha512-NTnHnVRd2JnRqPC0vW+iOQWU5pchDbYXsG2E6DMXEpMfUcQKclF9gmf3G3ZMhzG7IG9ji4coL0cm+FxeWxDpnw==
Expand Down Expand Up @@ -14508,7 +14524,7 @@ resolve@1.17.0:
dependencies:
path-parse "^1.0.6"

resolve@^1.10.0, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.8.1:
resolve@1.20.0, resolve@^1.10.0, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.8.1:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
Expand Down Expand Up @@ -14649,6 +14665,17 @@ rollup-plugin-typescript2@^0.29.0:
resolve "1.17.0"
tslib "2.0.1"

rollup-plugin-typescript2@^0.30.0:
version "0.30.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.30.0.tgz#1cc99ac2309bf4b9d0a3ebdbc2002aecd56083d3"
integrity sha512-NUFszIQyhgDdhRS9ya/VEmsnpTe+GERDMmFo0Y+kf8ds51Xy57nPNGglJY+W6x1vcouA7Au7nsTgsLFj2I0PxQ==
dependencies:
"@rollup/pluginutils" "^4.1.0"
find-cache-dir "^3.3.1"
fs-extra "8.1.0"
resolve "1.20.0"
tslib "2.1.0"

rollup-pluginutils@^2.8.2:
version "2.8.2"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
Expand Down Expand Up @@ -16330,6 +16357,11 @@ tslib@2.0.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"
integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==

tslib@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==

tslib@^1.6.0, tslib@^1.8.1, tslib@^1.9.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
Expand Down

0 comments on commit f9124aa

Please sign in to comment.