Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ie11 polyfill package and test with react-button package #14567

Merged
merged 37 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8796c6f
Add ie11 polyfill package and test with react-button package
tomi-msft Aug 17, 2020
3ea1365
change package name and add typings file
tomi-msft Aug 17, 2020
179d2cd
Fix getResolveAlias
ecraig12345 Aug 19, 2020
e8b1604
more getResolveAlias fixes
ecraig12345 Aug 19, 2020
b20835d
update readme and get latest polyfill script version
tomi-msft Aug 20, 2020
cde3520
Merge branch 'master' into ie11-polyfill
tomi-msft Aug 20, 2020
1d32dc2
clean up script file
tomi-msft Aug 23, 2020
d107059
Merge branch 'ie11-polyfill' of https://github.com/tomi-msft/fluentui…
tomi-msft Aug 23, 2020
109a1ca
Merge branch 'master' into ie11-polyfill
tomi-msft Aug 23, 2020
6467a43
Merge branch 'ie11-polyfill' of https://github.com/tomi-msft/fluentui…
tomi-msft Aug 23, 2020
cc2d67a
Updating example-app-base version in react-button.
khmakoto Aug 25, 2020
f66baa9
Merge branch 'ie11-polyfill' of https://github.com/tomi-msft/fluentui…
tomi-msft Aug 25, 2020
1200200
merge into master
tomi-msft Aug 25, 2020
a868b97
Removing the need for a theme and wrapping legacy examples with Theme…
khmakoto Aug 27, 2020
63c7573
Change files
khmakoto Aug 27, 2020
f83178a
merge with upstream master branch
tomi-msft Aug 27, 2020
2e2c13b
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Aug 27, 2020
3e70dd0
Change files
tomi-msft Aug 27, 2020
fddadbd
Update version in react-button and README in polyfill package
tomi-msft Aug 27, 2020
745c013
remove unused import
tomi-msft Aug 28, 2020
b8964c6
Update packages/ie11-custom-properties/README.md
tomi-msft Aug 28, 2020
0b719de
Merge branch 'master' into ie11-polyfill
tomi-msft Aug 28, 2020
443f6db
update example-app-base version
tomi-msft Aug 28, 2020
14b7a61
Merge branch 'ie11-polyfill' of https://github.com/tomi-msft/fluentui…
tomi-msft Aug 28, 2020
7331f7b
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Aug 28, 2020
332318a
update package to use external polyfill as devDependency
tomi-msft Sep 2, 2020
83540b1
Merge branch 'master' into ie11-polyfill
tomi-msft Sep 2, 2020
b8125c7
Change files
tomi-msft Sep 2, 2020
f9ea703
update example-app-base package to latest version
tomi-msft Sep 2, 2020
193f4a0
Merge branch 'master' into ie11-polyfill
tomi-msft Sep 2, 2020
9ba109b
Exporting ie11-custom-properties from ie11-polyfills.
khmakoto Sep 2, 2020
622feb2
Fixing merge conflict.
khmakoto Sep 2, 2020
0b52b8a
update example-app-base version
tomi-msft Sep 2, 2020
70187c8
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Sep 2, 2020
c4b5825
add more info to README & fix LICENSE
tomi-msft Sep 2, 2020
ee23ae6
Clean up README and change package to use JS
tomi-msft Sep 3, 2020
99a0d92
delete redundant change file
tomi-msft Sep 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "update package to use external polyfill as devDependency",
"packageName": "@fluentui/ie11-polyfills",
"email": "ololubek@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-09-02T05:54:55.211Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Adding legacy startup for internal testing on IE11.",
"packageName": "@fluentui/react-button",
"email": "humbertomakotomorimoto@gmail.com",
"dependentChangeType": "patch",
"date": "2020-08-27T19:13:14.436Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Adding check for undefined FluentTheme in CodeSnippet.tsx.",
"packageName": "@uifabric/example-app-base",
"email": "humbertomakotomorimoto@gmail.com",
"dependentChangeType": "patch",
"date": "2020-08-27T19:12:22.532Z"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import * as React from 'react';
import { IStyleFunctionOrObject, ITheme, IStyle, styled, classNamesFunction, IRawStyle } from 'office-ui-fabric-react';
import { NeutralColors, FluentTheme, SharedColors } from '@uifabric/fluent-theme';
import {
IStyleFunctionOrObject,
ITheme,
IStyle,
styled,
classNamesFunction,
IRawStyle,
DefaultPalette,
} from 'office-ui-fabric-react';
import { NeutralColors, SharedColors } from '@uifabric/fluent-theme';
import { baseCodeStyle, getStyles } from './CodeSnippet.styles';

