Skip to content

Commit 685b04e

Browse files
committed
fix(playground): angular versioned playground
1 parent ed9f335 commit 685b04e

14 files changed

Lines changed: 49996 additions & 34 deletions

File tree

‎src/components/global/Playground/stackblitz.utils.ts‎

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,24 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
7373
}
7474

7575
const openAngularEditor = async (code: string, options?: EditorOptions) => {
76-
let [main_ts, app_module_ts, app_component_ts, app_component_css, app_component_html, example_component_ts, styles_css, global_css, variables_css, angular_json, tsconfig_json, package_json] = await loadSourceFiles([
76+
let [
77+
main_ts,
78+
app_module_ts,
79+
app_component_ts,
80+
app_component_css,
81+
app_component_html,
82+
example_component_ts,
83+
styles_css,
84+
global_css,
85+
variables_css,
86+
angular_json,
87+
tsconfig_json,
88+
tsconfig_app_json,
89+
package_json,
90+
package_lock_json,
91+
zone_flags_ts,
92+
browsers_list_rc
93+
] = await loadSourceFiles([
7794
'angular/main.ts',
7895
'angular/app.module.ts',
7996
'angular/app.component.ts',
@@ -85,7 +102,11 @@ const openAngularEditor = async (code: string, options?: EditorOptions) => {
85102
'angular/variables.css',
86103
'angular/angular.json',
87104
'angular/tsconfig.json',
88-
'angular/package.json'
105+
'angular/tsconfig.app.json',
106+
'angular/package.json',
107+
'angular/package-lock.json',
108+
'angular/zone-flags.ts',
109+
'angular/.browserslistrc'
89110
], options.version)
90111

91112
if (options.angularModuleOptions) {
@@ -99,18 +120,8 @@ const openAngularEditor = async (code: string, options?: EditorOptions) => {
99120

100121
app_module_ts = app_module_ts.replace('{{ MODE }}', options?.mode);
101122

102-
let dependencies = {};
103-
try {
104-
dependencies = {
105-
...dependencies,
106-
...JSON.parse(package_json).dependencies
107-
}
108-
} catch (e) {
109-
console.error('Failed to parse package.json contents', e);
110-
}
111-
112123
sdk.openProject({
113-
template: 'angular-cli',
124+
template: 'node',
114125
title: options?.title ?? DEFAULT_EDITOR_TITLE,
115126
description: options?.description ?? DEFAULT_EDITOR_DESCRIPTION,
116127
files: {
@@ -126,12 +137,20 @@ const openAngularEditor = async (code: string, options?: EditorOptions) => {
126137
'src/index.html': '<app-root></app-root>',
127138
'src/styles.css': styles_css,
128139
'src/global.css': global_css,
140+
'src/zone-flags.ts': zone_flags_ts,
141+
'src/.browserslistrc': browsers_list_rc,
129142
'src/theme/variables.css': variables_css,
130143
'angular.json': angular_json,
131144
'tsconfig.json': tsconfig_json,
132-
...options?.files
145+
'tsconfig.app.json': tsconfig_app_json,
146+
'package.json': package_json,
147+
'package-lock.json': package_lock_json,
148+
...options?.files,
149+
'.stackblitzrc': `{
150+
"installDependencies": true,
151+
"startCommand": "npm run start"
152+
}`
133153
},
134-
dependencies
135154
});
136155
}
137156

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
Chrome >=60
12+
Firefox >=63
13+
Edge >=79
14+
Safari >=13
15+
iOS >=13

‎static/code/stackblitz/v6/angular/angular.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"index": "src/index.html",
1818
"main": "src/main.ts",
1919
"polyfills": "src/polyfills.ts",
20-
"tsConfig": "src/tsconfig.app.json",
20+
"tsConfig": "tsconfig.app.json",
2121
"assets": ["src/favicon.ico", "src/assets"],
2222
"styles": ["src/styles.css", "src/global.css", "src/theme/variables.css"],
2323
"scripts": []

0 commit comments

Comments
 (0)