Skip to content

Commit b169a21

Browse files
authored
feat: add runtime support (#93)
1 parent 96ab4c1 commit b169a21

34 files changed

+1886
-327
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.DS_Store
44
node_modules
55
dist
6+
tmp

examples/.verdaccio/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# path to a directory with all packages
2+
storage: ../tmp/local-registry/storage
3+
4+
# a list of other known repositories we can talk to
5+
uplinks:
6+
npmjs:
7+
url: https://registry.npmjs.org/
8+
maxage: 60m
9+
10+
packages:
11+
"**":
12+
# give all users (including non-authenticated users) full access
13+
# because it is a local registry
14+
access: $all
15+
publish: $all
16+
unpublish: $all
17+
18+
# if package is not available locally, proxy requests to npm registry
19+
proxy: npmjs
20+
21+
# log settings
22+
logs:
23+
type: stdout
24+
format: pretty
25+
level: warn
26+
27+
publish:
28+
allow_offline: true # set offline to true to allow publish offline

examples/apps/ng-app-cli/angular.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
"browser": "src/main.ts",
2828
"localize": ["fr"],
2929
"i18nMissingTranslation": "error",
30-
"polyfills": ["zone.js", "src/polyfills.ts"],
30+
"polyfills": ["zone.js"],
3131
"tsConfig": "tsconfig.app.json",
3232
"ngxEnv": {
3333
"prefix": "NGX_",
34+
"verbose": true,
3435
"unsecure": true,
36+
"runtime": true,
3537
"files": [".env.app", ".env"]
3638
},
3739
"assets": ["src/favicon.ico", "src/assets"],
@@ -74,7 +76,7 @@
7476
"main": "src/main.ts",
7577
"localize": ["fr"],
7678
"i18nMissingTranslation": "error",
77-
"polyfills": ["zone.js", "src/polyfills.ts"],
79+
"polyfills": ["zone.js"],
7880
"tsConfig": "tsconfig.app.json",
7981
"ngxEnv": {
8082
"prefix": "NGX_",
@@ -117,7 +119,7 @@
117119
"main": "src/main.ts",
118120
"localize": ["fr"],
119121
"i18nMissingTranslation": "error",
120-
"polyfills": ["zone.js", "src/polyfills.ts"],
122+
"polyfills": ["zone.js"],
121123
"tsConfig": "tsconfig.app.json",
122124
"ngxEnv": {
123125
"prefix": "NGX_",
@@ -185,7 +187,7 @@
185187
"test": {
186188
"builder": "@ngx-env/builder:karma",
187189
"options": {
188-
"polyfills": ["zone.js", "zone.js/testing", "src/polyfills.ts"],
190+
"polyfills": ["zone.js", "zone.js/testing"],
189191
"tsConfig": "tsconfig.spec.json",
190192
"karmaConfig": "karma.conf.js",
191193
"ngxEnv": {

examples/apps/ng-app-cli/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"dependencies": {
2121
"@angular/animations": "^17.2.0",
2222
"@angular/common": "^17.2.0",
23+
"@angular/localize": "^17.2.0",
2324
"@angular/compiler": "^17.2.0",
2425
"@angular/core": "^17.2.0",
2526
"@angular/forms": "^17.2.0",
@@ -37,24 +38,23 @@
3738
"@angular-devkit/build-angular": "^17.2.0",
3839
"@angular/cli": "^17.2.0",
3940
"@angular/compiler-cli": "^17.2.0",
40-
"@angular/localize": "^17.2.0",
41-
"@ngx-env/builder": "file:../../../packages/angular",
41+
"@dotenv-run/core": "*",
42+
"@dotenv-run/jest-angular": "*",
43+
"@jest/transform": "^29.7.0",
44+
"@ngx-env/builder": "*",
4245
"@types/express": "^4.17.17",
4346
"@types/jasmine": "~5.1.0",
4447
"@types/node": "^18.18.0",
48+
"esbuild": "0.20.0",
4549
"jasmine-core": "~5.1.0",
50+
"jest": "^29.7.0",
51+
"jest-preset-angular": "14.0.0",
4652
"karma": "~6.4.0",
4753
"karma-chrome-launcher": "~3.2.0",
4854
"karma-coverage": "~2.2.0",
4955
"karma-jasmine": "~5.1.0",
5056
"karma-jasmine-html-reporter": "~2.1.0",
51-
"typescript": "~5.2.2",
5257
"ts-jest": "^29.1.2",
53-
"@jest/transform": "^29.7.0",
54-
"esbuild": "0.20.0",
55-
"jest": "^29.7.0",
56-
"jest-preset-angular": "14.0.0",
57-
"@dotenv-run/core": "*",
58-
"@dotenv-run/jest-angular": "*"
58+
"typescript": "~5.2.2"
5959
}
6060
}

examples/apps/ng-app-cli/server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ export function app(): express.Express {
2020
// Example Express Rest API endpoints
2121
// server.get('/api/**', (req, res) => { });
2222
// Serve static files from /browser
23-
server.get('*.*', express.static(browserDistFolder, {
24-
maxAge: '1y'
25-
}));
23+
server.get(
24+
'*.*',
25+
express.static(browserDistFolder, {
26+
maxAge: '1y',
27+
})
28+
);
2629

2730
// All regular routes use the Angular engine
2831
server.get('*', (req, res, next) => {

examples/apps/ng-app-cli/src/app/app.config.server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { provideServerRendering } from '@angular/platform-server';
33
import { appConfig } from './app.config';
44

55
const serverConfig: ApplicationConfig = {
6-
providers: [
7-
provideServerRendering()
8-
]
6+
providers: [provideServerRendering()],
97
};
108

119
export const config = mergeApplicationConfig(appConfig, serverConfig);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
1+
import { ApplicationConfig } from '@angular/core';
22
import { provideRouter } from '@angular/router';
33

4-
import { routes } from './app.routes';
54
import { provideClientHydration } from '@angular/platform-browser';
5+
import { routes } from './app.routes';
66

77
export const appConfig: ApplicationConfig = {
8-
providers: [provideRouter(routes), provideClientHydration()]
8+
providers: [provideRouter(routes), provideClientHydration()],
99
};

examples/apps/ng-app-cli/src/env.d.ts

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,13 @@
1-
interface ImportMeta {
2-
readonly env: ImportMetaEnv;
3-
}
4-
5-
interface ImportMetaEnv {
6-
/**
7-
* Built-in environment variable.
8-
* @see Docs https://github.com/chihab/dotenv-run/packages/angular#node_env.
9-
*/
1+
// Define the type of the environment variables.
2+
declare interface Env {
103
readonly NODE_ENV: string;
11-
// Add your environment variables below
12-
// readonly NG_APP_API_URL: string;
4+
// Replace the following with your own environment variables.
5+
// Example: NGX_VERSION: string;
6+
NGX_BRANCH: string;
7+
NGX_VERSION: string;
138
[key: string]: any;
149
}
1510

16-
/*
17-
* Remove all the deprecated code below if you're using import.meta.env (recommended)
18-
*/
19-
20-
/****************************** DEPREACTED **************************/
21-
/**
22-
* @deprecated process.env usage
23-
* prefer using import.meta.env
24-
* */
25-
// declare var process: {
26-
// env: {
27-
// NODE_ENV: string;
28-
// [key: string]: any;
29-
// };
30-
// };
31-
32-
// If your project references @types/node directly (in you) or indirectly (as in RxJS < 7.6.0),
33-
// you might need to use the following declaration merging.
34-
// declare namespace NodeJS {
35-
// export interface ProcessEnv {
36-
// readonly NODE_ENV: string;
37-
// // Add your environment variables below
38-
// }
39-
// }
40-
41-
// If you're using Angular Universal and process.env notation, you'll need to add the following to your tsconfig.server.json:
42-
/* In your tsconfig.server.json */
43-
// {
44-
// "extends": "./tsconfig.app.json",
45-
// ...
46-
// "exclude": [
47-
// "src/env.d.ts"
48-
// ]
49-
// }
50-
51-
/*********************************************************************/
11+
declare interface ImportMeta {
12+
readonly env: Env;
13+
}

examples/apps/ng-app-cli/src/locale/messages.fr.xlf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
<body>
55
<trans-unit id="156685006078229661" datatype="html">
66
<source>Attribute string</source>
7-
<target>Attribute string</target>
87
<context-group purpose="location">
98
<context context-type="sourcefile">src/app/app.component.html</context>
109
<context context-type="linenumber">3</context>
1110
</context-group>
1211
</trans-unit>
1312
<trans-unit id="398840060331148207" datatype="html">
1413
<source>element string</source>
15-
<target>element string</target>
1614
<context-group purpose="location">
1715
<context context-type="sourcefile">src/app/app.component.html</context>
1816
<context context-type="linenumber">3,4</context>
1917
</context-group>
2018
</trans-unit>
2119
<trans-unit id="2023484548631819319" datatype="html">
2220
<source>Hello world</source>
23-
<target>Hello world</target>
2421
<context-group purpose="location">
2522
<context context-type="sourcefile">src/app/app.component.ts</context>
2623
<context context-type="linenumber">14</context>

examples/apps/ng-app-cli/src/main.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '@ngx-env/builder/runtime';
2+
13
import { bootstrapApplication } from '@angular/platform-browser';
24
import { AppComponent } from './app/app.component';
35
import { config } from './app/app.config.server';

0 commit comments

Comments
 (0)