Skip to content

Commit

Permalink
Remove es2019 syntax from website setup script, and pass in webpack i…
Browse files Browse the repository at this point in the history
…nstance
  • Loading branch information
ecraig12345 committed Apr 1, 2021
1 parent dec60bc commit e7516e8
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 14 deletions.
4 changes: 2 additions & 2 deletions apps/pr-deploy-site/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// pr-deploy-site.js is run without transpiling in all browsers, which means it must use
// IE 11-compatible syntax as long as we still support IE 11.
"files": ["pr-deploy-site.js"],
"plugins": ["es5"],
"extends": ["plugin:es5/no-es2015"],
"plugins": ["es"],
"extends": ["plugin:es/restrict-to-es2015"],
"rules": {
// turn off conflicting or unwanted rules from normal set
"curly": "off",
Expand Down
4 changes: 3 additions & 1 deletion apps/pr-deploy-site/just.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import fs from 'fs';
import path from 'path';
import { series, task, copyInstructionsTask, copyInstructions } from '@fluentui/scripts';
import { series, task, copyInstructionsTask, copyInstructions, cleanTask } from '@fluentui/scripts';
import { findGitRoot, getAllPackageInfo } from '@fluentui/scripts/monorepo/index';

task('clean', cleanTask());

const gitRoot = findGitRoot();
const instructions = copyInstructions.copyFilesToDestinationDirectory(
['pr-deploy-site.css', 'chiclet-test.html', 'index.html'],
Expand Down
1 change: 1 addition & 0 deletions apps/pr-deploy-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"private": true,
"scripts": {
"clean": "just-scripts clean",
"generate:site": "just-scripts generate:site",
"lint": "eslint --ext .js,.ts ."
},
Expand Down
2 changes: 2 additions & 0 deletions apps/public-docsite/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const resources = require('../../scripts/webpack/webpack-resources');
const getResolveAlias = require('../../scripts/webpack/getResolveAlias');
Expand Down Expand Up @@ -34,6 +35,7 @@ module.exports = function(env, argv) {
outDir: path.join(__dirname, 'dist'),
isProduction: isProductionArg,
CopyWebpackPlugin,
webpack,
}),
// Rest of the site
...resources.createConfig(
Expand Down
2 changes: 2 additions & 0 deletions apps/public-docsite/webpack.serve.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check

const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const resources = require('../../scripts/webpack/webpack-resources');
const getResolveAlias = require('../../scripts/webpack/getResolveAlias');
Expand All @@ -21,6 +22,7 @@ module.exports = [
outDir: path.join(__dirname, outDir),
isProduction: false,
CopyWebpackPlugin,
webpack,
}),
// Rest of site
resources.createServeConfig(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Update website setup script to pass in webpack",
"packageName": "@fluentui/public-docsite",
"email": "elcraig@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Remove es2019 syntax from website setup script, and pass in webpack instance",
"packageName": "@fluentui/public-docsite-setup",
"email": "elcraig@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"copy-webpack-plugin": "8.1.0",
"cross-env": "^5.1.4",
"css-loader": "5.0.1",
"eslint-plugin-es5": "1.5.0",
"eslint-plugin-es": "4.1.0",
"danger": "^6.0.5",
"file-loader": "6.2.0",
"gulp": "^4.0.2",
Expand Down
6 changes: 6 additions & 0 deletions packages/public-docsite-setup/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"rules": {
"no-console": "off"
}
},
{
"files": ["bin/*.js", "scripts/*.js"],
"plugins": ["es"],
// These files need to work with Node 8 (for 5.0 and 6.0 branches)
"extends": ["plugin:es/restrict-to-es2017"]
}
]
}
2 changes: 1 addition & 1 deletion packages/public-docsite-setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"just": "just-scripts",
"lint": "just-scripts lint"
"lint": "just-scripts lint && eslint ./bin/*.js ./scripts/*.js"
},
"license": "MIT",
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/public-docsite-setup/scripts/getLoadSiteConfig.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// @ts-check
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');

/**
* Gets a webpack config which copies `@fluentui/public-docsite-setup/index.html` to `outDir` and
* generates `loadSite.js` used to load the site for the given library version.
*
* Should work with webpack 4+. Requires `copy-webpack-plugin` 4+ to be installed.
* Should work with webpack 4+ and `copy-webpack-plugin` 4+.
*
* @param {object} options
* @param {string} options.libraryPath Path to the main library: `@fluentui/react` or `office-ui-fabric-react`
* @param {string} options.outDir Absolute path to the output directory
* @param {boolean} options.isProduction Whether to do a production build (same filename is used regardless)
* @param {*} options.CopyWebpackPlugin Constructor for `copy-webpack-plugin` 4+
* @returns {webpack.Configuration}
* @param {import('webpack')} options.webpack Result of `require('webpack')`, to ensure the correct one is used
* @returns {import('webpack').Configuration}
*/
function getLoadSiteConfig(options) {
const { libraryPath, outDir, isProduction, CopyWebpackPlugin } = options;
const { libraryPath, outDir, isProduction, CopyWebpackPlugin, webpack } = options;
const setupPackagePath = path.dirname(require.resolve('@fluentui/public-docsite-setup/package.json'));
const libraryVersion = JSON.parse(fs.readFileSync(`${libraryPath}/package.json`, 'utf-8')).version;

Expand All @@ -26,7 +26,7 @@ function getLoadSiteConfig(options) {
let copyPlugin;
try {
copyPlugin = new CopyWebpackPlugin({ patterns: copyPatterns });
} catch {
} catch (err) {
// copy-webpack-plugin >= 6 requires Node 10+ and takes an object containing patterns.
// Fabric 5 and 6 still support Node 8, so they need to use copy-webpack-plugin@5 which
// takes the patterns themselves as the first parameter.
Expand Down
11 changes: 7 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11835,10 +11835,13 @@ eslint-plugin-deprecation@^1.1.0:
tslib "^1.10.0"
tsutils "^3.0.0"

eslint-plugin-es5@1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-es5/-/eslint-plugin-es5-1.5.0.tgz#aab19af3d4798f7924bba309bc4f87087280fbba"
integrity sha512-Qxmfo7v2B7SGAEURJo0dpBweFf+JU15kSyALfiB2rXWcBuJ96r6X9kFHXFnhdopPHCaHjoQs1xQPUJVbGMb1AA==
eslint-plugin-es@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz#f0822f0c18a535a97c3e714e89f88586a7641ec9"
integrity sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==
dependencies:
eslint-utils "^2.0.0"
regexpp "^3.0.0"

eslint-plugin-import@^2.20.1, eslint-plugin-import@^2.21.0:
version "2.22.0"
Expand Down

0 comments on commit e7516e8

Please sign in to comment.