Skip to content

Commit de16b09

Browse files
authored
polyfills and config necessary for spfx ie11 support (#514)
1 parent 68661c3 commit de16b09

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

samples/sp-webpart/gulpfile.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,28 @@ const gulp = require('gulp');
44
const build = require('@microsoft/sp-build-web');
55
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
66

7+
build.configureWebpack.mergeConfig({
8+
additionalConfiguration: (generatedConfiguration) => {
9+
generatedConfiguration.module.rules.push(
10+
{
11+
test: /\.m?js$/, use:
12+
{
13+
loader: "babel-loader",
14+
options:
15+
{
16+
presets: [["@babel/preset-env",
17+
{
18+
targets: {
19+
"ie": "11"
20+
}
21+
}]]
22+
}
23+
}
24+
}
25+
);
26+
27+
return generatedConfiguration;
28+
}
29+
});
30+
731
build.initialize(gulp);

samples/sp-webpart/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
"@types/react": "16.8.8"
3131
},
3232
"devDependencies": {
33+
"@babel/core": "^7.10.3",
34+
"@babel/preset-env": "^7.10.3",
3335
"@microsoft/rush-stack-compiler-3.7": "0.2.9",
3436
"@microsoft/sp-build-web": "1.10.0",
3537
"@microsoft/sp-module-interfaces": "1.10.0",
@@ -38,7 +40,10 @@
3840
"@types/chai": "3.4.34",
3941
"@types/mocha": "2.2.38",
4042
"ajv": "~5.2.2",
43+
"babel-loader": "^8.1.0",
4144
"gulp": "~3.9.1",
42-
"typescript": "^3.4.3"
45+
"regenerator-runtime": "^0.13.5",
46+
"typescript": "^3.4.3",
47+
"webpack": "^4.43.0"
4348
}
4449
}

samples/sp-webpart/src/webparts/mgtDemo/MgtDemoWebPart.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ import * as React from 'react';
22
import * as ReactDom from 'react-dom';
33
import { Version } from '@microsoft/sp-core-library';
44
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
5-
import {
6-
IPropertyPaneConfiguration,
7-
PropertyPaneTextField
8-
} from '@microsoft/sp-property-pane';
5+
import { IPropertyPaneConfiguration, PropertyPaneTextField } from '@microsoft/sp-property-pane';
6+
7+
// import web component polyfills for browsers that need them
8+
import 'regenerator-runtime/runtime';
9+
import 'core-js/es/number';
10+
import 'core-js/es/math';
11+
import 'core-js/es/string';
12+
import 'core-js/es/date';
13+
import 'core-js/es/array';
14+
import 'core-js/es/regexp';
15+
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
916

1017
import * as strings from 'MgtDemoWebPartStrings';
1118
import MgtDemo from './components/MgtDemo';
1219
import { IMgtDemoProps } from './components/IMgtDemoProps';
1320

14-
// import web component polyfills for browsers that need them
15-
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
16-
1721
// import the providers at the top of the page
1822
import { Providers, SharePointProvider } from '@microsoft/mgt';
1923

0 commit comments

Comments
 (0)