Skip to content

Commit 2ea1b0b

Browse files
committed
Fix relative systemJs named modules to absolute for grading version. IE11 not supported (need investigation). Ceased to strict depend for promise-polyfill & whatwg-fetch
1 parent d1d72c7 commit 2ea1b0b

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed

gulpfile.esm.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
dest,
1313
task,
1414
parallel,
15+
series,
1516
} from 'gulp';
1617
import uglifyES from 'gulp-uglify-es';
1718

@@ -90,7 +91,6 @@ task('systemjs:deleteAssets',
9091
() => del([
9192
`${absDest}/**/*.html.js`,
9293
path.resolve(absDest, 'tsconfig.html-esm.json'),
93-
path.resolve(absDest, 'direct-vuex.esm.min.js'),
9494
path.resolve(absDest, 'vue-property-decorator.js'),
9595
path.resolve(absDest, 'vue-class-component.js'),
9696
]));
@@ -113,6 +113,16 @@ task('esm:fixImportsAddJsSuffix',
113113
.pipe(gReplace(/(.* from ')(.*)(\.html)(')/gm, '$1$2$3.js$4'))
114114
.pipe(dest(absDest)));
115115

116+
task('systemjs:fixRelativeHtml',
117+
() => src([
118+
path.resolve(absDest, path.basename(tsOptionsSystemJs.outFile)),
119+
])
120+
.pipe(gReplace(
121+
/(\.register\(")(.*)(\/)(.*)(",\s\[")(\.\/)(.*)(\.html"\])/gm,
122+
'$1$2$3$4$5$2/$7$8',
123+
))
124+
.pipe(dest(absDest)));
125+
116126
task('systemjs:uglifyBundles',
117127
() => src([
118128
path.resolve(absDest, path.basename(tsOptionsSystemJs.outFile)),
@@ -132,8 +142,6 @@ task('copySystemJs', // not in 'copyNonTranspiledFiles' because of dest
132142
task('systemjs:copyNonTranspiledFiles',
133143
() => src([
134144
path.resolve(absSrc, 'tsconfig.html-esm.json'),
135-
path.resolve('node_modules', 'promise-polyfill', 'dist', 'polyfill.min.js'),
136-
path.resolve('node_modules', 'whatwg-fetch', 'dist', 'fetch.umd.js'),
137145
])
138146
.pipe(dest(absDest)));
139147

@@ -151,7 +159,10 @@ task('predeploy',
151159
task('postdeploy',
152160
parallel(
153161
'systemjs:deleteAssets', // they are not need, because of bundles including
154-
'systemjs:uglifyBundles',
162+
series(
163+
'systemjs:fixRelativeHtml', // workaround for upgrading to SystemJS v6
164+
'systemjs:uglifyBundles',
165+
),
155166
),
156167
);
157168

package-lock.json

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

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "systemjs-ts-es6-vue",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/viT-1/systemjs-ts-es6-vue.git"
@@ -53,15 +53,13 @@
5353
"debounce-decorator-ts": "1.0.4",
5454
"direct-vuex": "0.12.1",
5555
"es-module-shims": "0.10.1",
56-
"promise-polyfill": "8.2.0",
5756
"express": "4.17.1",
5857
"systemjs": "5.0.0",
5958
"vue": "2.6.13",
6059
"vue-class-component": "7.2.6",
6160
"vue-multiselect": "2.1.6",
6261
"vue-property-decorator": "9.0.2",
63-
"vuex": "3.6.2",
64-
"whatwg-fetch": "3.6.2"
62+
"vuex": "3.6.2"
6563
},
6664
"devDependencies": {
6765
"@types/express": "4.17.12",

src/index.htm

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<!DOCTYPE html>
22

33
<head>
4-
<!-- If you need polyfill.io use v3 with 'always,gated' excluding Symbol, v2 breaks the code -->
5-
<!-- <script src="https://cdn.polyfill.io/v3/polyfill.min.js?flags=always,gated&excludes=Symbol,Symbol.iterator,Symbol.species"></script> -->
6-
7-
<!-- IE 7-11 Promise polyfill -->
8-
<script src="polyfill.min.js"></script>
9-
<!-- IE 10+ Fetch polyfill -->
10-
<script src="fetch.umd.js"></script>
11-
4+
<script>
5+
if (typeof Promise === 'undefined')
6+
document.write('<script src="https://unpkg.com/[email protected]/js/browser/bluebird.core.min.js"><\/script>');
7+
if (typeof fetch === 'undefined')
8+
document.write('<script src="https://unpkg.com/[email protected]/dist/fetch.umd.js"><\/script>');
9+
</script>
1210
<script src="systemjs/system.min.js"></script>
1311
<script src="systemjs/named-exports.min.js"></script>
1412
<script src="systemjs/named-register.min.js"></script>
@@ -27,17 +25,16 @@
2725
<script type="systemjs-importmap" src="importmap.system.json"></script>
2826
<script>
2927
function bundleLoad () {
30-
// dependencies: main use bundle that using html-esm (vue-class-component)
31-
System.import('html-esm')
32-
.then(function () {
33-
var bundleReady = System.import('bundle');
34-
var vuexReady = System.import('vuex');
35-
Promise.all([bundleReady, vuexReady])
28+
var htmlEsmReady = System.import('html-esm');
29+
var vuexReady = System.import('vuex');
30+
31+
Promise.all([htmlEsmReady, vuexReady])
3632
.then(function () {
37-
console.log('SystemJs bundle is loaded!');
38-
System.import('main');
33+
System.import('bundle').then(function () {
34+
console.log('SystemJs bundle is loaded!');
35+
System.import('main');
36+
});
3937
});
40-
});
4138
}
4239

4340
function waitForSystem () {

0 commit comments

Comments
 (0)