Skip to content

Commit 125818a

Browse files
committed
version bump, fixes for 0.0.16 and 0.0.17
1 parent 217ca1d commit 125818a

File tree

15 files changed

+102
-100
lines changed

15 files changed

+102
-100
lines changed

docs/backlog.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Develop `$ incept build` Script
44
- Develop `$ incept start` Script
55
- Develop `$ incept lint` Script
6+
- Develop npx starter called `create-incept-app`
67
- Move scripts to a package called `devops`
78
- Move babel configuration into a package called `presets`
89
- Move webpack configuration into a package called `presets`
@@ -51,13 +52,6 @@ There is a huge overlap between Babel and Webpack in terms of intent.
5152
If babel is for transpiling and webpack is for bundling, what's up
5253
with isomorphic plugins?
5354

54-
**Isomorphic Babel & Webpack**
55-
56-
Both of these projects suffer from plugins that need to be isomorphic
57-
being outdated in a matter of years like CSS, SVG, file & url importing.
58-
I ended up fixing and hosting up a fork of
59-
[`babel-plugin-file-loader`](https://github.com/cblanquera/babel-plugin-file-loader)
60-
6155
**webpack-dev-middleware**
6256

6357
For some reason `webpack-dev-middleware` is compiling for the

packages/admin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inceptjs/admin",
3-
"version": "0.0.17",
3+
"version": "0.0.18",
44
"description": "Incept Admin",
55
"author": "Chris <chris@incept.asia>",
66
"license": "MIT",
@@ -12,7 +12,7 @@
1212
],
1313
"dependencies": {
1414
"boxicons": "2.0.9",
15-
"inceptjs": "^0.0.17",
15+
"inceptjs": "^0.0.18",
1616
"react-redux": "^7.2.5",
1717
"redux-thunk": "^2.3.0",
1818
"redux": "^4.1.1"

packages/framework/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/framework/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inceptjs/framework",
3-
"version": "0.0.17",
3+
"version": "0.0.18",
44
"description": "Defines basic framework concepts",
55
"author": "Chris <chris@incept.asia>",
66
"license": "MIT",
@@ -22,7 +22,7 @@
2222
"build": "tsc"
2323
},
2424
"dependencies": {
25-
"@inceptjs/types": "^0.0.17",
25+
"@inceptjs/types": "^0.0.18",
2626
"mime": "^2.5.2"
2727
},
2828
"devDependencies": {

packages/incept/package-lock.json

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/incept/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "inceptjs",
3-
"version": "0.0.17",
3+
"version": "0.0.18",
44
"description": "A pluggable React framework",
55
"author": "Chris <chris@incept.asia>",
66
"license": "MIT",
@@ -31,8 +31,8 @@
3131
"@babel/preset-env": "^7.15.0",
3232
"@babel/preset-react": "^7.14.5",
3333
"@babel/register": "^7.15.3",
34-
"@inceptjs/framework": "^0.0.17",
35-
"@inceptjs/virtualfs": "^0.0.17",
34+
"@inceptjs/framework": "^0.0.18",
35+
"@inceptjs/virtualfs": "^0.0.18",
3636
"@loadable/babel-plugin": "5.13.2",
3737
"@loadable/component": "5.15.0",
3838
"@loadable/server": "5.15.1",

packages/incept/src/plugin/develop.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function startDevServer(
2121
const webpack = app.withWebpack;
2222
//log all errors
2323
app.on('error', logError.bind(app));
24+
//virtualize react files
25+
react.virtualize();
2426
//load webpack
2527
const {dev, hot} = webpack.develop(!!write);
2628
app.use(dev);

packages/incept/src/react/index.ts

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { StaticRouter, matchPath } from 'react-router';
77
import { Request, Response } from '@inceptjs/framework';
88

99
import { Application } from '../types/Application';
10+
import Exception from './Exception';
1011
import Page from './Page';
11-
import { Exception } from '..';
1212

1313
export default class WithReact {
1414
/**
@@ -19,12 +19,12 @@ export default class WithReact {
1919
/**
2020
* The file path to the App component
2121
*/
22-
protected _app: string;
22+
protected _app: string = '';
2323

2424
/**
2525
* The file path to the client entry
2626
*/
27-
protected _entry: string;
27+
protected _entry: string = '';
2828

2929
/**
3030
* The page component
@@ -62,13 +62,7 @@ export default class WithReact {
6262
*/
6363
set app(app: string) {
6464
const resolved = this._application.withVirtualFS.resolvePath(app);
65-
Exception.require(!!resolved, 'Cannot find module %s', app);
66-
const App = fs.readFileSync(resolved as string, 'utf8');
67-
const props = this._generateProps();
68-
this._application.withVirtualFS.writeFileSync(
69-
path.join(this._application.cwd, 'App.js'),
70-
App.replace(/\nconst props[^\n]+/g, `\n${props}\n`)
71-
);
65+
Exception.require(!!resolved, 'Module not found %s', app);
7266
this._app = resolved as string;
7367
}
7468

@@ -77,11 +71,7 @@ export default class WithReact {
7771
*/
7872
set entry(entry: string) {
7973
const resolved = this._application.withVirtualFS.resolvePath(entry);
80-
Exception.require(!!resolved, 'Cannot find module %s', entry);
81-
this._application.withVirtualFS.writeFileSync(
82-
path.join(this._application.cwd, 'entry.js'),
83-
fs.readFileSync(resolved as string, 'utf8')
84-
);
74+
Exception.require(!!resolved, 'Module not found %s', entry);
8575
this._entry = resolved as string;
8676
}
8777

@@ -99,29 +89,27 @@ export default class WithReact {
9989
this._application = app;
10090
//make a virtual cwd
10191
app.withVirtualFS.mkdirSync(app.cwd, { recursive: true });
102-
this._entry = path.normalize(
92+
//set a default entry
93+
this.entry = path.normalize(
10394
path.join(__dirname, '../../templates/entry')
10495
);
105-
this._app = path.normalize(
96+
//set a default app
97+
this.app = path.normalize(
10698
path.join(__dirname, '../../templates/App')
10799
);
100+
//set a default layout
108101
this._layouts.default = path.normalize(
109102
path.join(__dirname, '../../templates/Layout')
110103
);
104+
//set a default page
111105
this._page = this.makePage();
112106
}
113107

114108
/**
115109
* sets a config file
116110
*/
117111
config(name: string, file: string): WithReact {
118-
this._props[name] = file;
119-
const App = fs.readFileSync(this._app as string, 'utf8');
120-
const props = this._generateProps();
121-
this._application.withVirtualFS.writeFileSync(
122-
path.join(this._application.cwd, 'App.js'),
123-
App.replace(/\nconst props[^\n]+/g, `\n${props}\n`)
124-
);
112+
this._props[name] = file
125113
return this
126114
}
127115

@@ -237,6 +225,24 @@ export default class WithReact {
237225
return page.render(app);
238226
}
239227

228+
/**
229+
* Adds dynamically rendered files to node's FS
230+
*/
231+
virtualize() {
232+
//copy entry to cwd/entry.js
233+
this._application.withVirtualFS.writeFileSync(
234+
path.join(this._application.cwd, 'entry.js'),
235+
fs.readFileSync(this._entry as string, 'utf8')
236+
);
237+
//copy App to cwd/App.js
238+
const App = fs.readFileSync(this._app as string, 'utf8');
239+
const props = this._generateProps();
240+
this._application.withVirtualFS.writeFileSync(
241+
path.join(this._application.cwd, 'App.js'),
242+
App.replace(/\nconst props[^\n]+/g, `\n${props}\n`)
243+
);
244+
}
245+
240246
private _generateProps(): string {
241247
const importClause = `const %s = loadable(_ => import('%s'))`;
242248
const routes = this.routes;

packages/incept/src/types/Application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ export default class Application extends http.Router {
9898
this._config = Object.assign({}, defaults, config);
9999
this._pluginManager = new PluginLoader(this._config.cwd);
100100

101+
this.withVirtualFS = vfs;
101102
this.withBabel = new WithBabel;
102103
this.withReact = new WithReact(this);
103104
this.withWebpack = new WithWebpack(this);
104-
this.withVirtualFS = vfs;
105105
this.withVirtualFS.patchFS();
106106
}
107107

packages/incept/src/webpack/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default class WithWebpack {
116116
]);
117117

118118
//build a webpack compiler
119-
const compiler = bundler.compiler
119+
const compiler = bundler.compiler;
120120

121121
const dev = webpackDevMiddleware(compiler, {
122122
serverSideRender: true,

0 commit comments

Comments
 (0)