@compiled/webpack-loader 0.8.0 → 0.8.1
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/dist/compiled-loader.js +6 -3
- package/dist/compiled-loader.js.map +1 -1
- package/dist/extract-plugin.js +2 -5
- package/dist/extract-plugin.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/utils.d.ts +6 -3
- package/dist/utils.js +37 -15
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/compiled-loader.tsx +6 -3
- package/src/extract-plugin.tsx +3 -6
- package/src/types.tsx +7 -0
- package/src/utils.tsx +38 -20
package/dist/compiled-loader.js
CHANGED
|
@@ -31,7 +31,7 @@ let hasErrored = false;
|
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
33
|
function getLoaderOptions(context) {
|
|
34
|
-
const { bake = true, extract = false, importReact = undefined, nonce = undefined, resolve = {}, extensions = undefined, babelPlugins = [], } = typeof context.getOptions === 'undefined'
|
|
34
|
+
const { bake = true, extract = false, importReact = undefined, nonce = undefined, resolve = {}, extensions = undefined, babelPlugins = [], [extract_plugin_1.pluginName]: isPluginEnabled = false, } = typeof context.getOptions === 'undefined'
|
|
35
35
|
? // Webpack v4 flow
|
|
36
36
|
(0, loader_utils_1.getOptions)(context)
|
|
37
37
|
: // Webpack v5 flow
|
|
@@ -59,6 +59,9 @@ function getLoaderOptions(context) {
|
|
|
59
59
|
babelPlugins: {
|
|
60
60
|
type: 'array',
|
|
61
61
|
},
|
|
62
|
+
[extract_plugin_1.pluginName]: {
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
},
|
|
62
65
|
},
|
|
63
66
|
});
|
|
64
67
|
return {
|
|
@@ -69,6 +72,7 @@ function getLoaderOptions(context) {
|
|
|
69
72
|
resolve,
|
|
70
73
|
extensions,
|
|
71
74
|
babelPlugins,
|
|
75
|
+
[extract_plugin_1.pluginName]: isPluginEnabled,
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
@@ -153,8 +157,7 @@ async function compiledLoader(code) {
|
|
|
153
157
|
exports.default = compiledLoader;
|
|
154
158
|
function pitch() {
|
|
155
159
|
const options = getLoaderOptions(this);
|
|
156
|
-
|
|
157
|
-
if (!hasErrored && options.extract && !this[extract_plugin_1.pluginName]) {
|
|
160
|
+
if (!hasErrored && options.extract && !options[extract_plugin_1.pluginName]) {
|
|
158
161
|
this.emitError((0, utils_1.createError)('webpack-loader')(`You forgot to add the 'CompiledExtractPlugin' plugin (i.e \`{ plugins: [new CompiledExtractPlugin()] }\`), please read https://compiledcssinjs.com/docs/css-extraction-webpack`));
|
|
159
162
|
// We only want to error once, if we didn't do this you'd get an error for every file found.
|
|
160
163
|
hasErrored = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiled-loader.js","sourceRoot":"","sources":["../src/compiled-loader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,+BAA0C;AAE1C,sCAAgE;AAChE,2CAAyD;AACzD,uDAA0E;AAC1E,+CAA0C;AAG1C,qDAA8C;AAE9C,mCAAyC;AAEzC,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAA6C;IACrE,MAAM,EACJ,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,WAAW,GAAG,SAAS,EACvB,KAAK,GAAG,SAAS,EACjB,OAAO,GAAG,EAAE,EACZ,UAAU,GAAG,SAAS,EACtB,YAAY,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"compiled-loader.js","sourceRoot":"","sources":["../src/compiled-loader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,+BAA0C;AAE1C,sCAAgE;AAChE,2CAAyD;AACzD,uDAA0E;AAC1E,+CAA0C;AAG1C,qDAA8C;AAE9C,mCAAyC;AAEzC,IAAI,UAAU,GAAG,KAAK,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,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7E,QAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;AACH,CAAC;AA1FD,iCA0FC;AAED,SAAgB,KAAK;IACnB,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,2BAAU,CAAC,EAAE;QAC1D,IAAI,CAAC,SAAS,CACZ,IAAA,mBAAW,EAAC,gBAAgB,CAAC,CAC3B,gLAAgL,CACjL,CACF,CAAC;QAEF,4FAA4F;QAC5F,UAAU,GAAG,IAAI,CAAC;KACnB;AACH,CAAC;AAZD,sBAYC"}
|
package/dist/extract-plugin.js
CHANGED
|
@@ -83,6 +83,7 @@ const pushNodeModulesExtractLoader = (compiler, options) => {
|
|
|
83
83
|
// We turn off baking as we're only interested in extracting from node modules (they're already baked)!
|
|
84
84
|
bake: false,
|
|
85
85
|
extract: true,
|
|
86
|
+
[exports.pluginName]: true,
|
|
86
87
|
},
|
|
87
88
|
},
|
|
88
89
|
});
|
|
@@ -102,11 +103,7 @@ class CompiledExtractPlugin {
|
|
|
102
103
|
pushNodeModulesExtractLoader(compiler, __classPrivateFieldGet(this, _CompiledExtractPlugin_options, "f"));
|
|
103
104
|
forceCSSIntoOneStyleSheet(compiler);
|
|
104
105
|
compiler.hooks.compilation.tap(exports.pluginName, (compilation) => {
|
|
105
|
-
(0, utils_2.
|
|
106
|
-
// We add some information here to tell loaders that the plugin has been configured.
|
|
107
|
-
// Bundling will throw if this is missing (i.e. consumers did not setup correctly).
|
|
108
|
-
loaderContext[exports.pluginName] = true;
|
|
109
|
-
});
|
|
106
|
+
(0, utils_2.setPluginConfiguredOption)(compilation.options.module.rules, exports.pluginName);
|
|
110
107
|
(0, utils_2.getOptimizeAssetsHook)(compiler, compilation).tap(exports.pluginName, (assets) => {
|
|
111
108
|
const cssAssets = getCSSAssets(assets);
|
|
112
109
|
if (cssAssets.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-plugin.js","sourceRoot":"","sources":["../src/extract-plugin.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAqC;AACrC,2CAAyD;AAIzD,mCAKiB;AAEJ,QAAA,UAAU,GAAG,uBAAuB,CAAC;AACrC,QAAA,cAAc,GAAG,cAAc,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,CAAC,MAA6B,EAAE,EAAE;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACvB,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;QACpB,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,sBAAc,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACpF,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,yBAAyB,GAAG,CAAC,QAAkB,EAAE,EAAE;IACvD,MAAM,UAAU,GAAG;QACjB,WAAW,EAAE;YACX,IAAI,EAAE,sBAAc;YACpB,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,KAAK;YACb,mCAAmC;YACnC,IAAI,EAAE,2BAA2B;YACjC,OAAO,EAAE,IAAI;SACd;KACF,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE;QAClC,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC;KACpC;IAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE;QAC9C,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,GAAG;YAC1C,WAAW,EAAE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EAAE,CAAC,MAAM,EAAE,EAAE;gBACtE,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;gBACvC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC1B,OAAO;iBACR;gBAED,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;gBAC1B,MAAM,QAAQ,GAAG,IAAA,8BAAsB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACtD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,IAAA,UAAI,EAAC,QAAQ,CAAC,CAAC,CAAC;gBAEhD,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9BD,sDA8BC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ParserPlugin } from '@babel/parser';
|
|
2
2
|
import type { ResolveOptions, RuleSetCondition } from 'webpack';
|
|
3
|
+
import type { pluginName } from './extract-plugin';
|
|
3
4
|
export type { ResolveOptions };
|
|
4
5
|
export interface CompiledLoaderOptions {
|
|
5
6
|
/**
|
|
@@ -34,6 +35,10 @@ export interface CompiledLoaderOptions {
|
|
|
34
35
|
* List of babel plugins to be applied to evaluated files
|
|
35
36
|
*/
|
|
36
37
|
babelPlugins?: ParserPlugin[];
|
|
38
|
+
/**
|
|
39
|
+
* Set to true if CompiledExtractPlugin has been set up correctly
|
|
40
|
+
*/
|
|
41
|
+
[pluginName]?: boolean;
|
|
37
42
|
}
|
|
38
43
|
export interface CompiledExtractPluginOptions {
|
|
39
44
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { Compilation as CompilationType, Compiler, sources } from 'webpack';
|
|
1
|
+
import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } from 'webpack';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Sets an option on the plugin config to tell loaders that the plugin has been configured.
|
|
4
|
+
* Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
|
|
4
5
|
*
|
|
6
|
+
* @param rules
|
|
7
|
+
* @param pluginName
|
|
5
8
|
* @returns
|
|
6
9
|
*/
|
|
7
|
-
export declare const
|
|
10
|
+
export declare const setPluginConfiguredOption: (rules: (RuleSetRule | '...')[], pluginName: string) => void;
|
|
8
11
|
/**
|
|
9
12
|
* Returns the string representation of an assets source.
|
|
10
13
|
*
|
package/dist/utils.js
CHANGED
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toURIComponent = exports.getSources = exports.getOptimizeAssetsHook = exports.getAssetSourceContents = exports.
|
|
3
|
+
exports.toURIComponent = exports.getSources = exports.getOptimizeAssetsHook = exports.getAssetSourceContents = exports.setPluginConfiguredOption = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Sets an option on the plugin config to tell loaders that the plugin has been configured.
|
|
6
|
+
* Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
|
|
6
7
|
*
|
|
8
|
+
* @param rules
|
|
9
|
+
* @param pluginName
|
|
7
10
|
* @returns
|
|
8
11
|
*/
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
const setPluginConfiguredOption = (rules, pluginName) => {
|
|
13
|
+
for (const rule of rules) {
|
|
14
|
+
const use = rule.use;
|
|
15
|
+
if (!use || typeof use === 'string') {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(use)) {
|
|
19
|
+
if (!use.length) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
for (const nestedUse of use) {
|
|
23
|
+
if (typeof nestedUse !== 'object' || nestedUse.loader !== '@compiled/webpack-loader') {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const { options } = nestedUse;
|
|
27
|
+
if (!options || typeof options !== 'object' || !options.extract) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
options[pluginName] = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (typeof use === 'object' && use.loader === '@compiled/webpack-loader') {
|
|
35
|
+
const { options } = use;
|
|
36
|
+
if (!options || typeof options !== 'object' || !options.extract) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
options[pluginName] = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
21
43
|
};
|
|
22
|
-
exports.
|
|
44
|
+
exports.setPluginConfiguredOption = setPluginConfiguredOption;
|
|
23
45
|
/**
|
|
24
46
|
* Returns the string representation of an assets source.
|
|
25
47
|
*
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":";;;AAEA
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACI,MAAM,yBAAyB,GAAG,CACvC,KAA8B,EAC9B,UAAkB,EACZ,EAAE;IACR,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,GAAG,GAAI,IAAoB,CAAC,GAAG,CAAC;QACtC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YACnC,SAAS;SACV;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACtB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;gBACf,SAAS;aACV;YACD,KAAK,MAAM,SAAS,IAA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AO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,cAAc;IAClB,iBAAiB;IACjB,WAAW,CAAC,KAAK,CAAC,aAAa;QAC/B,iBAAiB;QACjB,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC;IAEnC,OAAO;QACL,GAAG,EAAE,CAAC,UAAkB,EAAE,QAAqD,EAAE,EAAE;YACjF,cAAc,CAAC,GAAG,CAChB,UAAU;gBACR,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC;oBACE,IAAI,EAAE,UAAU;oBAChB,KAAK,EAAE,WAAW,CAAC,kCAAkC;iBACtD,EACL,QAAQ,CACT,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,qBAAqB,yBA6BhC;AAEF;;;GAGG;AACI,MAAM,UAAU,GAAG,CAAC,QAAkB,EAAkB,EAAE;IAC/D,MAAM,EAAE,OAAO,EAAE;IACf,iBAAiB;IACjB,QAAQ,CAAC,OAAO;QAChB,iBAAiB;QACjB,EAAE,CAAC;IAEL,OAAO;IACL,iBAAiB;IACjB,OAAO;QACP,iBAAiB;QACjB,OAAO,CAAC,iBAAiB,CAAC,CAC3B,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,UAAU,cAarB;AAEF;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE;IACrD,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEhE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiled/webpack-loader",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "A familiar and performant compile time CSS-in-JS library for React.",
|
|
5
5
|
"homepage": "https://compiledcssinjs.com/docs/pkg-webpack-loader",
|
|
6
6
|
"bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.
|
|
24
|
-
"@compiled/babel-plugin": "^0.12.
|
|
23
|
+
"@babel/core": "^7.17.2",
|
|
24
|
+
"@compiled/babel-plugin": "^0.12.1",
|
|
25
25
|
"@compiled/babel-plugin-strip-runtime": "^0.11.4",
|
|
26
26
|
"@compiled/css": "^0.8.1",
|
|
27
27
|
"@compiled/react": "0.10.2",
|
package/src/compiled-loader.tsx
CHANGED
|
@@ -28,6 +28,7 @@ function getLoaderOptions(context: LoaderContext<CompiledLoaderOptions>) {
|
|
|
28
28
|
resolve = {},
|
|
29
29
|
extensions = undefined,
|
|
30
30
|
babelPlugins = [],
|
|
31
|
+
[pluginName]: isPluginEnabled = false,
|
|
31
32
|
}: CompiledLoaderOptions = typeof context.getOptions === 'undefined'
|
|
32
33
|
? // Webpack v4 flow
|
|
33
34
|
getOptions(context)
|
|
@@ -56,6 +57,9 @@ function getLoaderOptions(context: LoaderContext<CompiledLoaderOptions>) {
|
|
|
56
57
|
babelPlugins: {
|
|
57
58
|
type: 'array',
|
|
58
59
|
},
|
|
60
|
+
[pluginName]: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
},
|
|
59
63
|
},
|
|
60
64
|
});
|
|
61
65
|
|
|
@@ -67,6 +71,7 @@ function getLoaderOptions(context: LoaderContext<CompiledLoaderOptions>) {
|
|
|
67
71
|
resolve,
|
|
68
72
|
extensions,
|
|
69
73
|
babelPlugins,
|
|
74
|
+
[pluginName]: isPluginEnabled,
|
|
70
75
|
};
|
|
71
76
|
}
|
|
72
77
|
|
|
@@ -170,9 +175,7 @@ export default async function compiledLoader(
|
|
|
170
175
|
|
|
171
176
|
export function pitch(this: LoaderContext<CompiledLoaderOptions>): void {
|
|
172
177
|
const options = getLoaderOptions(this);
|
|
173
|
-
|
|
174
|
-
// @ts-expect-error No definitions for this[pluginName]
|
|
175
|
-
if (!hasErrored && options.extract && !this[pluginName]) {
|
|
178
|
+
if (!hasErrored && options.extract && !options[pluginName]) {
|
|
176
179
|
this.emitError(
|
|
177
180
|
createError('webpack-loader')(
|
|
178
181
|
`You forgot to add the 'CompiledExtractPlugin' plugin (i.e \`{ plugins: [new CompiledExtractPlugin()] }\`), please read https://compiledcssinjs.com/docs/css-extraction-webpack`
|
package/src/extract-plugin.tsx
CHANGED
|
@@ -5,9 +5,9 @@ import type { Compilation, Compiler } from 'webpack';
|
|
|
5
5
|
import type { CompiledExtractPluginOptions } from './types';
|
|
6
6
|
import {
|
|
7
7
|
getAssetSourceContents,
|
|
8
|
-
getNormalModuleHook,
|
|
9
8
|
getOptimizeAssetsHook,
|
|
10
9
|
getSources,
|
|
10
|
+
setPluginConfiguredOption,
|
|
11
11
|
} from './utils';
|
|
12
12
|
|
|
13
13
|
export const pluginName = 'CompiledExtractPlugin';
|
|
@@ -88,6 +88,7 @@ const pushNodeModulesExtractLoader = (
|
|
|
88
88
|
// We turn off baking as we're only interested in extracting from node modules (they're already baked)!
|
|
89
89
|
bake: false,
|
|
90
90
|
extract: true,
|
|
91
|
+
[pluginName]: true,
|
|
91
92
|
},
|
|
92
93
|
},
|
|
93
94
|
});
|
|
@@ -112,11 +113,7 @@ export class CompiledExtractPlugin {
|
|
|
112
113
|
forceCSSIntoOneStyleSheet(compiler);
|
|
113
114
|
|
|
114
115
|
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
115
|
-
|
|
116
|
-
// We add some information here to tell loaders that the plugin has been configured.
|
|
117
|
-
// Bundling will throw if this is missing (i.e. consumers did not setup correctly).
|
|
118
|
-
(loaderContext as any)[pluginName] = true;
|
|
119
|
-
});
|
|
116
|
+
setPluginConfiguredOption(compilation.options.module.rules, pluginName);
|
|
120
117
|
|
|
121
118
|
getOptimizeAssetsHook(compiler, compilation).tap(pluginName, (assets) => {
|
|
122
119
|
const cssAssets = getCSSAssets(assets);
|
package/src/types.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ParserPlugin } from '@babel/parser';
|
|
2
2
|
import type { ResolveOptions, RuleSetCondition } from 'webpack';
|
|
3
3
|
|
|
4
|
+
import type { pluginName } from './extract-plugin';
|
|
5
|
+
|
|
4
6
|
export type { ResolveOptions };
|
|
5
7
|
|
|
6
8
|
export interface CompiledLoaderOptions {
|
|
@@ -42,6 +44,11 @@ export interface CompiledLoaderOptions {
|
|
|
42
44
|
* List of babel plugins to be applied to evaluated files
|
|
43
45
|
*/
|
|
44
46
|
babelPlugins?: ParserPlugin[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set to true if CompiledExtractPlugin has been set up correctly
|
|
50
|
+
*/
|
|
51
|
+
[pluginName]?: boolean;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
export interface CompiledExtractPluginOptions {
|
package/src/utils.tsx
CHANGED
|
@@ -1,28 +1,46 @@
|
|
|
1
|
-
import type { Compilation as CompilationType, Compiler, sources } from 'webpack';
|
|
1
|
+
import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } from 'webpack';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Sets an option on the plugin config to tell loaders that the plugin has been configured.
|
|
5
|
+
* Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
|
|
5
6
|
*
|
|
7
|
+
* @param rules
|
|
8
|
+
* @param pluginName
|
|
6
9
|
* @returns
|
|
7
10
|
*/
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
):
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
export const setPluginConfiguredOption = (
|
|
12
|
+
rules: (RuleSetRule | '...')[],
|
|
13
|
+
pluginName: string
|
|
14
|
+
): void => {
|
|
15
|
+
for (const rule of rules) {
|
|
16
|
+
const use = (rule as RuleSetRule).use;
|
|
17
|
+
if (!use || typeof use === 'string') {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(use)) {
|
|
21
|
+
if (!use.length) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
for (const nestedUse of use) {
|
|
25
|
+
if (typeof nestedUse !== 'object' || nestedUse.loader !== '@compiled/webpack-loader') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const { options } = nestedUse;
|
|
29
|
+
if (!options || typeof options !== 'object' || !options.extract) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
options[pluginName] = true;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
if (typeof use === 'object' && use.loader === '@compiled/webpack-loader') {
|
|
36
|
+
const { options } = use;
|
|
37
|
+
if (!options || typeof options !== 'object' || !options.extract) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
options[pluginName] = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
26
44
|
};
|
|
27
45
|
|
|
28
46
|
/**
|