@compiled/webpack-loader 0.8.4 → 0.8.7
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/css-loader/README.md +1 -1
- package/dist/__fixtures__/async-styles.js +5 -1
- package/dist/__fixtures__/async-styles.js.map +1 -1
- package/dist/compiled-loader.js +7 -21
- package/dist/compiled-loader.js.map +1 -1
- package/dist/css-loader.d.ts +1 -1
- package/dist/css-loader.js +1 -1
- package/dist/css-loader.js.map +1 -1
- package/dist/extract-plugin.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +28 -38
- package/dist/utils.js.map +1 -1
- package/package.json +13 -13
- package/src/__tests__/{compiled-loader.test.tsx → compiled-loader.test.ts} +0 -0
- package/src/__tests__/{extract-plugin.test.tsx → extract-plugin.test.ts} +0 -0
- package/src/__tests__/{test-utils.tsx → test-utils.ts} +0 -0
- package/src/{compiled-loader.tsx → compiled-loader.ts} +9 -24
- package/src/{css-loader.tsx → css-loader.ts} +1 -1
- package/src/{extract-plugin.tsx → extract-plugin.ts} +0 -0
- package/src/{index.tsx → index.ts} +0 -0
- package/src/{types.tsx → types.ts} +0 -0
- package/src/{utils.tsx → utils.ts} +28 -38
package/css-loader/README.md
CHANGED
|
@@ -8,4 +8,4 @@ used for two reasons:
|
|
|
8
8
|
1. thread safe collection of styles
|
|
9
9
|
1. caching -- resulting in faster bundles
|
|
10
10
|
|
|
11
|
-
You can find it being used here `packages/webpack-loader/src/compiled-loader.
|
|
11
|
+
You can find it being used here `packages/webpack-loader/src/compiled-loader.ts`.
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-styles.js","sourceRoot":"","sources":["../../src/__fixtures__/async-styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"async-styles.js","sourceRoot":"","sources":["../../src/__fixtures__/async-styles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAO,mBAAmB,IAAE"}
|
package/dist/compiled-loader.js
CHANGED
|
@@ -22,7 +22,6 @@ const utils_1 = require("@compiled/utils");
|
|
|
22
22
|
const enhanced_resolve_1 = require("enhanced-resolve");
|
|
23
23
|
const loader_utils_1 = require("loader-utils");
|
|
24
24
|
const extract_plugin_1 = require("./extract-plugin");
|
|
25
|
-
const utils_2 = require("./utils");
|
|
26
25
|
let hasErrored = false;
|
|
27
26
|
/**
|
|
28
27
|
* Returns user configuration.
|
|
@@ -84,13 +83,13 @@ function getLoaderOptions(context) {
|
|
|
84
83
|
async function compiledLoader(code) {
|
|
85
84
|
var _a, _b, _c;
|
|
86
85
|
const callback = this.async();
|
|
87
|
-
// Bail early if Compiled isn't in the module
|
|
88
|
-
if (code.indexOf('@compiled/react') === -1
|
|
86
|
+
// Bail early if Compiled isn't in the module or we're looking at compiled runtime code
|
|
87
|
+
if (code.indexOf('@compiled/react') === -1 ||
|
|
88
|
+
this.resourcePath.includes('/node_modules/@compiled/react')) {
|
|
89
89
|
return callback(null, code);
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
92
|
const includedFiles = [];
|
|
93
|
-
const foundCSSRules = [];
|
|
94
93
|
const _d = getLoaderOptions(this), { resolve } = _d, options = __rest(_d, ["resolve"]);
|
|
95
94
|
// Transform to an AST using the local babel config.
|
|
96
95
|
const ast = await (0, core_1.parseAsync)(code, {
|
|
@@ -115,7 +114,9 @@ async function compiledLoader(code) {
|
|
|
115
114
|
plugins: [
|
|
116
115
|
options.extract && [
|
|
117
116
|
'@compiled/babel-plugin-strip-runtime',
|
|
118
|
-
{
|
|
117
|
+
{
|
|
118
|
+
styleSheetPath: `@compiled/webpack-loader/css-loader!@compiled/webpack-loader/css-loader/${extract_plugin_1.styleSheetName}.css`,
|
|
119
|
+
},
|
|
119
120
|
],
|
|
120
121
|
options.bake && [
|
|
121
122
|
'@compiled/babel-plugin',
|
|
@@ -131,22 +132,7 @@ async function compiledLoader(code) {
|
|
|
131
132
|
includedFiles.forEach((file) => {
|
|
132
133
|
this.addDependency((0, path_1.normalize)(file));
|
|
133
134
|
});
|
|
134
|
-
|
|
135
|
-
if (options.extract && foundCSSRules.length) {
|
|
136
|
-
foundCSSRules.forEach((rule) => {
|
|
137
|
-
// Each found atomic rule will create a new import that uses `@compiled/webpack-loader/css-loader`.
|
|
138
|
-
// The benefit is two fold:
|
|
139
|
-
// (1) thread safe collection of styles
|
|
140
|
-
// (2) caching -- resulting in faster builds (one import per rule!)
|
|
141
|
-
const params = (0, utils_2.toURIComponent)(rule);
|
|
142
|
-
// We use require instead of import so it works with both ESM and CJS source.
|
|
143
|
-
// If we used ESM it would blow up with CJS source, unfortunately.
|
|
144
|
-
output = `
|
|
145
|
-
require("@compiled/webpack-loader/css-loader!@compiled/webpack-loader/css-loader/${extract_plugin_1.styleSheetName}.css?style=${params}");
|
|
146
|
-
${output}`;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
callback(null, output, (_c = result === null || result === void 0 ? void 0 : result.map) !== null && _c !== void 0 ? _c : undefined);
|
|
135
|
+
callback(null, (result === null || result === void 0 ? void 0 : result.code) || '', (_c = result === null || result === void 0 ? void 0 : result.map) !== null && _c !== void 0 ? _c : undefined);
|
|
150
136
|
}
|
|
151
137
|
catch (e) {
|
|
152
138
|
// @ts-expect-error Not checking for error type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiled-loader.js","sourceRoot":"","sources":["../src/compiled-loader.
|
|
1
|
+
{"version":3,"file":"compiled-loader.js","sourceRoot":"","sources":["../src/compiled-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,+BAA0C;AAE1C,sCAAgE;AAChE,2CAAyD;AACzD,uDAA0E;AAC1E,+CAA0C;AAG1C,qDAA8D;AAG9D,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,EACjB,CAAC,2BAAU,CAAC,EAAE,eAAe,GAAG,KAAK,GACtC,GAA0B,OAAO,OAAO,CAAC,UAAU,KAAK,WAAW;QAClE,CAAC,CAAC,kBAAkB;YAClB,IAAA,yBAAU,EAAC,OAAO,CAAC;QACrB,CAAC,CAAC,kBAAkB;YAClB,OAAO,CAAC,UAAU,CAAC;gBACjB,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,SAAS;qBAChB;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,SAAS;qBAChB;oBACD,WAAW,EAAE;wBACX,IAAI,EAAE,SAAS;qBAChB;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;qBACf;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;qBACf;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,OAAO;qBACd;oBACD,YAAY,EAAE;wBACZ,IAAI,EAAE,OAAO;qBACd;oBACD,CAAC,2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C;QAC7E,QAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;AACH,CAAC;AA5ED,iCA4EC;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/css-loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LoaderContext } from 'webpack';
|
|
2
2
|
/**
|
|
3
|
-
* CSSLoader will take the style query params added by `./compiled-loader.
|
|
3
|
+
* CSSLoader will take the style query params added by `./compiled-loader.ts` and turn it into CSS.
|
|
4
4
|
*/
|
|
5
5
|
export default function CSSLoader(this: LoaderContext<void>): string;
|
|
6
6
|
/**
|
package/dist/css-loader.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pitch = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
/**
|
|
6
|
-
* CSSLoader will take the style query params added by `./compiled-loader.
|
|
6
|
+
* CSSLoader will take the style query params added by `./compiled-loader.ts` and turn it into CSS.
|
|
7
7
|
*/
|
|
8
8
|
function CSSLoader() {
|
|
9
9
|
const query = new url_1.URLSearchParams(this.resourceQuery);
|
package/dist/css-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-loader.js","sourceRoot":"","sources":["../src/css-loader.
|
|
1
|
+
{"version":3,"file":"css-loader.js","sourceRoot":"","sources":["../src/css-loader.ts"],"names":[],"mappings":";;;AAAA,6BAAsC;AAItC;;GAEG;AACH,SAAwB,SAAS;IAC/B,MAAM,KAAK,GAAG,IAAI,qBAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,SAAS,IAAI,EAAE,CAAC;AACzB,CAAC;AAJD,4BAIC;AAED;;GAEG;AACH,SAAgB,KAAK;IACnB,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE;QACnC,6CAA6C;QAC7C,OAAO;KACR;IAED,+DAA+D;IAC/D,8EAA8E;IAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAY,CAAC,CAAC;AAClC,CAAC;AAVD,sBAUC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-plugin.js","sourceRoot":"","sources":["../src/extract-plugin.
|
|
1
|
+
{"version":3,"file":"extract-plugin.js","sourceRoot":"","sources":["../src/extract-plugin.ts"],"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,EAA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AS,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/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAmD;AAA1C,2HAAA,OAAO,OAAA;AAAE,wGAAA,KAAK,OAAA;AACvB,mDAAyD;AAAhD,uHAAA,qBAAqB,OAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
CHANGED
|
@@ -29,11 +29,3 @@ export declare const getOptimizeAssetsHook: (compiler: Compiler, compilation: Co
|
|
|
29
29
|
* @returns
|
|
30
30
|
*/
|
|
31
31
|
export declare const getSources: (compiler: Compiler) => typeof sources;
|
|
32
|
-
/**
|
|
33
|
-
* Escapes a CSS rule to be a valid query param.
|
|
34
|
-
* Also escapes escalamation marks (!) to not confuse webpack.
|
|
35
|
-
*
|
|
36
|
-
* @param rule
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
export declare const toURIComponent: (rule: string) => string;
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getSources = exports.getOptimizeAssetsHook = exports.getAssetSourceContents = exports.setPluginConfiguredOption = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to set plugin configured option on the @compiled/webpack-loader
|
|
6
|
+
*
|
|
7
|
+
* @param use
|
|
8
|
+
* @param pluginName
|
|
9
|
+
*/
|
|
10
|
+
const setOptionOnCompiledWebpackLoader = (use, pluginName) => {
|
|
11
|
+
if (!use || !Array.isArray(use) || !use.length) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
for (const nestedUse of use) {
|
|
15
|
+
if (typeof nestedUse === 'object' && nestedUse.loader === '@compiled/webpack-loader') {
|
|
16
|
+
const { options } = nestedUse;
|
|
17
|
+
if (options !== undefined && typeof options === 'object' && options.extract !== undefined) {
|
|
18
|
+
options[pluginName] = true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
4
23
|
/**
|
|
5
24
|
* Sets an option on the plugin config to tell loaders that the plugin has been configured.
|
|
6
25
|
* Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
|
|
@@ -10,34 +29,17 @@ exports.toURIComponent = exports.getSources = exports.getOptimizeAssetsHook = ex
|
|
|
10
29
|
* @returns
|
|
11
30
|
*/
|
|
12
31
|
const setPluginConfiguredOption = (rules, pluginName) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
32
|
+
var _a;
|
|
33
|
+
for (const r of rules) {
|
|
34
|
+
const rule = r;
|
|
35
|
+
const nestedRules = (_a = rule.oneOf) !== null && _a !== void 0 ? _a : rule.rules;
|
|
36
|
+
if (nestedRules) {
|
|
37
|
+
for (const nestedRule of nestedRules) {
|
|
38
|
+
setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
else {
|
|
34
|
-
|
|
35
|
-
const { options } = use;
|
|
36
|
-
if (!options || typeof options !== 'object' || !options.extract) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
options[pluginName] = true;
|
|
40
|
-
}
|
|
42
|
+
setOptionOnCompiledWebpackLoader(rule.use, pluginName);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
};
|
|
@@ -103,16 +105,4 @@ const getSources = (compiler) => {
|
|
|
103
105
|
require('webpack-sources'));
|
|
104
106
|
};
|
|
105
107
|
exports.getSources = getSources;
|
|
106
|
-
/**
|
|
107
|
-
* Escapes a CSS rule to be a valid query param.
|
|
108
|
-
* Also escapes escalamation marks (!) to not confuse webpack.
|
|
109
|
-
*
|
|
110
|
-
* @param rule
|
|
111
|
-
* @returns
|
|
112
|
-
*/
|
|
113
|
-
const toURIComponent = (rule) => {
|
|
114
|
-
const component = encodeURIComponent(rule).replace(/!/g, '%21');
|
|
115
|
-
return component;
|
|
116
|
-
};
|
|
117
|
-
exports.toURIComponent = toURIComponent;
|
|
118
108
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAM,gCAAgC,GAAG,CAAC,GAAuB,EAAE,UAAkB,EAAE,EAAE;IACvF,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;Q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,WAA4B,EAC+B,EAAE;IAC7D,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE;IAC5B,iBAAiB;IACjB,QAAQ,CAAC,OAAO;QAChB,iBAAiB;QACjB,OAAO,CAAC,SAAS,CAAC,CAAC;IACrB,MAAM,UAAU,GAAG,OAAO,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiled/webpack-loader",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
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,25 +20,25 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.17.
|
|
24
|
-
"@compiled/babel-plugin": "^0.
|
|
25
|
-
"@compiled/babel-plugin-strip-runtime": "^0.
|
|
26
|
-
"@compiled/css": "^0.8.
|
|
27
|
-
"@compiled/react": "0.10.
|
|
28
|
-
"@compiled/utils": "^0.6.
|
|
23
|
+
"@babel/core": "^7.17.8",
|
|
24
|
+
"@compiled/babel-plugin": "^0.15.0",
|
|
25
|
+
"@compiled/babel-plugin-strip-runtime": "^0.14.1",
|
|
26
|
+
"@compiled/css": "^0.8.2",
|
|
27
|
+
"@compiled/react": "0.10.4",
|
|
28
|
+
"@compiled/utils": "^0.6.16",
|
|
29
29
|
"enhanced-resolve": "^5.8.3",
|
|
30
30
|
"loader-utils": "^2.0.2",
|
|
31
|
-
"webpack-sources": "^
|
|
31
|
+
"webpack-sources": "^3.2.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"babel-loader": "^8.2.
|
|
35
|
-
"css-loader": "^
|
|
34
|
+
"babel-loader": "^8.2.4",
|
|
35
|
+
"css-loader": "^6.7.1",
|
|
36
36
|
"memfs": "^3.4.1",
|
|
37
37
|
"mini-css-extract-plugin": "^1.6.2",
|
|
38
38
|
"react": "^17.0.2",
|
|
39
|
-
"ts-node": "^10.
|
|
40
|
-
"tsconfig-paths": "^3.
|
|
41
|
-
"webpack": "^5.
|
|
39
|
+
"ts-node": "^10.7.0",
|
|
40
|
+
"tsconfig-paths": "^3.13.0",
|
|
41
|
+
"webpack": "^5.70.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"webpack": ">= 4.46.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -9,7 +9,6 @@ import type { LoaderContext } from 'webpack';
|
|
|
9
9
|
|
|
10
10
|
import { pluginName, styleSheetName } from './extract-plugin';
|
|
11
11
|
import type { CompiledLoaderOptions } from './types';
|
|
12
|
-
import { toURIComponent } from './utils';
|
|
13
12
|
|
|
14
13
|
let hasErrored = false;
|
|
15
14
|
|
|
@@ -87,14 +86,16 @@ export default async function compiledLoader(
|
|
|
87
86
|
): Promise<void> {
|
|
88
87
|
const callback = this.async();
|
|
89
88
|
|
|
90
|
-
// Bail early if Compiled isn't in the module
|
|
91
|
-
if (
|
|
89
|
+
// Bail early if Compiled isn't in the module or we're looking at compiled runtime code
|
|
90
|
+
if (
|
|
91
|
+
code.indexOf('@compiled/react') === -1 ||
|
|
92
|
+
this.resourcePath.includes('/node_modules/@compiled/react')
|
|
93
|
+
) {
|
|
92
94
|
return callback(null, code);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
try {
|
|
96
98
|
const includedFiles: string[] = [];
|
|
97
|
-
const foundCSSRules: string[] = [];
|
|
98
99
|
const { resolve, ...options } = getLoaderOptions(this);
|
|
99
100
|
|
|
100
101
|
// Transform to an AST using the local babel config.
|
|
@@ -125,7 +126,9 @@ export default async function compiledLoader(
|
|
|
125
126
|
plugins: [
|
|
126
127
|
options.extract && [
|
|
127
128
|
'@compiled/babel-plugin-strip-runtime',
|
|
128
|
-
{
|
|
129
|
+
{
|
|
130
|
+
styleSheetPath: `@compiled/webpack-loader/css-loader!@compiled/webpack-loader/css-loader/${styleSheetName}.css`,
|
|
131
|
+
},
|
|
129
132
|
],
|
|
130
133
|
options.bake && [
|
|
131
134
|
'@compiled/babel-plugin',
|
|
@@ -147,25 +150,7 @@ export default async function compiledLoader(
|
|
|
147
150
|
this.addDependency(normalize(file));
|
|
148
151
|
});
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (options.extract && foundCSSRules.length) {
|
|
153
|
-
foundCSSRules.forEach((rule) => {
|
|
154
|
-
// Each found atomic rule will create a new import that uses `@compiled/webpack-loader/css-loader`.
|
|
155
|
-
// The benefit is two fold:
|
|
156
|
-
// (1) thread safe collection of styles
|
|
157
|
-
// (2) caching -- resulting in faster builds (one import per rule!)
|
|
158
|
-
const params = toURIComponent(rule);
|
|
159
|
-
|
|
160
|
-
// We use require instead of import so it works with both ESM and CJS source.
|
|
161
|
-
// If we used ESM it would blow up with CJS source, unfortunately.
|
|
162
|
-
output = `
|
|
163
|
-
require("@compiled/webpack-loader/css-loader!@compiled/webpack-loader/css-loader/${styleSheetName}.css?style=${params}");
|
|
164
|
-
${output}`;
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
callback(null, output, result?.map ?? undefined);
|
|
153
|
+
callback(null, result?.code || '', result?.map ?? undefined);
|
|
169
154
|
} catch (e: unknown) {
|
|
170
155
|
// @ts-expect-error Not checking for error type
|
|
171
156
|
const error = createError('compiled-loader', 'Unhandled exception')(e.stack);
|
|
@@ -3,7 +3,7 @@ import { URLSearchParams } from 'url';
|
|
|
3
3
|
import type { LoaderContext } from 'webpack';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* CSSLoader will take the style query params added by `./compiled-loader.
|
|
6
|
+
* CSSLoader will take the style query params added by `./compiled-loader.ts` and turn it into CSS.
|
|
7
7
|
*/
|
|
8
8
|
export default function CSSLoader(this: LoaderContext<void>): string {
|
|
9
9
|
const query = new URLSearchParams(this.resourceQuery);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } from 'webpack';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to set plugin configured option on the @compiled/webpack-loader
|
|
5
|
+
*
|
|
6
|
+
* @param use
|
|
7
|
+
* @param pluginName
|
|
8
|
+
*/
|
|
9
|
+
const setOptionOnCompiledWebpackLoader = (use: RuleSetRule['use'], pluginName: string) => {
|
|
10
|
+
if (!use || !Array.isArray(use) || !use.length) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
for (const nestedUse of use) {
|
|
15
|
+
if (typeof nestedUse === 'object' && nestedUse.loader === '@compiled/webpack-loader') {
|
|
16
|
+
const { options } = nestedUse;
|
|
17
|
+
if (options !== undefined && typeof options === 'object' && options.extract !== undefined) {
|
|
18
|
+
options[pluginName] = true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
3
24
|
/**
|
|
4
25
|
* Sets an option on the plugin config to tell loaders that the plugin has been configured.
|
|
5
26
|
* Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
|
|
@@ -12,33 +33,15 @@ export const setPluginConfiguredOption = (
|
|
|
12
33
|
rules: (RuleSetRule | '...')[],
|
|
13
34
|
pluginName: string
|
|
14
35
|
): void => {
|
|
15
|
-
for (const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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;
|
|
36
|
+
for (const r of rules) {
|
|
37
|
+
const rule = r as RuleSetRule;
|
|
38
|
+
const nestedRules = rule.oneOf ?? rule.rules;
|
|
39
|
+
if (nestedRules) {
|
|
40
|
+
for (const nestedRule of nestedRules) {
|
|
41
|
+
setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
|
|
33
42
|
}
|
|
34
43
|
} else {
|
|
35
|
-
|
|
36
|
-
const { options } = use;
|
|
37
|
-
if (!options || typeof options !== 'object' || !options.extract) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
options[pluginName] = true;
|
|
41
|
-
}
|
|
44
|
+
setOptionOnCompiledWebpackLoader(rule.use, pluginName);
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
};
|
|
@@ -113,16 +116,3 @@ export const getSources = (compiler: Compiler): typeof sources => {
|
|
|
113
116
|
require('webpack-sources')
|
|
114
117
|
);
|
|
115
118
|
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Escapes a CSS rule to be a valid query param.
|
|
119
|
-
* Also escapes escalamation marks (!) to not confuse webpack.
|
|
120
|
-
*
|
|
121
|
-
* @param rule
|
|
122
|
-
* @returns
|
|
123
|
-
*/
|
|
124
|
-
export const toURIComponent = (rule: string): string => {
|
|
125
|
-
const component = encodeURIComponent(rule).replace(/!/g, '%21');
|
|
126
|
-
|
|
127
|
-
return component;
|
|
128
|
-
};
|