stylex-webpack 0.2.1-beta.7 → 0.3.1-beta.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/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const PLUGIN_NAME = 'stylex';
|
|
|
7
7
|
const VIRTUAL_CSS_PATH = require.resolve('./stylex.virtual.css');
|
|
8
8
|
const VIRTUAL_CSS_PATTERN = /stylex\.virtual\.css/;
|
|
9
9
|
const STYLEX_CHUNK_NAME = '_stylex-webpack-generated';
|
|
10
|
+
const INCLUDE_REGEXP = /\.[cm]?[jt]sx?$/;
|
|
10
11
|
|
|
11
12
|
function _define_property(obj, key, value) {
|
|
12
13
|
if (key in obj) {
|
|
@@ -71,8 +72,7 @@ class StyleXPlugin {
|
|
|
71
72
|
compiler.hooks.make.tap(PLUGIN_NAME, (compilation)=>{
|
|
72
73
|
NormalModule.getCompilationHooks(compilation).loader.tap(PLUGIN_NAME, (loaderContext, mod)=>{
|
|
73
74
|
const extname = path.extname(mod.matchResource || mod.resource);
|
|
74
|
-
if (
|
|
75
|
-
/\.jsx?/.test(extname) || /\.tsx?/.test(extname)) {
|
|
75
|
+
if (INCLUDE_REGEXP.test(extname)) {
|
|
76
76
|
loaderContext.StyleXWebpackContextKey = {
|
|
77
77
|
registerStyleXRules: (resourcePath, stylexRules)=>{
|
|
78
78
|
this.stylexRules.set(resourcePath, stylexRules);
|
|
@@ -113,7 +113,7 @@ class StyleXPlugin {
|
|
|
113
113
|
const cssModulesInStylexChunk = compilation.chunkGraph.getChunkModulesIterableBySourceType(stylexChunk, 'css/mini-extract');
|
|
114
114
|
// we only re-collect stylex rules if we can found css in the stylex chunk
|
|
115
115
|
if (cssModulesInStylexChunk) {
|
|
116
|
-
this.stylexRules
|
|
116
|
+
this.stylexRules.clear();
|
|
117
117
|
for (const cssModule of cssModulesInStylexChunk){
|
|
118
118
|
const stringifiedStylexRule = cssModule._identifier.split('!').pop()?.split('?').pop();
|
|
119
119
|
if (!stringifiedStylexRule) {
|
|
@@ -128,7 +128,7 @@ class StyleXPlugin {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
// Let's find the css file that belongs to the stylex chunk
|
|
131
|
-
const cssAssetDetails = Object.entries(assets).find(([assetName])=>stylexChunk.files.has(assetName) && assetName.
|
|
131
|
+
const cssAssetDetails = Object.entries(assets).find(([assetName])=>stylexChunk.files.has(assetName) && assetName.endsWith('.css'));
|
|
132
132
|
if (!cssAssetDetails) {
|
|
133
133
|
return;
|
|
134
134
|
}
|
package/package.json
CHANGED