Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #53 from zalando-incubator/37-combine-server-with-…
Browse files Browse the repository at this point in the history
…bundler

Use tessellate-server in bundler
  • Loading branch information
mfellner committed Feb 3, 2017
2 parents a51c575 + c28bacb commit 6c4446b
Show file tree
Hide file tree
Showing 27 changed files with 7,319 additions and 400 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ branches:
- master
language: node_js
node_js:
- "6"
- "7"
env:
- CXX=g++-4.8
addons:
Expand All @@ -20,6 +20,10 @@ cache:
- packages/tessellate-bundler/node_modules
- packages/tessellate-editor/node_modules
- packages/tessellate-fragment/node_modules
- packages/tessellate-render/node_modules
- packages/tessellate-request/node_modules
- packages/tessellate-server/node_modules
- packages/tessellate-transform/node_modules
- packages/tessellate-viewer/node_modules
before_install:
- .travis/before_install.sh
Expand Down
10 changes: 4 additions & 6 deletions packages/tessellate-bundler/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
[include]

[libs]
./../../flow-typed/
./flow-typed/
./declarations/

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
experimental.strict_type_args=true

suppress_type=$FlowIssue
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue

[version]
^0.33.0
suppress_type=$FlowIgnore
suppress_comment=\\(.\\|\n\\)*\\$FlowIgnore
1 change: 1 addition & 0 deletions packages/tessellate-bundler/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/dist
/bundles
/flow-typed
2 changes: 1 addition & 1 deletion packages/tessellate-bundler/bin/tessellate-bundler
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('../dist/server.js')
require('../dist/server.js').main()
17 changes: 17 additions & 0 deletions packages/tessellate-bundler/declarations/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
declare type TessellateBundle = {
js: {
name: string;
source: string;
};
css?: {
name: string;
source: string;
};
};

