Skip to content

Commit 2f60ba4

Browse files
committed
fix(reactant-template): fix reactant-template js web
1 parent 9b4c0d9 commit 2f60ba4

File tree

6 files changed

+75
-33
lines changed

6 files changed

+75
-33
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
11
import React from 'react';
2-
import { render } from 'reactant-web';
3-
import {
4-
ViewModule,
5-
createApp,
6-
injectable,
7-
useConnector,
8-
action,
9-
state,
10-
} from 'reactant';
11-
12-
@injectable()
13-
class Counter {
14-
@state
15-
count = 0;
16-
17-
@action
18-
increase() {
19-
this.count += 1;
20-
}
21-
22-
@action
23-
decrease() {
24-
this.count -= 1;
25-
}
26-
}
2+
import { ViewModule, injectable, useConnector } from 'reactant';
3+
import { CounterService } from './counter.service';
274

285
@injectable({
29-
deps: [Counter],
6+
deps: [CounterService],
307
})
318
class AppView extends ViewModule {
329
constructor(counter) {
@@ -50,9 +27,4 @@ class AppView extends ViewModule {
5027
}
5128
}
5229

53-
const app = createApp({
54-
main: AppView,
55-
render,
56-
});
57-
58-
app.bootstrap(document.getElementById('app'));
30+
export { AppView };
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { injectable, action, state } from 'reactant';
2+
3+
@injectable()
4+
class CounterService {
5+
@state
6+
count = 0;
7+
8+
@action
9+
increase() {
10+
this.count += 1;
11+
}
12+
13+
@action
14+
decrease() {
15+
this.count -= 1;
16+
}
17+
}
18+
19+
export { CounterService };
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { testBed } from 'reactant';
2+
import { CounterService } from './counter.service';
3+
4+
describe('CounterService', () => {
5+
let module;
6+
7+
beforeEach(() => {
8+
module = testBed({
9+
main: CounterService,
10+
modules: [],
11+
}).instance;
12+
});
13+
14+
test('should be created', () => {
15+
expect(module instanceof CounterService).toBeTruthy();
16+
});
17+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { render } from 'reactant-web';
2+
import { createApp } from 'reactant';
3+
import { AppView } from './app.view';
4+
5+
const app = createApp({
6+
modules: [],
7+
main: AppView,
8+
render,
9+
});
10+
11+
app.bootstrap(document.getElementById('app'));

packages/reactant-template/templates/web/javascript/template/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path');
33
const CopyWebpackPlugin = require('copy-webpack-plugin');
44

55
module.exports = {
6-
entry: './src/index.jsx',
6+
entry: './src/index.js',
77
output: {
88
path: path.resolve(__dirname, 'dist'),
99
filename: 'bundle.js',

0 commit comments

Comments
 (0)