@vanilla-extract/vite-plugin 4.0.10 → 4.0.12
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.
|
@@ -13,6 +13,18 @@ const virtualExtCss = '.vanilla.css';
|
|
|
13
13
|
const isVirtualId = id => id.endsWith(virtualExtCss);
|
|
14
14
|
const fileIdToVirtualId = id => `${id}${virtualExtCss}`;
|
|
15
15
|
const virtualIdToFileId = virtualId => virtualId.slice(0, -virtualExtCss.length);
|
|
16
|
+
const removeIncompatiblePlugins = plugin => typeof plugin === 'object' && plugin !== null && 'name' in plugin &&
|
|
17
|
+
// Prevent an infinite loop where the compiler creates a new instance of the plugin,
|
|
18
|
+
// which creates a new compiler, which creates a new instance of the plugin, etc.
|
|
19
|
+
plugin.name !== 'vanilla-extract' &&
|
|
20
|
+
// Skip Remix because it throws an error if it's not loaded with a config file.
|
|
21
|
+
// If it _is_ loaded with a config file, it will create an infinite loop because it
|
|
22
|
+
// also has a child compiler which uses the same mechanism to load the config file.
|
|
23
|
+
// https://github.com/remix-run/remix/pull/7990#issuecomment-1809356626
|
|
24
|
+
// Additionally, some internal Remix plugins rely on a `ctx` object to be initialized by
|
|
25
|
+
// the main Remix plugin, and may not function correctly without it. To address this, we
|
|
26
|
+
// filter out all Remix-related plugins.
|
|
27
|
+
!plugin.name.startsWith('remix');
|
|
16
28
|
function vanillaExtractPlugin({
|
|
17
29
|
identifiers,
|
|
18
30
|
unstable_mode: mode = 'emitCss'
|
|
@@ -83,34 +95,34 @@ function vanillaExtractPlugin({
|
|
|
83
95
|
async buildStart() {
|
|
84
96
|
// Ensure we re-use the compiler instance between builds, e.g. in watch mode
|
|
85
97
|
if (mode !== 'transform' && !compiler) {
|
|
86
|
-
var
|
|
98
|
+
var _configForViteCompile;
|
|
87
99
|
const {
|
|
88
100
|
loadConfigFromFile
|
|
89
101
|
} = await vitePromise;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
let configForViteCompiler;
|
|
103
|
+
|
|
104
|
+
// The user has a vite config file
|
|
105
|
+
if (config.configFile) {
|
|
106
|
+
const configFile = await loadConfigFromFile({
|
|
107
|
+
command: config.command,
|
|
108
|
+
mode: config.mode,
|
|
109
|
+
isSsrBuild: configEnv.isSsrBuild
|
|
110
|
+
}, config.configFile);
|
|
111
|
+
configForViteCompiler = configFile === null || configFile === void 0 ? void 0 : configFile.config;
|
|
112
|
+
}
|
|
113
|
+
// The user is using a vite-based framework that has a custom config file
|
|
114
|
+
else {
|
|
115
|
+
configForViteCompiler = config.inlineConfig;
|
|
116
|
+
}
|
|
117
|
+
const viteConfig = {
|
|
118
|
+
...configForViteCompiler,
|
|
119
|
+
plugins: (_configForViteCompile = configForViteCompiler) === null || _configForViteCompile === void 0 || (_configForViteCompile = _configForViteCompile.plugins) === null || _configForViteCompile === void 0 ? void 0 : _configForViteCompile.flat().filter(removeIncompatiblePlugins)
|
|
120
|
+
};
|
|
95
121
|
compiler = integration.createCompiler({
|
|
96
122
|
root: config.root,
|
|
97
123
|
identifiers: getIdentOption(),
|
|
98
124
|
cssImportSpecifier: fileIdToVirtualId,
|
|
99
|
-
viteConfig
|
|
100
|
-
...(configFile === null || configFile === void 0 ? void 0 : configFile.config),
|
|
101
|
-
plugins: configFile === null || configFile === void 0 || (_configFile$config$pl = configFile.config.plugins) === null || _configFile$config$pl === void 0 ? void 0 : _configFile$config$pl.flat().filter(plugin => typeof plugin === 'object' && plugin !== null && 'name' in plugin &&
|
|
102
|
-
// Prevent an infinite loop where the compiler creates a new instance of the plugin,
|
|
103
|
-
// which creates a new compiler, which creates a new instance of the plugin, etc.
|
|
104
|
-
plugin.name !== 'vanilla-extract' &&
|
|
105
|
-
// Skip Remix because it throws an error if it's not loaded with a config file.
|
|
106
|
-
// If it _is_ loaded with a config file, it will create an infinite loop because it
|
|
107
|
-
// also has a child compiler which uses the same mechanism to load the config file.
|
|
108
|
-
// https://github.com/remix-run/remix/pull/7990#issuecomment-1809356626
|
|
109
|
-
// Additionally, some internal Remix plugins rely on a `ctx` object to be initialized by
|
|
110
|
-
// the main Remix plugin, and may not function correctly without it. To address this, we
|
|
111
|
-
// filter out all Remix-related plugins.
|
|
112
|
-
!plugin.name.startsWith('remix'))
|
|
113
|
-
}
|
|
125
|
+
viteConfig
|
|
114
126
|
});
|
|
115
127
|
}
|
|
116
128
|
},
|
|
@@ -13,6 +13,18 @@ const virtualExtCss = '.vanilla.css';
|
|
|
13
13
|
const isVirtualId = id => id.endsWith(virtualExtCss);
|
|
14
14
|
const fileIdToVirtualId = id => `${id}${virtualExtCss}`;
|
|
15
15
|
const virtualIdToFileId = virtualId => virtualId.slice(0, -virtualExtCss.length);
|
|
16
|
+
const removeIncompatiblePlugins = plugin => typeof plugin === 'object' && plugin !== null && 'name' in plugin &&
|
|
17
|
+
// Prevent an infinite loop where the compiler creates a new instance of the plugin,
|
|
18
|
+
// which creates a new compiler, which creates a new instance of the plugin, etc.
|
|
19
|
+
plugin.name !== 'vanilla-extract' &&
|
|
20
|
+
// Skip Remix because it throws an error if it's not loaded with a config file.
|
|
21
|
+
// If it _is_ loaded with a config file, it will create an infinite loop because it
|
|
22
|
+
// also has a child compiler which uses the same mechanism to load the config file.
|
|
23
|
+
// https://github.com/remix-run/remix/pull/7990#issuecomment-1809356626
|
|
24
|
+
// Additionally, some internal Remix plugins rely on a `ctx` object to be initialized by
|
|
25
|
+
// the main Remix plugin, and may not function correctly without it. To address this, we
|
|
26
|
+
// filter out all Remix-related plugins.
|
|
27
|
+
!plugin.name.startsWith('remix');
|
|
16
28
|
function vanillaExtractPlugin({
|
|
17
29
|
identifiers,
|
|
18
30
|
unstable_mode: mode = 'emitCss'
|
|
@@ -83,34 +95,34 @@ function vanillaExtractPlugin({
|
|
|
83
95
|
async buildStart() {
|
|
84
96
|
// Ensure we re-use the compiler instance between builds, e.g. in watch mode
|
|
85
97
|
if (mode !== 'transform' && !compiler) {
|
|
86
|
-
var
|
|
98
|
+
var _configForViteCompile;
|
|
87
99
|
const {
|
|
88
100
|
loadConfigFromFile
|
|
89
101
|
} = await vitePromise;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
let configForViteCompiler;
|
|
103
|
+
|
|
104
|
+
// The user has a vite config file
|
|
105
|
+
if (config.configFile) {
|
|
106
|
+
const configFile = await loadConfigFromFile({
|
|
107
|
+
command: config.command,
|
|
108
|
+
mode: config.mode,
|
|
109
|
+
isSsrBuild: configEnv.isSsrBuild
|
|
110
|
+
}, config.configFile);
|
|
111
|
+
configForViteCompiler = configFile === null || configFile === void 0 ? void 0 : configFile.config;
|
|
112
|
+
}
|
|
113
|
+
// The user is using a vite-based framework that has a custom config file
|
|
114
|
+
else {
|
|
115
|
+
configForViteCompiler = config.inlineConfig;
|
|
116
|
+
}
|
|
117
|
+
const viteConfig = {
|
|
118
|
+
...configForViteCompiler,
|
|
119
|
+
plugins: (_configForViteCompile = configForViteCompiler) === null || _configForViteCompile === void 0 || (_configForViteCompile = _configForViteCompile.plugins) === null || _configForViteCompile === void 0 ? void 0 : _configForViteCompile.flat().filter(removeIncompatiblePlugins)
|
|
120
|
+
};
|
|
95
121
|
compiler = integration.createCompiler({
|
|
96
122
|
root: config.root,
|
|
97
123
|
identifiers: getIdentOption(),
|
|
98
124
|
cssImportSpecifier: fileIdToVirtualId,
|
|
99
|
-
viteConfig
|
|
100
|
-
...(configFile === null || configFile === void 0 ? void 0 : configFile.config),
|
|
101
|
-
plugins: configFile === null || configFile === void 0 || (_configFile$config$pl = configFile.config.plugins) === null || _configFile$config$pl === void 0 ? void 0 : _configFile$config$pl.flat().filter(plugin => typeof plugin === 'object' && plugin !== null && 'name' in plugin &&
|
|
102
|
-
// Prevent an infinite loop where the compiler creates a new instance of the plugin,
|
|
103
|
-
// which creates a new compiler, which creates a new instance of the plugin, etc.
|
|
104
|
-
plugin.name !== 'vanilla-extract' &&
|
|
105
|
-
// Skip Remix because it throws an error if it's not loaded with a config file.
|
|
106
|
-
// If it _is_ loaded with a config file, it will create an infinite loop because it
|
|
107
|
-
// also has a child compiler which uses the same mechanism to load the config file.
|
|
108
|
-
// https://github.com/remix-run/remix/pull/7990#issuecomment-1809356626
|
|
109
|
-
// Additionally, some internal Remix plugins rely on a `ctx` object to be initialized by
|
|
110
|
-
// the main Remix plugin, and may not function correctly without it. To address this, we
|
|
111
|
-
// filter out all Remix-related plugins.
|
|
112
|
-
!plugin.name.startsWith('remix'))
|
|
113
|
-
}
|
|
125
|
+
viteConfig
|
|
114
126
|
});
|
|
115
127
|
}
|
|
116
128
|
},
|
|
@@ -5,6 +5,18 @@ const virtualExtCss = '.vanilla.css';
|
|
|
5
5
|
const isVirtualId = id => id.endsWith(virtualExtCss);
|
|
6
6
|
const fileIdToVirtualId = id => `${id}${virtualExtCss}`;
|
|
7
7
|
const virtualIdToFileId = virtualId => virtualId.slice(0, -virtualExtCss.length);
|
|
8
|
+
const removeIncompatiblePlugins = plugin => typeof plugin === 'object' && plugin !== null && 'name' in plugin &&
|
|
9
|
+
// Prevent an infinite loop where the compiler creates a new instance of the plugin,
|
|
10
|
+
// which creates a new compiler, which creates a new instance of the plugin, etc.
|
|
11
|
+
plugin.name !== 'vanilla-extract' &&
|
|
12
|
+
// Skip Remix because it throws an error if it's not loaded with a config file.
|
|
13
|
+
// If it _is_ loaded with a config file, it will create an infinite loop because it
|
|
14
|
+
// also has a child compiler which uses the same mechanism to load the config file.
|
|
15
|
+
// https://github.com/remix-run/remix/pull/7990#issuecomment-1809356626
|
|
16
|
+
// Additionally, some internal Remix plugins rely on a `ctx` object to be initialized by
|
|
17
|
+
// the main Remix plugin, and may not function correctly without it. To address this, we
|
|
18
|
+
// filter out all Remix-related plugins.
|
|
19
|
+
!plugin.name.startsWith('remix');
|
|
8
20
|
function vanillaExtractPlugin({
|
|
9
21
|
identifiers,
|
|
10
22
|
unstable_mode: mode = 'emitCss'
|
|
@@ -75,34 +87,34 @@ function vanillaExtractPlugin({
|
|
|
75
87
|
async buildStart() {
|
|
76
88
|
// Ensure we re-use the compiler instance between builds, e.g. in watch mode
|
|
77
89
|
if (mode !== 'transform' && !compiler) {
|
|
78
|
-
var
|
|
90
|
+
var _configForViteCompile;
|
|
79
91
|
const {
|
|
80
92
|
loadConfigFromFile
|
|
81
93
|
} = await vitePromise;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
let configForViteCompiler;
|
|
95
|
+
|
|
96
|
+
// The user has a vite config file
|
|
97
|
+
if (config.configFile) {
|
|
98
|
+
const configFile = await loadConfigFromFile({
|
|
99
|
+
command: config.command,
|
|
100
|
+
mode: config.mode,
|
|
101
|
+
isSsrBuild: configEnv.isSsrBuild
|
|
102
|
+
}, config.configFile);
|
|
103
|
+
configForViteCompiler = configFile === null || configFile === void 0 ? void 0 : configFile.config;
|
|
104
|
+
}
|
|
105
|
+
// The user is using a vite-based framework that has a custom config file
|
|
106
|
+
else {
|
|
107
|
+
configForViteCompiler = config.inlineConfig;
|
|
108
|
+
}
|
|
109
|
+
const viteConfig = {
|
|
110
|
+
...configForViteCompiler,
|
|
111
|
+
plugins: (_configForViteCompile = configForViteCompiler) === null || _configForViteCompile === void 0 || (_configForViteCompile = _configForViteCompile.plugins) === null || _configForViteCompile === void 0 ? void 0 : _configForViteCompile.flat().filter(removeIncompatiblePlugins)
|
|
112
|
+
};
|
|
87
113
|
compiler = createCompiler({
|
|
88
114
|
root: config.root,
|
|
89
115
|
identifiers: getIdentOption(),
|
|
90
116
|
cssImportSpecifier: fileIdToVirtualId,
|
|
91
|
-
viteConfig
|
|
92
|
-
...(configFile === null || configFile === void 0 ? void 0 : configFile.config),
|
|
93
|
-
plugins: configFile === null || configFile === void 0 || (_configFile$config$pl = configFile.config.plugins) === null || _configFile$config$pl === void 0 ? void 0 : _configFile$config$pl.flat().filter(plugin => typeof plugin === 'object' && plugin !== null && 'name' in plugin &&
|
|
94
|
-
// Prevent an infinite loop where the compiler creates a new instance of the plugin,
|
|
95
|
-
// which creates a new compiler, which creates a new instance of the plugin, etc.
|
|
96
|
-
plugin.name !== 'vanilla-extract' &&
|
|
97
|
-
// Skip Remix because it throws an error if it's not loaded with a config file.
|
|
98
|
-
// If it _is_ loaded with a config file, it will create an infinite loop because it
|
|
99
|
-
// also has a child compiler which uses the same mechanism to load the config file.
|
|
100
|
-
// https://github.com/remix-run/remix/pull/7990#issuecomment-1809356626
|
|
101
|
-
// Additionally, some internal Remix plugins rely on a `ctx` object to be initialized by
|
|
102
|
-
// the main Remix plugin, and may not function correctly without it. To address this, we
|
|
103
|
-
// filter out all Remix-related plugins.
|
|
104
|
-
!plugin.name.startsWith('remix'))
|
|
105
|
-
}
|
|
117
|
+
viteConfig
|
|
106
118
|
});
|
|
107
119
|
}
|
|
108
120
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanilla-extract/vite-plugin",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.12",
|
|
4
4
|
"description": "Zero-runtime Stylesheets-in-TypeScript",
|
|
5
5
|
"main": "dist/vanilla-extract-vite-plugin.cjs.js",
|
|
6
6
|
"module": "dist/vanilla-extract-vite-plugin.esm.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"author": "SEEK",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@vanilla-extract/integration": "^7.1.
|
|
19
|
+
"@vanilla-extract/integration": "^7.1.7"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"vite": "^5.0.11"
|