-
-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed null value display when using angular universal (#852)
fixes #764
- Loading branch information
1 parent
c115f59
commit 77482c0
Showing
17 changed files
with
1,614 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { SpecReporter } = require('jasmine-spec-reporter'); | ||
|
||
exports.config = { | ||
allScriptsTimeout: 11000, | ||
specs: [ | ||
'./src/**/*.server-e2e-spec.ts' | ||
], | ||
capabilities: { | ||
browserName: 'chrome', | ||
}, | ||
directConnect: true, | ||
baseUrl: 'http://localhost:4000/', | ||
framework: 'jasmine', | ||
jasmineNodeOpts: { | ||
showColors: true, | ||
defaultTimeoutInterval: 30000, | ||
print: function() {} | ||
}, | ||
onPrepare() { | ||
require('ts-node').register({ | ||
project: require('path').join(__dirname, './tsconfig.e2e.json') | ||
}); | ||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { browser, by } from 'protractor'; | ||
|
||
describe('ng-select:universal', () => { | ||
beforeEach(() => { | ||
browser.driver.get(browser.baseUrl + '/'); | ||
}); | ||
|
||
it('should not have null value', async() => { | ||
const input = await browser.driver.findElement(by.css('.ng-input input')); | ||
const value = await input.getAttribute('value'); | ||
expect(value).not.toEqual('null'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'zone.js/dist/zone-node'; | ||
import 'reflect-metadata'; | ||
import { enableProdMode } from '@angular/core'; | ||
import * as express from 'express'; | ||
import { join } from 'path'; | ||
import { ngExpressEngine } from '@nguniversal/express-engine'; | ||
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader'; | ||
import { AppServerModuleNgFactory, LAZY_MODULE_MAP } from './dist/integration-server/main'; | ||
|
||
enableProdMode(); | ||
|
||
const app = express(); | ||
const PORT = process.env.PORT || 4000; | ||
const DIST_FOLDER = join(process.cwd(), 'dist'); | ||
|
||
app.engine('html', ngExpressEngine({ | ||
bootstrap: AppServerModuleNgFactory, | ||
providers: [ | ||
provideModuleMap(LAZY_MODULE_MAP), | ||
], | ||
})); | ||
|
||
app.set('view engine', 'html'); | ||
app.set('views', join(DIST_FOLDER, 'integration')); | ||
app.get('*.*', express.static(join(DIST_FOLDER, 'integration'))); | ||
app.get('*', (req, res) => { | ||
res.render('index', {req}); | ||
}); | ||
app.listen(PORT, () => { | ||
console.log(`Node server listening on http://localhost:${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { ServerModule } from '@angular/platform-server'; | ||
|
||
import { AppModule } from './app.module'; | ||
import { AppComponent } from './app.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
AppModule, | ||
ServerModule, | ||
], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppServerModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const environment = { | ||
production: false, | ||
manualBootstrap: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AppServerModule } from './app/app.server.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.app.json", | ||
"compilerOptions": { | ||
"outDir": "../out-tsc/app-server", | ||
"baseUrl": "." | ||
}, | ||
"angularCompilerOptions": { | ||
"entryModule": "app/app.server.module#AppServerModule" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
module.exports = { | ||
entry: { server: './server.ts' }, | ||
resolve: { extensions: ['.js', '.ts'] }, | ||
target: 'node', | ||
mode: 'none', | ||
externals: [/node_modules/], | ||
output: { | ||
path: path.join(__dirname, 'dist/integration-server'), | ||
filename: '[name].js' | ||
}, | ||
module: { | ||
rules: [{ test: /\.ts$/, loader: 'ts-loader' }] | ||
}, | ||
plugins: [ | ||
// Temporary Fix for issue: https://github.com/angular/angular/issues/11580 | ||
// for 'WARNING Critical dependency: the request of a dependency is an expression' | ||
new webpack.ContextReplacementPlugin( | ||
/(.+)?angular(\\|\/)core(.+)?/, | ||
path.join(__dirname, 'src'), // location of your src | ||
{} // a map of your routes | ||
), | ||
new webpack.ContextReplacementPlugin( | ||
/(.+)?express(\\|\/)(.+)?/, | ||
path.join(__dirname, 'src'), | ||
{} | ||
) | ||
] | ||
}; |
Oops, something went wrong.