diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..42ef285 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,96 @@ +import express from 'express' +import webpack from 'webpack' +import WebpackChainConfig from 'webpack-chain' + +export interface LogOptions { + logLevel: number + debug: boolean + silly: boolean + quiet: boolean + logUpdate: boolean +} + +export interface Options extends LogOptions { + dev: boolean + baseDir: string + config: string | false + inspectWebpack: boolean +} + +export interface WebpackConfigContext { + isServer: boolean + isClient: boolean + dev: boolean + type: string +} + +export type ChainWebpackFn = (config: WebpackChainConfig, context: WebpackConfigContext) => void + +export type ConfigureWebpackFn = (config: webpack.Configuration, context: WebpackConfigContext) => void + +export type ConfigureServerFn = (server: express.Express) => void + +export type GeneratedRoutes = string[] + +export interface PluginDef { + name: string + apply: (ream: Ream) => void +} + +export interface GenerateOptions { + routes: GeneratedRoutes +} + +export interface Config { + entry: string + outDir: string + fsRoutes: boolean | { + baseDir: string + basePath: string + match: RegExp + } + transpileDependencies: string[] + runtimeCompiler: boolean + productionSourceMap: boolean + chainWebpack: ChainWebpackFn + configureWebpack: ConfigureWebpackFn + server: { + port: number + host: string + } + plugins: PluginDef[] + generate: GenerateOptions + css: { + extract: boolean + } + pwa: boolean + minimize: boolean + defaultBabelPreset: 'minimal' | false +} + +export class Ream { + constructor(options?: Partial, config?: Partial) + chainWebpack(ChainWebpackFn): void + addGenerateRoutes(GeneratedRoutes): void + hasPlugin(string): PluginDef + loadPlugins(): void + createConfigs(): void + createCompilers(): void + build(): Promise + generate(opts?: GenerateOptions): Promise + generateOnly(opts?: GenerateOptions): Promise + configureServer(fn: ConfigureServerFn): void + prepareFiles(): Promise + writeCreateAppFile(): Promise + writeEntryFile(): Promise + getServer(): Promise + getRequestHandler(): Promise + start(): Promise + prepareWebpack(): Promise + prepareProduction(): Promise + createRenderer({ serverBundle, clientManifest, serverType }: { serverBundle: string | object, clientManifest: object, serverType: 'generate' | 'production' }): void + resolveOutDir(...args): string + resolveBaseDir(...args): string +} + +export default function ream(options?: Partial, config?: Partial): Ream diff --git a/package.json b/package.json index 6e1f875..a4dcd57 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,9 @@ "@babel/plugin-transform-runtime": "^7.0.0-beta.47", "@babel/preset-env": "^7.0.0-beta.47", "@babel/runtime": "^7.0.0-beta.47", + "@types/express": "^4.16.0", + "@types/webpack": "^4.4.20", + "@types/webpack-chain": "^5.0.0", "async-to-gen": "^1.4.0", "babel-helper-vue-jsx-merge-props": "^2.0.3", "babel-loader": "^8.0.0-beta.3", diff --git a/yarn.lock b/yarn.lock index b76838b..03de7ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -729,6 +729,102 @@ into-stream "^3.1.0" lodash "^4.17.4" +"@types/anymatch@*": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.0.tgz#d1d55958d1fccc5527d4aba29fc9c4b942f563ff" + integrity sha512-7WcbyctkE8GTzogDb0ulRAEw7v8oIS54ft9mQTU7PfM0hp5e+8kpa+HeQ7IQrFbKtJXBKcZ4bh+Em9dTw5L6AQ== + +"@types/body-parser@*": + version "1.17.0" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.17.0.tgz#9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c" + integrity sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/connect@*": + version "3.4.32" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.32.tgz#aa0e9616b9435ccad02bc52b5b454ffc2c70ba28" + integrity sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg== + dependencies: + "@types/node" "*" + +"@types/events@*": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" + integrity sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA== + +"@types/express-serve-static-core@*": + version "4.16.0" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.16.0.tgz#fdfe777594ddc1fe8eb8eccce52e261b496e43e7" + integrity sha512-lTeoCu5NxJU4OD9moCgm0ESZzweAx0YqsAcab6OB0EB3+As1OaHtKnaGJvcngQxYsi9UNv0abn4/DRavrRxt4w== + dependencies: + "@types/events" "*" + "@types/node" "*" + "@types/range-parser" "*" + +"@types/express@^4.16.0": + version "4.16.0" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.16.0.tgz#6d8bc42ccaa6f35cf29a2b7c3333cb47b5a32a19" + integrity sha512-TtPEYumsmSTtTetAPXlJVf3kEqb6wZK0bZojpJQrnD/djV4q1oB6QQ8aKvKqwNPACoe02GNiy5zDzcYivR5Z2w== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "*" + "@types/serve-static" "*" + +"@types/mime@*": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.0.tgz#5a7306e367c539b9f6543499de8dd519fac37a8b" + integrity sha512-A2TAGbTFdBw9azHbpVd+/FkdW2T6msN1uct1O9bH3vTerEHKZhTXJUQXy+hNq1B0RagfU8U+KBdqiZpxjhOUQA== + +"@types/node@*": + version "10.12.11" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.11.tgz#715c476c99a5f6898a1ae61caf9825e43c03912e" + integrity sha512-3iIOhNiPGTdcUNVCv9e5G7GotfvJJe2pc9w2UgDXlUwnxSZ3RgcUocIU+xYm+rTU54jIKih998QE4dMOyMN1NQ== + +"@types/range-parser@*": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.2.tgz#fa8e1ad1d474688a757140c91de6dace6f4abc8d" + integrity sha512-HtKGu+qG1NPvYe1z7ezLsyIaXYyi8SoAVqWDZgDQ8dLrsZvSzUNCwZyfX33uhWxL/SU0ZDQZ3nwZ0nimt507Kw== + +"@types/serve-static@*": + version "1.13.2" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.2.tgz#f5ac4d7a6420a99a6a45af4719f4dcd8cd907a48" + integrity sha512-/BZ4QRLpH/bNYgZgwhKEh+5AsboDBcUdlBYgzoLX0fpj3Y2gp6EApyOlM3bK53wQS/OE1SrdSYBAbux2D1528Q== + dependencies: + "@types/express-serve-static-core" "*" + "@types/mime" "*" + +"@types/tapable@*": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370" + integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ== + +"@types/uglify-js@*": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082" + integrity sha512-SudIN9TRJ+v8g5pTG8RRCqfqTMNqgWCKKd3vtynhGzkIIjxaicNAMuY5TRadJ6tzDu3Dotf3ngaMILtmOdmWEQ== + dependencies: + source-map "^0.6.1" + +"@types/webpack-chain@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@types/webpack-chain/-/webpack-chain-5.0.0.tgz#35a60c7e853640a4625047c2f8e43e4352d6a3c0" + integrity sha512-J4DNl1L4cF0Nwxe/tZiRU54iIjvv06ggxPBRMoE+J99y1yHOH+UzHo8UUIjLR9nMiiMqm1/C8yJMKllv7VxEeA== + dependencies: + "@types/webpack" "*" + +"@types/webpack@*", "@types/webpack@^4.4.20": + version "4.4.20" + resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.4.20.tgz#b2108461ac00d983ed966b0f781b451d6431a936" + integrity sha512-uSVhicDIkh2Phkn0L49eZQb4Ory5q9opiqhjxQGu+onh9mbPEhSF5OuA68dmH240VN1+mavQTmkQ1hqnKZB0gA== + dependencies: + "@types/anymatch" "*" + "@types/node" "*" + "@types/tapable" "*" + "@types/uglify-js" "*" + source-map "^0.6.0" + "@vue/component-compiler-utils@^2.0.0": version "2.1.2" resolved "https://registry.yarnpkg.com/@vue/component-compiler-utils/-/component-compiler-utils-2.1.2.tgz#75e7cc8496baecbb0994dc8783571d9ff07737fe"