/* eslint-disable @typescript-eslint/no-explicit-any */
Expand Down Expand Up @@ -38,7 +46,7 @@ style['hljs-comment'] = style['hljs-quote'] = {
};

style['hljs-built_in'] = style['builtin-name'] = {
color: FluentTheme.palette.themeDarker,
color: DefaultPalette.themeDarker,
};

style['hljs-link'] = style['hljs-regexp'] = {
Expand Down
34 changes: 34 additions & 0 deletions packages/ie11-polyfills/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
*.api.json
*.config.js
*.log
*.nuspec
*.test.*
*.yml
.editorconfig
.eslintrc*
.eslintcache
.gitattributes
.gitignore
.vscode
coverage
dist-storybook
dist/*.stats.html
dist/*.stats.json
dist/demo*.*
fabric-test*
gulpfile.js
images
index.html
jsconfig.json
node_modules
results
src/**/*
!src/**/examples/*.tsx
!src/**/docs/**/*.md
!src/**/*.types.ts
temp
tsconfig.json
tsd.json
tslint.json
typings
visualtests
2 changes: 2 additions & 0 deletions packages/ie11-polyfills/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry=https://registry.npmjs.org/

15 changes: 15 additions & 0 deletions packages/ie11-polyfills/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@fluentui/ie11-polyfills

Copyright (c) Microsoft Corporation

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
13 changes: 13 additions & 0 deletions packages/ie11-polyfills/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @fluentui/ie11-polyfills

**IE11 polyfills for Fluent UI React**

Package to hold ie11 polyfill that allows webpages that use CSS variables for styling to render correctly in IE11. It will also hold any future IE11 polyfills

To use the polyfill, just import the package:

```js
import '@fluentui/ie11-polyfills';
```

If you are using any websites with hot reloading, you will have to either put the polyfill on each page that uses css variables, or refresh the page for the script to take effect.
1 change: 1 addition & 0 deletions packages/ie11-polyfills/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions packages/ie11-polyfills/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('ie11-custom-properties');
16 changes: 16 additions & 0 deletions packages/ie11-polyfills/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@fluentui/ie11-polyfills",
"version": "0.1.0",
"description": "Package to hold current and future ie11 polyfills",
"main": "index.js",
"typings": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/fluentui"
},
"devDependencies": {
"@uifabric/build": "^7.0.0",
"ie11-custom-properties": "4.1.0"
},
"license": "MIT"
}
9 changes: 9 additions & 0 deletions packages/react-button/config/pre-copy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"copyTo": {
"dist": [
"@uifabric/example-app-base/index.html",
"react/umd/react.development.js",
"react-dom/umd/react-dom.development.js"
]
}
}
3 changes: 3 additions & 0 deletions packages/react-button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"just": "just-scripts",
"lint": "just-scripts lint",
"start": "just-scripts dev:storybook",
"start:legacy": "just-scripts dev",
"start-test": "just-scripts jest-watch",
"test": "just-scripts test",
"update-api": "just-scripts update-api",
Expand All @@ -29,6 +30,7 @@
"devDependencies": {
"@fluentui/common-styles": "^0.2.5",
"@fluentui/eslint-plugin": "^0.54.0",
"@fluentui/ie11-polyfills": "^0.1.0",
"@fluentui/react-conformance": "^0.1.1",
"@fluentui/storybook": "^0.4.4",
"@types/enzyme": "3.10.3",
Expand All @@ -39,6 +41,7 @@
"@types/react-test-renderer": "^16.0.0",
"@types/webpack-env": "1.15.1",
"@uifabric/build": "^7.0.0",
"@uifabric/example-app-base": "^7.15.3",
"enzyme": "~3.10.0",
"enzyme-adapter-react-16": "^1.15.0",
"react": "16.8.6",
Expand Down
28 changes: 28 additions & 0 deletions packages/react-button/src/demo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from 'react';
import * as path from 'path';
import { createApp, Markdown, examplesOf } from '@uifabric/example-app-base';
import { ThemeProvider } from '@fluentui/react-theme-provider';
import '@fluentui/ie11-polyfills';

const req = require.context('../components', true, /\.stories\.tsx$/, 'sync');

const exampleWithTheme = (example: () => JSX.Element) => () => <ThemeProvider>{example()}</ThemeProvider>;

createApp(
// List of examples
req.keys().map(key => {
const storiesModule = req(key);
const exampleGroup = examplesOf(path.basename(key, '.stories.tsx'));
for (const exampleName of Object.keys(storiesModule)) {
exampleGroup.add(exampleName, exampleWithTheme(storiesModule[exampleName]));
}
return exampleGroup;
}),
// Intro page
() => (
<div style={{ marginTop: -20, padding: 40 }}>
<Markdown>{require<string>('!raw-loader!../../README.md')}</Markdown>
</div>
),
'React Button Examples',
);
15 changes: 15 additions & 0 deletions packages/react-button/webpack.serve.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const resources = require('@uifabric/build/webpack/webpack-resources');
const getResolveAlias = require('@uifabric/build/webpack/getResolveAlias');
module.exports = resources.createServeConfig({
entry: './src/demo/index.tsx',
output: {
filename: 'demo-app.js',
},
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
resolve: {
alias: getResolveAlias(),
},
});
2 changes: 1 addition & 1 deletion scripts/create-package/plopfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = (plop: NodePlopAPI) => {
type: 'input',
name: 'packageName',
message: 'Package name (do NOT include @fluentui prefix):',
validate: (input: string) => /^[a-z-]+$/.test(input) || 'Must enter a valid unscoped npm package name',
validate: (input: string) => /^[a-z\d-]+$/.test(input) || 'Must enter a valid unscoped npm package name',
},
{
type: 'list',
Expand Down
48 changes: 32 additions & 16 deletions scripts/webpack/getResolveAlias.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// @ts-check
const path = require('path');

const { findRepoDeps, findGitRoot } = require('../monorepo/index');
const { readConfig } = require('../read-config');

function getOutputPath(packageJson) {
for (const mainField of ['module', 'main']) {
const main = packageJson[mainField];
if (main) {
return main.includes('dist/es') ? 'dist/es' : 'lib';
}
}

return 'lib';
function getOutputPath(entryPoint) {
return entryPoint && entryPoint.includes('dist/es') ? 'dist/es' : 'lib';
}

function getResolveAlias() {
Expand All @@ -30,21 +24,42 @@ function getResolveAlias() {
let cwd = process.cwd();
const packageJson = readConfig(path.join(cwd, 'package.json'));

deps.forEach(depInfo => {
if (!excludedPackages.includes(depInfo.packageJson.name)) {
alias[`${depInfo.packageJson.name}$`] = path.join(gitRoot, depInfo.packagePath, 'src');
alias[`${depInfo.packageJson.name}/src`] = path.join(gitRoot, depInfo.packagePath, 'src');
deps.forEach(({ packageJson: depPackageJson, packagePath: depPackagePath }) => {
const depName = depPackageJson.name;
const entryPoint = depPackageJson.module || depPackageJson.main;

if (excludedPackages.includes(depName)) {
return;
}

if (!entryPoint) {
// Something really weird--still give the path to its repo location
alias[depName] = path.join(gitRoot, depPackagePath);
} else if (/\b(dist|lib)\b/.test(entryPoint)) {
// Standard package
alias[`${depName}/src`] = path.join(gitRoot, depPackagePath, 'src');

const outputPath = getOutputPath(depInfo.packageJson);
const outputPath = getOutputPath(entryPoint);
alias[`${depName}/${outputPath}`] = path.join(gitRoot, depPackagePath, 'src');

alias[`${depInfo.packageJson.name}/${outputPath}`] = path.join(gitRoot, depInfo.packagePath, 'src');
if (/\/index\b/.test(entryPoint)) {
// Standard index entry point
alias[`${depName}$`] = path.join(gitRoot, depPackagePath, 'src');
} else {
// Non-standard entry point name
alias[`${depName}$`] = path.join(gitRoot, depPackagePath, entryPoint.replace(`\\/${outputPath}\\/`, '/src/'));
}
} else {
// Non-standard package such as ie11-custom-properties
alias[`${depName}$`] = path.join(gitRoot, depPackagePath, entryPoint);
alias[`${depName}/`] = path.join(gitRoot, depPackagePath);
}
});

alias[`${packageJson.name}$`] = path.join(cwd, 'src');
alias[`${packageJson.name}/src`] = path.join(cwd, 'src');

const outputPath = getOutputPath(packageJson);
const outputPath = getOutputPath(packageJson.module || packageJson.main);

alias[`${packageJson.name}/${outputPath}`] = path.join(cwd, 'src');

Expand All @@ -53,6 +68,7 @@ function getResolveAlias() {

module.exports = getResolveAlias;

// @ts-ignore
if (require.main === module) {
console.log(getResolveAlias());
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12923,6 +12923,11 @@ icss-utils@^4.0.0, icss-utils@^4.1.1:
dependencies:
postcss "^7.0.14"

ie11-custom-properties@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ie11-custom-properties/-/ie11-custom-properties-4.1.0.tgz#fec74a4d62f746e1aa2ae52b0c3136edca119596"
integrity sha512-ep6R2iQvgfDEjd97ifkGKv119/Q+4La1GzKyshMsq2kIUVDlQUt74uc7WtMT4oN2G4d+tcA3QA86aUl7ESjBYw==

ieee754@^1.1.4:
version "1.1.13"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
Expand Down