Skip to content

Commit 0bfd93e

Browse files
committed
Fix errors in 2.0
1 parent 55e6431 commit 0bfd93e

File tree

14 files changed

+284
-44
lines changed

14 files changed

+284
-44
lines changed

packages/create-cycle-app/package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@
2222
"create-cycle-app": "./index.js"
2323
},
2424
"dependencies": {
25-
"@cycle/dom": "^18.0.0",
26-
"@cycle/http": "^14.0.0",
27-
"@cycle/isolate": "^3.0.0",
28-
"@cycle/run": "^3.1.0",
29-
"@cycle/time": "^0.8.0",
30-
"chalk": "^1.1.3",
31-
"cross-spawn": "^4.0.2",
32-
"cycle-onionify": "^3.3.0",
25+
"@cycle/dom": "^18.3.0",
26+
"@cycle/http": "^14.4.0",
27+
"@cycle/isolate": "^3.1.0",
28+
"@cycle/run": "^3.3.0",
29+
"@cycle/time": "^0.10.1",
30+
"chalk": "^2.1.0",
31+
"cross-spawn": "^5.1.0",
32+
"cycle-onionify": "^4.0.0",
3333
"inquirer": "^3.3.0",
3434
"minimist": "^1.2.0",
35-
"xstream": "^10.9.0"
35+
"xstream": "^11.0.0"
3636
},
3737
"devDependencies": {
3838
"cycle-restart": "^0.2.2",
39-
"cyclejs-test-helpers": "^1.3.0",
40-
"fs-extra": "^2.1.2",
39+
"cyclejs-test-helpers": "^1.4.0",
40+
"fs-extra": "^4.0.2",
4141
"html-looks-like": "^1.0.3",
42-
"jest": "^18.1.0",
43-
"jsverify": "^0.8.2",
44-
"snabbdom-to-html": "^3.2.0"
42+
"jest": "^21.2.1",
43+
"jsverify": "^0.8.3",
44+
"snabbdom-to-html": "^3.3.0"
4545
},
4646
"repository": {
4747
"type": "git",
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
module.exports = {
22
basics: [
3-
'@cycle/dom@17.1.0'
3+
'@cycle/dom@18.3.0'
44
],
55
language: {
66
javascript: [],
7-
typescript: []
7+
typescript: [
8+
9+
10+
]
811
},
912
streamLib: {
1013
xstream: [
11-
'@cycle/run@3.1.0',
12-
'xstream@10.5.0'
14+
'@cycle/run@3.3.0',
15+
'xstream@11.0.0'
1316
],
1417
rxjs: [
15-
'@cycle/rxjs-run@7.0.0',
16-
'rxjs@5.3.0'
18+
'@cycle/rxjs-run@7.1.0',
19+
'rxjs@5.4.3'
1720
],
1821
most: [
19-
'@cycle/most-run@7.1.0',
20-
'most@1.2.2'
22+
'@cycle/most-run@7.2.0',
23+
'most@1.7.2'
2124
]
2225
}
2326
}

packages/cycle-scripts/configs/javascript/webpack.config.dev.js

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ module.exports = {
3434
paths.appIndex
3535
]
3636
},
37+
resolve: {
38+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
39+
},
3740
output: {
3841
// This does not produce a real file. It's just the virtual path that is
3942
// served by WebpackDevServer in development. This is the JS bundle

packages/cycle-scripts/configs/javascript/webpack.config.prod.js

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ module.exports = {
2929
// The output path where webpack will write the bundle
3030
path: paths.appBuild
3131
},
32+
resolve: {
33+
extensions: ['.js', '.ts', '.tsx', '.jsx', '.json']
34+
},
3235
module: {
3336
rules: [
3437
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
'use strict'
2+
3+
// Silence webpack2 deprecation warnings
4+
// https://github.com/vuejs/vue-loader/issues/666
5+
process.noDeprecation = true
6+
7+
const HtmlWebpackPlugin = require('html-webpack-plugin')
8+
const path = require('path')
9+
const webpack = require('webpack')
10+
const { CheckerPlugin } = require('awesome-typescript-loader')
11+
12+
// Paths to be used for webpack configuration
13+
const paths = {
14+
appSrc: path.join(process.cwd(), 'src'),
15+
appIndex: path.join(process.cwd(), 'src', 'index.ts'),
16+
appBuild: path.join(process.cwd(), 'build'),
17+
public: '/'
18+
}
19+
20+
module.exports = {
21+
entry: {
22+
main: [
23+
// Include an alternative client for WebpackDevServer. A client's job is to
24+
// connect to WebpackDevServer by a socket and get notified about changes.
25+
// When you save a file, the client will either apply hot updates (in case
26+
// of CSS changes), or refresh the page (in case of JS changes). When you
27+
// make a syntax error, this client will display a syntax error overlay.
28+
// Note: instead of the default WebpackDevServer client, we use a custom one
29+
// to bring better experience from Create React App users. You can replace
30+
// the line below with these two lines if you prefer the stock client:
31+
// require.resolve('webpack-dev-server/client') + '?/',
32+
// require.resolve('webpack/hot/dev-server'),
33+
require.resolve('react-dev-utils/webpackHotDevClient'),
34+
// Your app's code
35+
paths.appIndex
36+
]
37+
},
38+
resolve: {
39+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
40+
},
41+
output: {
42+
// This does not produce a real file. It's just the virtual path that is
43+
// served by WebpackDevServer in development. This is the JS bundle
44+
// containing code from all our entry points, and the Webpack runtime.
45+
filename: 'static/js/bundle.js',
46+
// Not used in dev but WebpackDevServer crashes without it:
47+
path: paths.appBuild,
48+
// The URL that app is served from. We use "/" in development.
49+
publicPath: paths.public
50+
},
51+
module: {
52+
rules: [
53+
{
54+
// We use babel-loader to transipile every .js or .jsx file
55+
test: /\.jsx?$/,
56+
loader: 'babel-loader',
57+
// Including over excluding as a whitelist is easier to maintain than a blacklist.
58+
// as per http://stackoverflow.com/questions/31675025/how-to-exclude-nested-node-module-folders-from-a-loader-in-webpack
59+
include: paths.appSrc,
60+
options: {
61+
// This is a feature of `babel-loader` for webpack (not Babel itself).
62+
// It enables caching results in ./node_modules/.cache/babel-loader/
63+
// directory for faster rebuilds.
64+
cacheDirectory: true,
65+
// Instead of relying on a babelrc file to configure babel (or in package.json configs)
66+
// We speficy here which presets to use. In the future this could be moved to it's own
67+
// package as create-react-app does with their 'babel-preset-react-app module
68+
babelrc: false,
69+
presets: [
70+
[ 'env', {
71+
'targets': {
72+
'browsers': ['last 2 versions']
73+
}
74+
}]
75+
],
76+
plugins: [
77+
// https://cycle.js.org/getting-started.html#getting-started-coding-consider-jsx
78+
// This allow us to use JSX to create virtual dom elements instead of Snabbdom helpers like div(), input(), ..
79+
['transform-react-jsx', { pragma: 'Snabbdom.createElement' }],
80+
// Allow Babel to transform rest properties for object destructuring assignment and spread properties for object literals.
81+
['transform-object-rest-spread']
82+
]
83+
}
84+
},
85+
{
86+
test: /\.tsx?$/,
87+
loader: 'awesome-typescript-loader'
88+
}
89+
]
90+
},
91+
plugins: [
92+
new CheckerPlugin(),
93+
// This is necessary to emit hot updates (currently CSS only):
94+
new webpack.HotModuleReplacementPlugin(),
95+
// Generates an `index.html` file with the <script> injected.
96+
new HtmlWebpackPlugin({
97+
template: 'public/index.html',
98+
inject: true,
99+
favicon: 'public/favicon.png',
100+
hash: true
101+
}),
102+
// Makes environment variables available to the JS code, fallback to 'development'
103+
new webpack.DefinePlugin({
104+
DEVELOPMENT: JSON.stringify(process.env.NODE_ENV === 'development')
105+
}),
106+
// To be used for JSX support
107+
new webpack.ProvidePlugin({
108+
Snabbdom: 'snabbdom-pragma'
109+
})
110+
],
111+
devtool: 'inline-source-map'
112+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
'use strict'
2+
3+
// Silence webpack2 deprecation warnings
4+
// https://github.com/vuejs/vue-loader/issues/666
5+
process.noDeprecation = true
6+
7+
const path = require('path')
8+
const HtmlWebpackPlugin = require('html-webpack-plugin')
9+
const webpack = require('webpack')
10+
const { CheckerPlugin } = require('awesome-typescript-loader')
11+
12+
// Paths to be used for webpack configuration
13+
const paths = {
14+
appSrc: path.join(process.cwd(), 'src'),
15+
appIndex: path.join(process.cwd(), 'src', 'index.ts'),
16+
appBuild: path.join(process.cwd(), 'build'),
17+
public: '/'
18+
}
19+
20+
module.exports = {
21+
entry: {
22+
main: [
23+
// Your app's code
24+
paths.appIndex
25+
]
26+
},
27+
output: {
28+
// This is the productin JS bundle containing code from all our entry points.
29+
filename: 'bundle.js',
30+
// The output path where webpack will write the bundle
31+
path: paths.appBuild
32+
},
33+
resolve: {
34+
extensions: ['.js', '.ts', '.tsx', '.jsx', '.json']
35+
},
36+
module: {
37+
rules: [
38+
{
39+
// We use babel-loader to transipile every .js or .jsx file
40+
test: /\.jsx?$/,
41+
loader: 'babel-loader',
42+
// Including over excluding as a whitelist is easier to maintain than a blacklist.
43+
// as per http://stackoverflow.com/questions/31675025/how-to-exclude-nested-node-module-folders-from-a-loader-in-webpack
44+
include: paths.appSrc,
45+
options: {
46+
// This is a feature of `babel-loader` for webpack (not Babel itself).
47+
// It enables caching results in ./node_modules/.cache/babel-loader/
48+
// directory for faster rebuilds.
49+
cacheDirectory: true,
50+
// Instead of relying on a babelrc file to configure babel (or in package.json configs)
51+
// We speficy here which presets to use. In the future this could be moved to it's own
52+
// package as create-react-app does with their 'babel-preset-react-app module.
53+
// As uglify doesn't support es6 code yet, the uglify param will tell babel plugin to transpile to es5
54+
// in order for the output to be uglified.
55+
presets: [
56+
[ 'env', {
57+
'targets': {
58+
'browsers': ['last 2 versions'],
59+
uglify: true
60+
}
61+
}]
62+
],
63+
plugins: [
64+
// https://cycle.js.org/getting-started.html#getting-started-coding-consider-jsx
65+
// This allow us to use JSX to create virtual dom elements instead of Snabbdom helpers like div(), input(), ..
66+
['transform-react-jsx', { pragma: 'Snabbdom.createElement' }],
67+
// Allow Babel to transform rest properties for object destructuring assignment and spread properties for object literals.
68+
['transform-object-rest-spread']
69+
]
70+
}
71+
},
72+
{
73+
test: /\.tsx?$/,
74+
loader: 'awesome-typescript-loader'
75+
}
76+
]
77+
},
78+
plugins: [
79+
new CheckerPlugin(),
80+
// Generates an `index.html` file with the <script> injected.
81+
new HtmlWebpackPlugin({
82+
template: 'public/index.html',
83+
inject: true,
84+
favicon: 'public/favicon.png',
85+
hash: true
86+
}),
87+
// Makes environment variables available to the JS code, fallback to 'production'
88+
new webpack.DefinePlugin({
89+
PRODUCTION: JSON.stringify(process.env.NODE_ENV === 'production')
90+
}),
91+
// To be used for JSX support
92+
new webpack.ProvidePlugin({
93+
Snabbdom: 'snabbdom-pragma'
94+
}),
95+
// Uglify plugin, depending on the devtool options, Source Maps are generated.
96+
new webpack.optimize.UglifyJsPlugin({
97+
sourceMap: this.devtool && this.devtool.indexOf('source-map') >= 0
98+
})
99+
],
100+
devtool: 'cheap-module-source-map'
101+
}

packages/cycle-scripts/index.js

100644100755
File mode changed.

packages/cycle-scripts/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@
3131
},
3232
"dependencies": {
3333
"babel-core": "^6.26.0",
34-
"babel-loader": "^6.4.1",
34+
"babel-loader": "^7.1.2",
3535
"babel-plugin-transform-object-rest-spread": "^6.26.0",
3636
"babel-plugin-transform-react-jsx": "^6.24.1",
3737
"babel-preset-env": "^1.6.0",
38-
"chalk": "^1.1.3",
38+
"chalk": "^2.1.0",
3939
"cross-spawn": "^5.1.0",
40-
"fs-extra": "^2.1.2",
40+
"fs-extra": "^4.0.2",
4141
"html-webpack-plugin": "^2.30.1",
4242
"inquirer": "^3.3.0",
43-
"jest": "^19.0.2",
44-
"react-dev-utils": "^0.5.2",
45-
"snabbdom-pragma": "^1.10.0",
46-
"webpack": "^2.7.0",
43+
"jest": "^21.2.1",
44+
"react-dev-utils": "^4.1.0",
45+
"snabbdom-pragma": "^2.5.0",
46+
"webpack": "^3.6.0",
4747
"webpack-dev-server": "^2.9.1"
4848
}
4949
}

packages/cycle-scripts/scripts/build.js

-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const notEjected = require(path.join(process.cwd(), 'package.json')).cca
4545

4646
const FileSizeReporter = require('react-dev-utils/FileSizeReporter')
4747
const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild
48-
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild
4948

5049
const config = require(path.join(
5150
'../configs/',
@@ -117,9 +116,6 @@ function build (previousFileSizes) {
117116
console.log(chalk.green('Compiled successfully.'))
118117
console.log()
119118

120-
console.log('File sizes after gzip:')
121-
console.log()
122-
printFileSizesAfterBuild(stats, previousFileSizes)
123119
console.log()
124120
})
125121
// todo better output

packages/cycle-scripts/scripts/init/setup.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ module.exports = function setup (appPath, appName, options) {
2626
fs.ensureDirSync(path.join(appPath, 'src'))
2727
// Get templates in cycle-scripts/template/src/<language>
2828
// Interpolate them and write compiled files in ./src
29-
fs.readdir(templatePath, (err, files) => {
30-
if (err) {
31-
throw err
32-
}
33-
files.forEach(file => {
34-
const targetPath = path.join(appPath, 'src', file)
35-
const template = require(path.join(templatePath, file))
36-
const targetContent = template(templateStrings[streamLib])
37-
fs.outputFile(targetPath, targetContent)
38-
})
29+
const files = fs.readdirSync(templatePath)
30+
files.forEach(file => {
31+
const targetPath = path.join(appPath, 'src', file)
32+
const template = require(path.join(templatePath, file))
33+
const targetContent = template(templateStrings[streamLib])
34+
fs.outputFile(targetPath, targetContent)
3935
})
4036
// Copy cycle-scripts/template/gitgnore to ./.gitignore
4137
fs.copySync(path.join(flavorPath, 'template', 'gitignore'), path.join(appPath, '.gitignore'))
4238

39+
if (language === 'typescript') {
40+
fs.copySync(path.join(flavorPath, 'template', 'tsconfig.json'), path.join(appPath, 'tsconfig.json'))
41+
fs.copySync(path.join(flavorPath, 'template', 'custom-typings.d.ts'), path.join(appPath, 'custom-typings.d.ts'))
42+
}
43+
4344
// STEP #2 - Edit package.json
4445
// Retrieve package.json content
4546
const packageJsonPath = path.join(appPath, 'package.json')

packages/cycle-scripts/template/config/typescript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
},
99
rxjs: {
1010
run: '@cycle/rxjs-run',
11-
import: 'import Rx from \'rxjs/Rx\'',
11+
import: 'import * as Rx from \'rxjs\'',
1212
typeImport: 'import {Observable} from \'rxjs\'',
1313
stream: 'Rx.Observable',
1414
streamType: 'Observable'

0 commit comments

Comments
 (0)