scoobie 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/webpack/config.ts +11 -0
- package/webpack/index.ts +6 -0
- package/webpack/{webpackPlugin.js → webpackPlugin.ts} +22 -19
- package/webpack/config.js +0 -11
- package/webpack/index.js +0 -10
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "12.0.0",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@mdx-js/loader": "^1.6.22",
|
|
10
10
|
"@mdx-js/react": "^1.6.22",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-helmet": "6.1.0",
|
|
43
43
|
"react-router-dom": "6.0.2",
|
|
44
44
|
"semantic-release": "18.0.0",
|
|
45
|
-
"sku": "11.1
|
|
45
|
+
"sku": "11.2.1"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"src",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { merge } from 'webpack-merge';
|
|
2
|
+
|
|
3
|
+
import { ScoobieWebpackPlugin } from './webpackPlugin';
|
|
4
|
+
|
|
5
|
+
export const dangerouslySetWebpackConfig = (webpackConfig: any) =>
|
|
6
|
+
merge(webpackConfig, {
|
|
7
|
+
plugins: [
|
|
8
|
+
// This must run after SkuWebpackPlugin.
|
|
9
|
+
new ScoobieWebpackPlugin(),
|
|
10
|
+
],
|
|
11
|
+
});
|
package/webpack/index.ts
ADDED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
|
|
3
|
+
// TODO: Convert our Remark logic to TypeScript
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import { remarkPlugin } from '../remark';
|
|
6
|
+
|
|
7
|
+
type RemarkPlugin = unknown;
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* Vendored from `sku/config/webpack/utils`.
|
|
@@ -12,7 +18,7 @@ const SKU_WEBPACK_UTILS = {
|
|
|
12
18
|
|
|
13
19
|
const ruleTestsToRemove = new Set(Object.values(SKU_WEBPACK_UTILS).map(String));
|
|
14
20
|
|
|
15
|
-
const createMdxRule = (remarkPlugins) => ({
|
|
21
|
+
const createMdxRule = (remarkPlugins: RemarkPlugin[]) => ({
|
|
16
22
|
test: /\.mdx?$/i,
|
|
17
23
|
use: [
|
|
18
24
|
{
|
|
@@ -39,10 +45,10 @@ const createMdxRule = (remarkPlugins) => ({
|
|
|
39
45
|
*
|
|
40
46
|
* {@link https://github.com/seek-oss/sku/blob/v11.0.2/config/webpack/webpack.config.js#L125}
|
|
41
47
|
*/
|
|
42
|
-
const shouldEmit = (compiler) =>
|
|
48
|
+
const shouldEmit = (compiler: Compiler) =>
|
|
43
49
|
compiler.options.name === 'client' || compiler.options.name === 'preview';
|
|
44
50
|
|
|
45
|
-
const createImageRule = (compiler) => ({
|
|
51
|
+
const createImageRule = (compiler: Compiler) => ({
|
|
46
52
|
test: [/\.jpe?g$/i, /\.png$/i],
|
|
47
53
|
type: 'asset/resource',
|
|
48
54
|
generator: {
|
|
@@ -50,7 +56,7 @@ const createImageRule = (compiler) => ({
|
|
|
50
56
|
},
|
|
51
57
|
});
|
|
52
58
|
|
|
53
|
-
const createSvgRule = (compiler) => ({
|
|
59
|
+
const createSvgRule = (compiler: Compiler) => ({
|
|
54
60
|
test: /\.svg$/i,
|
|
55
61
|
type: 'asset/resource',
|
|
56
62
|
generator: {
|
|
@@ -85,14 +91,15 @@ const createSvgRule = (compiler) => ({
|
|
|
85
91
|
],
|
|
86
92
|
});
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
interface Config {
|
|
95
|
+
mermaid?: { rootDir: string };
|
|
96
|
+
remark?: (defaultPlugins: unknown[]) => unknown[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class ScoobieWebpackPlugin {
|
|
100
|
+
private remarkPlugins: unknown[];
|
|
101
|
+
|
|
102
|
+
constructor(config: Config = {}) {
|
|
96
103
|
const defaultRemarkPlugins = [
|
|
97
104
|
...(config.mermaid ? [[remarkPlugin.mermaid, config.mermaid]] : []),
|
|
98
105
|
remarkPlugin.slug,
|
|
@@ -107,7 +114,7 @@ class ScoobieWebpackPlugin {
|
|
|
107
114
|
: defaultRemarkPlugins;
|
|
108
115
|
}
|
|
109
116
|
|
|
110
|
-
apply(compiler) {
|
|
117
|
+
apply(compiler: Compiler) {
|
|
111
118
|
/**
|
|
112
119
|
* Get rid of the image and SVG rules from `SkuWebpackPlugin`.
|
|
113
120
|
*
|
|
@@ -126,7 +133,7 @@ class ScoobieWebpackPlugin {
|
|
|
126
133
|
* {@link https://webpack.js.org/guides/asset-modules/}
|
|
127
134
|
*/
|
|
128
135
|
const rules = compiler.options.module.rules.filter(
|
|
129
|
-
(rule) => !ruleTestsToRemove.has(String(rule.test)),
|
|
136
|
+
(rule) => rule === '...' || !ruleTestsToRemove.has(String(rule.test)),
|
|
130
137
|
);
|
|
131
138
|
|
|
132
139
|
rules.push(createMdxRule(this.remarkPlugins));
|
|
@@ -136,7 +143,3 @@ class ScoobieWebpackPlugin {
|
|
|
136
143
|
compiler.options.module.rules = rules;
|
|
137
144
|
}
|
|
138
145
|
}
|
|
139
|
-
|
|
140
|
-
module.exports = {
|
|
141
|
-
ScoobieWebpackPlugin,
|
|
142
|
-
};
|
package/webpack/config.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const { merge } = require('webpack-merge');
|
|
2
|
-
|
|
3
|
-
const { ScoobieWebpackPlugin } = require('./webpackPlugin');
|
|
4
|
-
|
|
5
|
-
module.exports.dangerouslySetWebpackConfig = (webpackConfig) =>
|
|
6
|
-
merge(webpackConfig, {
|
|
7
|
-
plugins: [
|
|
8
|
-
// This must run after SkuWebpackPlugin.
|
|
9
|
-
new ScoobieWebpackPlugin(),
|
|
10
|
-
],
|
|
11
|
-
});
|
package/webpack/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const { merge } = require('webpack-merge');
|
|
2
|
-
|
|
3
|
-
const { dangerouslySetWebpackConfig } = require('./config');
|
|
4
|
-
const { ScoobieWebpackPlugin } = require('./webpackPlugin');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
ScoobieWebpackPlugin,
|
|
8
|
-
dangerouslySetWebpackConfig,
|
|
9
|
-
merge,
|
|
10
|
-
};
|