@compiled/webpack-loader 0.14.0 → 0.14.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.
|
@@ -11,8 +11,11 @@ function createDefaultResolver({ resolveOptions, webpackResolveOptions }) {
|
|
|
11
11
|
// Setup the default resolver, where webpack will merge any passed in options with the default
|
|
12
12
|
// resolve configuration. Ideally, we use this.getResolve({ ...resolve, useSyncFileSystemCalls: true, })
|
|
13
13
|
// However, it does not work correctly when in development mode :/
|
|
14
|
+
// @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
|
|
15
|
+
// compatible with @types/node fs types
|
|
14
16
|
const resolver = enhanced_resolve_1.ResolverFactory.createResolver(Object.assign(Object.assign(Object.assign({
|
|
15
|
-
// @ts-expect-error
|
|
17
|
+
// @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
|
|
18
|
+
// compatible with @types/node fs types
|
|
16
19
|
fileSystem: new enhanced_resolve_1.CachedInputFileSystem(fs_1.default, 4000) }, (webpackResolveOptions !== null && webpackResolveOptions !== void 0 ? webpackResolveOptions : {})), resolveOptions), {
|
|
17
20
|
// This makes the resolver invoke the callback synchronously
|
|
18
21
|
useSyncFileSystemCalls: true }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-default-resolver.js","sourceRoot":"","sources":["../src/create-default-resolver.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,+BAA+B;AAG/B,uDAA0E;AAQ1E,SAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAU;IACrF,8FAA8F;IAC9F,wGAAwG;IACxG,kEAAkE;
|
|
1
|
+
{"version":3,"file":"create-default-resolver.js","sourceRoot":"","sources":["../src/create-default-resolver.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,+BAA+B;AAG/B,uDAA0E;AAQ1E,SAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAU;IACrF,8FAA8F;IAC9F,wGAAwG;IACxG,kEAAkE;IAElE,0EAA0E;IAC1E,uCAAuC;IACvC,MAAM,QAAQ,GAAG,kCAAe,CAAC,cAAc;QAC7C,0EAA0E;QAC1E,uCAAuC;QACvC,UAAU,EAAE,IAAI,wCAAqB,CAAC,YAAE,EAAE,IAAI,CAAC,IAC5C,CAAC,qBAAqB,aAArB,qBAAqB,cAArB,qBAAqB,GAAI,EAAE,CAAC,GAC7B,cAAc;QACjB,4DAA4D;QAC5D,sBAAsB,EAAE,IAAI,IAC5B,CAAC;IAEH,OAAO;QACL,6EAA6E;QAC7E,WAAW,EAAE,CAAC,OAAe,EAAE,OAAe,EAAE,EAAE;YAChD,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,OAAO,CAAW,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC;AAvBD,sDAuBC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Compilation as CompilationType, Compiler, sources,
|
|
1
|
+
import type { Compilation as CompilationType, Compiler, sources, WebpackOptionsNormalized } from 'webpack';
|
|
2
2
|
/**
|
|
3
3
|
* Sets an option on the plugin config to tell loaders that the plugin has been configured.
|
|
4
4
|
* Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
|
|
@@ -7,7 +7,7 @@ import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } f
|
|
|
7
7
|
* @param pluginName
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare const setPluginConfiguredOption: (rules:
|
|
10
|
+
export declare const setPluginConfiguredOption: (rules: WebpackOptionsNormalized['module']['rules'], pluginName: string) => void;
|
|
11
11
|
/**
|
|
12
12
|
* Returns the string representation of an assets source.
|
|
13
13
|
*
|
package/dist/utils.js
CHANGED
|
@@ -13,7 +13,8 @@ const setOptionOnCompiledWebpackLoader = (use, pluginName) => {
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
for (const nestedUse of use) {
|
|
16
|
-
if (
|
|
16
|
+
if (nestedUse &&
|
|
17
|
+
typeof nestedUse === 'object' &&
|
|
17
18
|
(nestedUse.loader === '@compiled/webpack-loader' ||
|
|
18
19
|
((_a = nestedUse.loader) === null || _a === void 0 ? void 0 : _a.includes('/node_modules/@compiled/webpack-loader')))) {
|
|
19
20
|
const { options } = nestedUse;
|
|
@@ -34,11 +35,16 @@ const setOptionOnCompiledWebpackLoader = (use, pluginName) => {
|
|
|
34
35
|
const setPluginConfiguredOption = (rules, pluginName) => {
|
|
35
36
|
var _a;
|
|
36
37
|
for (const r of rules) {
|
|
38
|
+
if (!r) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
37
41
|
const rule = r;
|
|
38
42
|
const nestedRules = (_a = rule.oneOf) !== null && _a !== void 0 ? _a : rule.rules;
|
|
39
43
|
if (nestedRules) {
|
|
40
44
|
for (const nestedRule of nestedRules) {
|
|
41
|
-
|
|
45
|
+
if (nestedRule) {
|
|
46
|
+
setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
else {
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAQA;;;;;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;QAC9C,OAAO;KACR;IAED,KAAK,MAAM,SAAS,IAAI,GAAG,EAAE;QAC3B,IACE,SAAS;YACT,OAAO,SAAS,KAAK,Q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B,0BAOjC;AAEF;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,CACnC,QAAkB,EAClB,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.14.
|
|
3
|
+
"version": "0.14.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",
|
|
@@ -14,8 +14,12 @@ export function createDefaultResolver({ resolveOptions, webpackResolveOptions }:
|
|
|
14
14
|
// Setup the default resolver, where webpack will merge any passed in options with the default
|
|
15
15
|
// resolve configuration. Ideally, we use this.getResolve({ ...resolve, useSyncFileSystemCalls: true, })
|
|
16
16
|
// However, it does not work correctly when in development mode :/
|
|
17
|
+
|
|
18
|
+
// @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
|
|
19
|
+
// compatible with @types/node fs types
|
|
17
20
|
const resolver = ResolverFactory.createResolver({
|
|
18
|
-
// @ts-expect-error
|
|
21
|
+
// @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
|
|
22
|
+
// compatible with @types/node fs types
|
|
19
23
|
fileSystem: new CachedInputFileSystem(fs, 4000),
|
|
20
24
|
...(webpackResolveOptions ?? {}),
|
|
21
25
|
...resolveOptions,
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Compilation as CompilationType,
|
|
3
|
+
Compiler,
|
|
4
|
+
sources,
|
|
5
|
+
RuleSetRule,
|
|
6
|
+
WebpackOptionsNormalized,
|
|
7
|
+
} from 'webpack';
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* Helper function to set plugin configured option on the @compiled/webpack-loader
|
|
@@ -13,6 +19,7 @@ const setOptionOnCompiledWebpackLoader = (use: RuleSetRule['use'], pluginName: s
|
|
|
13
19
|
|
|
14
20
|
for (const nestedUse of use) {
|
|
15
21
|
if (
|
|
22
|
+
nestedUse &&
|
|
16
23
|
typeof nestedUse === 'object' &&
|
|
17
24
|
(nestedUse.loader === '@compiled/webpack-loader' ||
|
|
18
25
|
nestedUse.loader?.includes('/node_modules/@compiled/webpack-loader'))
|
|
@@ -34,15 +41,21 @@ const setOptionOnCompiledWebpackLoader = (use: RuleSetRule['use'], pluginName: s
|
|
|
34
41
|
* @returns
|
|
35
42
|
*/
|
|
36
43
|
export const setPluginConfiguredOption = (
|
|
37
|
-
rules:
|
|
44
|
+
rules: WebpackOptionsNormalized['module']['rules'],
|
|
38
45
|
pluginName: string
|
|
39
46
|
): void => {
|
|
40
47
|
for (const r of rules) {
|
|
48
|
+
if (!r) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
41
52
|
const rule = r as RuleSetRule;
|
|
42
53
|
const nestedRules = rule.oneOf ?? rule.rules;
|
|
43
54
|
if (nestedRules) {
|
|
44
55
|
for (const nestedRule of nestedRules) {
|
|
45
|
-
|
|
56
|
+
if (nestedRule) {
|
|
57
|
+
setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
|
|
58
|
+
}
|
|
46
59
|
}
|
|
47
60
|
} else {
|
|
48
61
|
setOptionOnCompiledWebpackLoader(rule.use, pluginName);
|