Skip to content

Commit 766e073

Browse files
committed
fix(lib): upgraded the lib to angular v9 + fixed schematics issues
1 parent 3780222 commit 766e073

File tree

9 files changed

+116
-139
lines changed

9 files changed

+116
-139
lines changed

projects/angular-material-extensions/fab-menu/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"url": "https://github.com/angular-material-extensions/fab-menu/issues"
3030
},
3131
"scripts": {
32-
"build": "../../../node_modules/.bin/ng build @angular-material-extensions/fab-menu",
32+
"build": "../../../node_modules/.bin/ng build @angular-material-extensions/fab-menu --prod",
3333
"build:watch": "../../../node_modules/.bin/ng build @angular-material-extensions/fab-menu --watch",
3434
"build:schematics": "../../../node_modules/.bin/tsc -p tsconfig.schematics.json",
3535
"clean": "rm -rf ../../../dist",

projects/angular-material-extensions/fab-menu/schematics/helpers/angular/config.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
export * from './ast-utils';
22
export * from './change';
33
export * from './component-schema';
4-
export * from './config';
54
export * from './dependencies';
65
export * from './find-module';
76
export * from './json-utils';
87
export * from './latest-versions';
9-
export * from './lint-fix';
108
export * from './ng-ast-utils';
119
export * from './parse-name';
1210
export * from './paths';
13-
export * from './project';
14-
export * from './project-targets';
1511
export * from './validation';
1612
export * from './workspace-models';

projects/angular-material-extensions/fab-menu/schematics/helpers/angular/lint-fix.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

projects/angular-material-extensions/fab-menu/schematics/helpers/angular/project-targets.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

projects/angular-material-extensions/fab-menu/schematics/helpers/angular/project.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

projects/angular-material-extensions/fab-menu/schematics/ng-add/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {chain, noop, Rule, SchematicContext, Tree} from '@angular-devkit/schematics';
22
import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
33
import {
4-
addModuleImportToRootModule,
54
addPackageJsonDependency,
6-
getProjectFromWorkspace,
7-
getWorkspace,
85
NodeDependency,
96
NodeDependencyType
107
} from '../helpers';
118

9+
import {getWorkspace} from '@schematics/angular/utility/config';
10+
import {addModuleImportToRootModule, getProjectFromWorkspace,} from '@angular/cdk/schematics';
11+
1212
/** Loads the full version from the given Angular package gracefully. */
1313
function loadPackageVersionGracefully(): string | null {
1414
try {
@@ -27,7 +27,7 @@ export function addPackageJsonDependencies(): Rule {
2727
const dependencies: NodeDependency[] = [
2828
{
2929
type: NodeDependencyType.Default, version: loadPackageVersionGracefully()
30-
|| '0.1.0', name: '@angular-material-extensions/fab-menu'
30+
|| '1.4.0', name: '@angular-material-extensions/fab-menu'
3131
},
3232
];
3333

server.ts.bak

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* *** NOTE ON IMPORTING FROM ANGULAR AND NGUNIVERSAL IN THIS FILE ***
3+
*
4+
* If your application uses third-party dependencies, you'll need to
5+
* either use Webpack or the Angular CLI's `bundleDependencies` feature
6+
* in order to adequately package them for use on the server without a
7+
* node_modules directory.
8+
*
9+
* However, due to the nature of the CLI's `bundleDependencies`, importing
10+
* Angular in this file will create a different instance of Angular than
11+
* the version in the compiled application code. This leads to unavoidable
12+
* conflicts. Therefore, please do not explicitly import from @angular or
13+
* @nguniversal in this file. You can export any needed resources
14+
* from your application's main.server.ts file, as seen below with the
15+
* import for `ngExpressEngine`.
16+
*/
17+
18+
import 'zone.js/dist/zone-node';
19+
20+
import * as express from 'express';
21+
import {join} from 'path';
22+
23+
// Express server
24+
const app = express();
25+
26+
const PORT = process.env.PORT || 4000;
27+
const DIST_FOLDER = join(process.cwd(), 'dist/browser');
28+
29+
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
30+
const {AppServerModuleNgFactory, LAZY_MODULE_MAP, ngExpressEngine, provideModuleMap} = require('./dist/server/main');
31+
32+
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
33+
app.engine('html', ngExpressEngine({
34+
bootstrap: AppServerModuleNgFactory,
35+
providers: [
36+
provideModuleMap(LAZY_MODULE_MAP)
37+
]
38+
}));
39+
40+
app.set('view engine', 'html');
41+
app.set('views', DIST_FOLDER);
42+
43+
// Example Express Rest API endpoints
44+
// app.get('/api/**', (req, res) => { });
45+
// Serve static files from /browser
46+
app.get('*.*', express.static(DIST_FOLDER, {
47+
maxAge: '1y'
48+
}));
49+
50+
// All regular routes use the Universal engine
51+
app.get('*', (req, res) => {
52+
res.render('index', { req });
53+
});
54+
55+
// Start up the Node server
56+
app.listen(PORT, () => {
57+
console.log(`Node Express server listening on http://localhost:${PORT}`);
58+
});

webpack.server.config.js.bak

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Work around for https://github.com/angular/angular-cli/issues/7200
2+
3+
const path = require('path');
4+
const webpack = require('webpack');
5+
6+
module.exports = {
7+
mode: 'none',
8+
entry: {
9+
// This is our Express server for Dynamic universal
10+
server: './server.ts',
11+
// This is an example of Static prerendering (generative)
12+
prerender: './prerender.ts'
13+
},
14+
externals: {
15+
'./dist/server/main': 'require("./server/main")'
16+
},
17+
target: 'node',
18+
resolve: { extensions: ['.ts', '.js'] },
19+
optimization: {
20+
minimize: false
21+
},
22+
output: {
23+
// Puts the output at the root of the dist folder
24+
path: path.join(__dirname, 'dist'),
25+
filename: '[name].js'
26+
},
27+
module: {
28+
noParse: /polyfills-.*\.js/,
29+
rules: [
30+
{ test: /\.ts$/, loader: 'ts-loader' },
31+
{
32+
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
33+
// Removing this will cause deprecation warnings to appear.
34+
test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/,
35+
parser: { system: true },
36+
},
37+
]
38+
},
39+
plugins: [
40+
new webpack.ContextReplacementPlugin(
41+
// fixes WARNING Critical dependency: the request of a dependency is an expression
42+
/(.+)?angular(\\|\/)core(.+)?/,
43+
path.join(__dirname, 'src'), // location of your src
44+
{} // a map of your routes
45+
),
46+
new webpack.ContextReplacementPlugin(
47+
// fixes WARNING Critical dependency: the request of a dependency is an expression
48+
/(.+)?express(\\|\/)(.+)?/,
49+
path.join(__dirname, 'src'),
50+
{}
51+
)
52+
]
53+
};

0 commit comments

Comments
 (0)