Skip to content

Commit

Permalink
fix: Add missing lang attribute on HTML element
Browse files Browse the repository at this point in the history
Fixes #879 #1668
  • Loading branch information
sapegin committed Oct 23, 2020
1 parent 804e314 commit 85c627d
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 255 deletions.
573 changes: 346 additions & 227 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@tippyjs/react": "4.1.0",
"@vxna/mini-html-webpack-template": "^1.0.0",
"@vxna/mini-html-webpack-template": "^2.0.0",
"acorn": "^6.4.1",
"acorn-jsx": "^5.1.0",
"ast-types": "~0.13.2",
Expand Down Expand Up @@ -67,7 +67,7 @@
"lodash": "^4.17.15",
"lowercase-keys": "^2.0.0",
"markdown-to-jsx": "^6.11.4",
"mini-html-webpack-plugin": "^2.0.0",
"mini-html-webpack-plugin": "^3.1.3",
"mri": "^1.1.4",
"ora": "^4.0.2",
"prismjs": "^1.17.1",
Expand Down Expand Up @@ -164,7 +164,7 @@
"tapable": "^1.1.3",
"typescript": "^3.8.3",
"url-loader": "^2.2.0",
"webpack": "^4.41.2",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.9"
},
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/make-webpack-config.ts
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import castArray from 'lodash/castArray';
import webpack, { Configuration, Resolve } from 'webpack';
import TerserPlugin from 'terser-webpack-plugin';
import MiniHtmlWebpackPlugin from 'mini-html-webpack-plugin';
import { MiniHtmlWebpackPlugin } from 'mini-html-webpack-plugin';
import MiniHtmlWebpackTemplate from '@vxna/mini-html-webpack-template';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
Expand Down Expand Up @@ -34,6 +34,7 @@ export default function (
const templateContext = isFunction(config.template) ? {} : config.template;
const htmlPluginOptions = {
context: {
lang: 'en',
...templateContext,
title: config.title,
container: config.mountPointId,
Expand Down
27 changes: 14 additions & 13 deletions src/scripts/utils/StyleguidistOptionsPlugin.ts
@@ -1,5 +1,4 @@
import { Tapable } from 'tapable';
import { Compiler, compilation } from 'webpack';
import { compilation, Compiler, WebpackPluginInstance, loader } from 'webpack';
import * as Rsg from '../../typings';

// Webpack plugin that makes Styleguidist config available for Styleguidist webpack loaders.
Expand All @@ -8,22 +7,24 @@ import * as Rsg from '../../typings';
// Other working in webpack 2 way is to use LoaderOptionsPlugin, but it has problems.
// See this issue for details: https://github.com/styleguidist/react-styleguidist/issues/328

export default class StyleguidistOptionsPlugin implements Tapable.Plugin {
export default class StyleguidistOptionsPlugin implements WebpackPluginInstance {
private options: Rsg.SanitizedStyleguidistConfig;

public constructor(options: Rsg.SanitizedStyleguidistConfig) {
this.options = options;
this.plugin = this.plugin.bind(this);
}

public plugin(compil: compilation.Compilation) {
const pluginFunc = (context: Rsg.StyleguidistLoaderContext, module: { resource?: boolean }) => {
if (!module.resource) {
return;
}
context._styleguidist = this.options;
};
compil.hooks.normalModuleLoader.tap('StyleguidistOptionsPlugin', pluginFunc);
}
private pluginFunc = (context: Rsg.StyleguidistLoaderContext, module: loader.LoaderContext) => {
if (!module.resource) {
return;
}
context._styleguidist = this.options;
};

private plugin = (compil: compilation.Compilation) => {
// FIXME: Find out how to type it properly
compil.hooks.normalModuleLoader.tap('StyleguidistOptionsPlugin', this.pluginFunc as any);
};

public apply(compiler: Compiler) {
compiler.hooks.compilation.tap('StyleguidistOptionsPlugin', this.plugin);
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/utils/ensureWebpack.ts
Expand Up @@ -14,11 +14,11 @@ if (!webpackVersion) {
throw new StyleguidistError(
'Webpack is required for Styleguidist, please add it to your project:\n\n' +
' npm install --save-dev webpack\n\n' +
'See how to configure it for your style guide:\n' +
'See how to configure webpack for your style guide:\n' +
consts.DOCS_WEBPACK
);
} else if (webpackVersion < MIN_WEBPACK_VERSION) {
throw new StyleguidistError(
`Webpack ${webpackVersion} is not supported by Styleguidist, the minimum version is ${MIN_WEBPACK_VERSION}`
`Webpack ${webpackVersion} is not supported by Styleguidist, the minimum supported version is ${MIN_WEBPACK_VERSION}`
);
}
9 changes: 0 additions & 9 deletions src/typings/dependencies/mini-html-webpack-plugin.ts

This file was deleted.

0 comments on commit 85c627d

Please sign in to comment.