@stylexswc/postcss-plugin 0.15.1 → 0.15.2-rc.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/README.md +54 -13
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +94 -19
- package/dist/bundler.d.ts +2 -2
- package/dist/bundler.d.ts.map +1 -1
- package/dist/bundler.js +4 -8
- package/dist/discovery.d.ts +49 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +277 -0
- package/dist/index.d.ts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +39 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const plugin: {
|
|
2
|
-
({ cwd, rsOptions, include, exclude, useCSSLayers, }: import("./types").StyleXPluginOption): {
|
|
2
|
+
({ cwd, rsOptions, include, exclude, useCSSLayers, importSources, }: import("./types").StyleXPluginOption): {
|
|
3
3
|
postcssPlugin: string;
|
|
4
4
|
plugins: ((root: import("postcss").Root, result: import("postcss").Result) => void)[];
|
|
5
5
|
};
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import postcss from 'postcss';
|
|
2
2
|
import type { StyleXPluginOption } from './types';
|
|
3
3
|
declare function createPlugin(): {
|
|
4
|
-
({ cwd, rsOptions, include, exclude, useCSSLayers, }: StyleXPluginOption): {
|
|
4
|
+
({ cwd, rsOptions, include, exclude, useCSSLayers, importSources, }: StyleXPluginOption): {
|
|
5
5
|
postcssPlugin: string;
|
|
6
6
|
plugins: ((root: postcss.Root, result: postcss.Result) => void)[];
|
|
7
7
|
};
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAQ9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAOlD,iBAAS,YAAY;yEAehB,kBAAkB;;yBAsDC,OAAO,CAAC,IAAI,UAAU,OAAO,CAAC,MAAM;;;EAmE3D;AAED,eAAe,YAAY,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -5,19 +5,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const postcss_1 = __importDefault(require("postcss"));
|
|
7
7
|
const builder_1 = __importDefault(require("./builder"));
|
|
8
|
+
const discovery_1 = require("./discovery");
|
|
9
|
+
function isDebugEnabled() {
|
|
10
|
+
const value = String(process.env.STYLEX_POSTCSS_DEBUG ?? '').toLowerCase();
|
|
11
|
+
return value === '1' || value === 'true' || value === 'yes';
|
|
12
|
+
}
|
|
8
13
|
function createPlugin() {
|
|
9
14
|
const PLUGIN_NAME = '@stylexswc/postcss-plugin';
|
|
10
15
|
const builder = (0, builder_1.default)();
|
|
11
16
|
const isDev = process.env.NODE_ENV === 'development';
|
|
12
17
|
const plugin = ({
|
|
13
18
|
// By default reuses the Babel configuration from the project root.
|
|
14
|
-
cwd = process.cwd(), rsOptions = {}, include, exclude, useCSSLayers = false, }) => {
|
|
15
|
-
|
|
19
|
+
cwd = process.cwd(), rsOptions = {}, include, exclude, useCSSLayers = false, importSources, }) => {
|
|
20
|
+
const importSourcesResolution = (0, discovery_1.resolveImportSourcesWithMetadata)({
|
|
21
|
+
importSources,
|
|
22
|
+
rsOptions,
|
|
23
|
+
});
|
|
24
|
+
const effectiveImportSources = importSourcesResolution.importSources;
|
|
25
|
+
const includeResolution = (0, discovery_1.resolveIncludeWithMetadata)({
|
|
26
|
+
cwd,
|
|
27
|
+
include,
|
|
28
|
+
importSources: effectiveImportSources,
|
|
29
|
+
});
|
|
30
|
+
const effectiveInclude = includeResolution.include;
|
|
31
|
+
const effectiveExclude = (0, discovery_1.resolveExclude)({
|
|
32
|
+
include,
|
|
33
|
+
exclude,
|
|
34
|
+
});
|
|
35
|
+
const excludeWithDefaults = [
|
|
16
36
|
// Exclude type declaration files by default because it never contains any CSS rules.
|
|
17
37
|
'**/*.d.ts',
|
|
18
38
|
'**/*.flow',
|
|
19
|
-
...
|
|
39
|
+
...effectiveExclude,
|
|
20
40
|
];
|
|
41
|
+
if (isDebugEnabled()) {
|
|
42
|
+
console.info(`[${PLUGIN_NAME}] Auto-discovery details:\n${JSON.stringify({
|
|
43
|
+
cwd,
|
|
44
|
+
importSourcesSource: importSourcesResolution.source,
|
|
45
|
+
importSources: effectiveImportSources,
|
|
46
|
+
include: effectiveInclude,
|
|
47
|
+
includeWasExplicit: includeResolution.hasExplicitInclude,
|
|
48
|
+
discoveredDependencyDirectories: includeResolution.discoveredDependencyDirectories,
|
|
49
|
+
exclude: excludeWithDefaults,
|
|
50
|
+
}, null, 2)}`);
|
|
51
|
+
}
|
|
21
52
|
// Whether to skip the error when transforming StyleX rules.
|
|
22
53
|
// Useful in watch mode where Fast Refresh can recover from errors.
|
|
23
54
|
// Initial transform will still throw errors in watch mode to surface issues early.
|
|
@@ -30,12 +61,14 @@ function createPlugin() {
|
|
|
30
61
|
const fileName = result.opts.from;
|
|
31
62
|
// Configure the builder with the provided options
|
|
32
63
|
builder.configure({
|
|
33
|
-
include,
|
|
34
|
-
exclude,
|
|
64
|
+
include: effectiveInclude,
|
|
65
|
+
exclude: excludeWithDefaults,
|
|
35
66
|
cwd,
|
|
36
67
|
rsOptions: {
|
|
37
68
|
...rsOptions,
|
|
38
|
-
importSources:
|
|
69
|
+
importSources: effectiveImportSources.length > 0
|
|
70
|
+
? effectiveImportSources
|
|
71
|
+
: rsOptions?.importSources ?? ['@stylexjs/stylex', 'stylex'],
|
|
39
72
|
styleResolution: rsOptions?.styleResolution ?? 'property-specificity',
|
|
40
73
|
},
|
|
41
74
|
useCSSLayers,
|