declare type TessellateElement = {
type: string;
style?: string;
props: { [key: string]: any } | null;
children?: Array<TessellateElement | string>;
};
66 changes: 33 additions & 33 deletions packages/tessellate-bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,54 @@
"url": "https://github.com/zalando-incubator/tessellate.git"
},
"scripts": {
"dist": "webpack",
"clean": "rimraf dist/*",
"dist": "babel -d dist src",
"start": "DEBUG=tessellate-bundler:*,webpack-sandboxed:* babel-node src/server.js",
"lint": "eslint .",
"test": "NODE_ENV=test jest --coverage"
"test": "NODE_ENV=test jest --coverage",
"flow-check": "flow check",
"flow-typed-install": "rimraf flow-typed/npm/*_vx.x.x.js && flow-typed install -o",
"prepublish": "npm run clean && npm run dist"
},
"dependencies": {
"babel-core": "6.17.0",
"babel-loader": "6.2.5",
"babel-preset-es2015": "6.16.0",
"babel-preset-react": "6.16.0",
"change-case": "3.0.0",
"css-loader": "0.25.0",
"debug": "2.2.0",
"babel-core": "6.22.1",
"babel-loader": "6.2.10",
"babel-preset-es2015": "6.22.0",
"babel-preset-react": "6.22.0",
"change-case": "3.0.1",
"css-loader": "0.26.1",
"debug": "2.6.0",
"extract-text-webpack-plugin": "2.0.0-beta.4",
"js-yaml": "3.6.1",
"js-yaml": "3.7.0",
"kcors": "2.2.0",
"koa": "2.0.0-alpha.7",
"koa-bodyparser": "3.2.0",
"koa-morgan": "1.0.1",
"koa-router": "7.0.1",
"koa-static": "3.0.0",
"mkdirp": "0.5.1",
"mz": "2.4.0",
"mz": "2.6.0",
"nconf": "0.8.4",
"prom-client": "6.1.0",
"prometheus-gc-stats": "0.3.1",
"style-loader": "0.13.1",
"tessellate-server": "1.1.0",
"thenify": "3.2.1",
"uuid": "2.0.3",
"webpack": "2.1.0-beta.25",
"uuid": "3.0.1",
"webpack": "2.2.1",
"webpack-sandboxed": "0.1.0"
},
"peerDependencies": {
"koa": "2.x.x",
"koa-router-rx": "0.3.x",
"rxjs": "5.x.x"
},
"devDependencies": {
"babel-cli": "6.16.0",
"babel-eslint": "7.0.0",
"babel-jest": "16.0.0",
"babel-plugin-syntax-flow": "6.13.0",
"babel-plugin-transform-flow-strip-types": "6.14.0",
"babel-cli": "6.22.2",
"babel-eslint": "7.1.1",
"babel-jest": "18.0.0",
"babel-plugin-syntax-flow": "6.18.0",
"babel-plugin-transform-flow-strip-types": "6.22.0",
"babel-preset-latest-minimal": "1.1.2",
"eslint": "3.8.1",
"eslint-plugin-babel": "3.3.0",
"eslint-plugin-flowtype": "2.20.0",
"eslint-plugin-promise": "3.3.0",
"eslint-plugin-react": "6.4.1",
"jest": "16.0.1",
"flow-bin": "0.38.0",
"flow-typed": "2.0.0",
"jest": "18.1.0",
"mosaic-component-example": "1.0.2",
"supertest": "2.0.0",
"supertest-as-promised": "4.0.0"
"rimraf": "2.5.4",
"supertest": "3.0.0"
},
"jest": {
"testEnvironment": "node",
Expand Down
56 changes: 0 additions & 56 deletions packages/tessellate-bundler/src/actions/bundles.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/tessellate-bundler/src/actions/content.js

This file was deleted.

4 changes: 0 additions & 4 deletions packages/tessellate-bundler/src/actions/index.js

This file was deleted.

21 changes: 5 additions & 16 deletions packages/tessellate-bundler/src/bundle-service.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
// @flowimport path from 'path'
// @flow
import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import WebpackSandbox from 'webpack-sandboxed'
import logger from './logger'
import * as utils from './utils'

export type BundleType = {
js: {
name: string;
source: string;
};
css?: {
name: string;
source: string;
};
};

type Options = {
cssSupport?: boolean;
production?: boolean;
packages: ?Array<string>;
externals: ?{ [key: string]: string };
packages?: Array<string>;
externals?: { [key: string]: string };
}

const log = logger('bundle-service')

async function _createWebpackSandbox(args: Options = {}): Promise<WebpackSandbox> {
let loaders = [{
test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: {
test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', options: {
presets: ['es2015', 'react']
}
}]
Expand Down Expand Up @@ -82,7 +71,7 @@ async function _createWebpackSandbox(args: Options = {}): Promise<WebpackSandbox

const createWebpackSandbox = utils.memoize(_createWebpackSandbox)

export async function make(source: string, options: Options = {}): Promise<BundleType> {
export async function make(source: string, options: Options = {}): Promise<TessellateBundle> {
log.debug('Create WebpackSandbox with options %o', options)
const sandbox = await createWebpackSandbox(options)
log.debug('Compile bundle...')
Expand Down
19 changes: 6 additions & 13 deletions packages/tessellate-bundler/src/content-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,19 @@ import fs from 'mz/fs'
import thenify from 'thenify'
import nconf from './nconf'
import logger from './logger'
import { Problem } from './error'

import type { BundleType } from './bundle-service'
import { Problem } from 'tessellate-server'

type ExportArgs = {|
domain: string;
name: string;
bundle: BundleType;
bundle: TessellateBundle;
|}

type FetchArgs = {|
domain: string;
name: string;
|}

type ElementType = {
type: string;
props: { [key: string]: any };
children?: Array<ElementType>;
}

type PublishResult = {
js: string;
css?: string;
Expand Down Expand Up @@ -72,8 +64,9 @@ async function publishToFileSystem(target: string, args: ExportArgs): Promise<Pu
await mkdirp(basePath)
await fs.writeFile(path.resolve(process.cwd(), jsPath), args.bundle.js.source)

if (args.bundle.css && args.bundle.css.source) {
await fs.writeFile(path.resolve(process.cwd(), cssPath), args.bundle.css.source)
if (typeof args.bundle.css === 'object' && typeof args.bundle.css.source === 'string') {
const cssSource = args.bundle.css.source
await fs.writeFile(path.resolve(process.cwd(), cssPath), cssSource)
result.css = path.relative(target, cssPath)
}

Expand All @@ -84,7 +77,7 @@ async function publishToS3(): Promise<PublishResult> {
throw new Error('publishToS3 not implemented.')
}

export async function fetch(args: FetchArgs): Promise<ElementType> {
export async function fetch(args: FetchArgs): Promise<TessellateElement> {
log.debug('Fetch %s/%s', args.domain, args.name)
throw new Error('fetch not implemented.')
}
36 changes: 0 additions & 36 deletions packages/tessellate-bundler/src/dispatch.js

This file was deleted.

Loading

0 comments on commit 6c4446b

Please sign in to comment.