Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vanilla-extract/integration

Package Overview
Dependencies
Maintainers
4
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vanilla-extract/integration - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

dist/declarations/src/addFileScope.d.ts

13

CHANGELOG.md
# @vanilla-extract/integration
## 1.3.0
### Minor Changes
- [#341](https://github.com/seek-oss/vanilla-extract/pull/341) [`0b743e7`](https://github.com/seek-oss/vanilla-extract/commit/0b743e744447616f8daf0c6b88beff8ffef8d41b) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add `addFileScope` API
### Patch Changes
- [#343](https://github.com/seek-oss/vanilla-extract/pull/343) [`50bae14`](https://github.com/seek-oss/vanilla-extract/commit/50bae14bf38c8a971ad1727cb8e827c86da06772) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Cleanup adapter after processing styles
- Updated dependencies [[`50bae14`](https://github.com/seek-oss/vanilla-extract/commit/50bae14bf38c8a971ad1727cb8e827c86da06772)]:
- @vanilla-extract/css@1.4.1
## 1.2.0

@@ -4,0 +17,0 @@

2

dist/declarations/src/index.d.ts

@@ -6,3 +6,5 @@ export { processVanillaFile } from './processVanillaFile';

export { hash } from './hash';
export { addFileScope } from './addFileScope';
export * from './filters';
export type { IdentifierOption } from './processVanillaFile';
export type { PackageInfo } from './packageInfo';

3

dist/declarations/src/packageInfo.d.ts

@@ -1,2 +0,2 @@

interface PackageInfo {
export interface PackageInfo {
name: string;

@@ -7,2 +7,1 @@ path: string;

export declare function getPackageInfo(cwd?: string | null): PackageInfo;
export {};

@@ -5,3 +5,2 @@ 'use strict';

var adapter = require('@vanilla-extract/css/adapter');
var transformCss = require('@vanilla-extract/css/transformCss');

@@ -80,5 +79,3 @@ var evalCode = require('eval');

};
adapter.setAdapter(cssAdapter);
const currentNodeEnv = process.env.NODE_ENV;
const sourceWithBoundLoaderInstance = `require('@vanilla-extract/css/adapter').setAdapter(__adapter__);${source};`; // Vite sometimes modifies NODE_ENV which causes different versions (e.g. dev/prod) of vanilla packages to be loaded
const currentNodeEnv = process.env.NODE_ENV; // Vite sometimes modifies NODE_ENV which causes different versions (e.g. dev/prod) of vanilla packages to be loaded
// This can cause CSS to be bound to the wrong instance, resulting in no CSS output

@@ -88,6 +85,10 @@ // To get around this we set the NODE_ENV back to the original value ONLY during eval

process.env.NODE_ENV = originalNodeEnv;
const evalResult = evalCode__default['default'](sourceWithBoundLoaderInstance, filePath, {
const adapterBoundSource = `
require('@vanilla-extract/css/adapter').setAdapter(__adapter__);
${source}
`;
const evalResult = evalCode__default['default'](adapterBoundSource, filePath, {
console,
__adapter__: cssAdapter,
process
process,
__adapter__: cssAdapter
}, true);

@@ -112,4 +113,15 @@ process.env.NODE_ENV = currentNodeEnv;

cssImports.push(virtualCssFilePath);
}
} // We run this code inside eval as jest seems to create a difrerent instance of the adapter file
// for requires executed within the eval and all CSS can be lost.
evalCode__default['default'](`const { removeAdapter } = require('@vanilla-extract/css/adapter');
// Backwards compat with older versions of @vanilla-extract/css
if (removeAdapter) {
removeAdapter();
}
`, filePath, {
console,
process
}, true);
const unusedCompositions = composedClassLists.filter(({

@@ -236,2 +248,29 @@ identifier

function addFileScope({
source,
filePath,
packageInfo
}) {
if (source.indexOf('@vanilla-extract/css/fileScope') > -1) {
return {
source,
updated: false
};
} // Encode windows file paths as posix
const normalizedPath = path.posix.join(...path.relative(packageInfo.dirname, filePath).split(path.sep));
const packageName = packageInfo.name ? `"${packageInfo.name}"` : 'undefined';
const contents = `
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
setFileScope("${normalizedPath}", ${packageName});
${source}
endFileScope();
`;
return {
source: contents,
updated: true
};
}
const vanillaExtractFilescopePlugin = () => ({

@@ -248,15 +287,14 @@ name: 'vanilla-extract-filescope',

const originalSource = await fs.promises.readFile(path$1, 'utf-8');
const {
source,
updated
} = addFileScope({
source: originalSource,
filePath: path$1,
packageInfo
});
if (originalSource.indexOf('@vanilla-extract/css/fileScope') === -1) {
// Encode windows file paths as posix
const filePath = path.posix.join(...path.relative(packageInfo.dirname, path$1).split(path.sep));
const contents = `
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
setFileScope("${filePath}", ${packageInfo.name ? `"${packageInfo.name}"` : 'undefined'});
${originalSource}
endFileScope()
`;
if (updated) {
return {
contents,
contents: source,
loader: path$1.match(/\.(ts|tsx)$/i) ? 'ts' : undefined,

@@ -300,2 +338,3 @@ resolveDir: path.dirname(path$1)

exports.addFileScope = addFileScope;
exports.compile = compile;

@@ -302,0 +341,0 @@ exports.cssFileFilter = cssFileFilter;

@@ -5,3 +5,2 @@ 'use strict';

var adapter = require('@vanilla-extract/css/adapter');
var transformCss = require('@vanilla-extract/css/transformCss');

@@ -80,5 +79,3 @@ var evalCode = require('eval');

};
adapter.setAdapter(cssAdapter);
const currentNodeEnv = "production";
const sourceWithBoundLoaderInstance = `require('@vanilla-extract/css/adapter').setAdapter(__adapter__);${source};`; // Vite sometimes modifies NODE_ENV which causes different versions (e.g. dev/prod) of vanilla packages to be loaded
const currentNodeEnv = "production"; // Vite sometimes modifies NODE_ENV which causes different versions (e.g. dev/prod) of vanilla packages to be loaded
// This can cause CSS to be bound to the wrong instance, resulting in no CSS output

@@ -88,6 +85,10 @@ // To get around this we set the NODE_ENV back to the original value ONLY during eval

process.env.NODE_ENV = originalNodeEnv;
const evalResult = evalCode__default['default'](sourceWithBoundLoaderInstance, filePath, {
const adapterBoundSource = `
require('@vanilla-extract/css/adapter').setAdapter(__adapter__);
${source}
`;
const evalResult = evalCode__default['default'](adapterBoundSource, filePath, {
console,
__adapter__: cssAdapter,
process
process,
__adapter__: cssAdapter
}, true);

@@ -112,4 +113,15 @@ process.env.NODE_ENV = currentNodeEnv;

cssImports.push(virtualCssFilePath);
}
} // We run this code inside eval as jest seems to create a difrerent instance of the adapter file
// for requires executed within the eval and all CSS can be lost.
evalCode__default['default'](`const { removeAdapter } = require('@vanilla-extract/css/adapter');
// Backwards compat with older versions of @vanilla-extract/css
if (removeAdapter) {
removeAdapter();
}
`, filePath, {
console,
process
}, true);
const unusedCompositions = composedClassLists.filter(({

@@ -236,2 +248,29 @@ identifier

function addFileScope({
source,
filePath,
packageInfo
}) {
if (source.indexOf('@vanilla-extract/css/fileScope') > -1) {
return {
source,
updated: false
};
} // Encode windows file paths as posix
const normalizedPath = path.posix.join(...path.relative(packageInfo.dirname, filePath).split(path.sep));
const packageName = packageInfo.name ? `"${packageInfo.name}"` : 'undefined';
const contents = `
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
setFileScope("${normalizedPath}", ${packageName});
${source}
endFileScope();
`;
return {
source: contents,
updated: true
};
}
const vanillaExtractFilescopePlugin = () => ({

@@ -248,15 +287,14 @@ name: 'vanilla-extract-filescope',

const originalSource = await fs.promises.readFile(path$1, 'utf-8');
const {
source,
updated
} = addFileScope({
source: originalSource,
filePath: path$1,
packageInfo
});
if (originalSource.indexOf('@vanilla-extract/css/fileScope') === -1) {
// Encode windows file paths as posix
const filePath = path.posix.join(...path.relative(packageInfo.dirname, path$1).split(path.sep));
const contents = `
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
setFileScope("${filePath}", ${packageInfo.name ? `"${packageInfo.name}"` : 'undefined'});
${originalSource}
endFileScope()
`;
if (updated) {
return {
contents,
contents: source,
loader: path$1.match(/\.(ts|tsx)$/i) ? 'ts' : undefined,

@@ -300,2 +338,3 @@ resolveDir: path.dirname(path$1)

exports.addFileScope = addFileScope;
exports.compile = compile;

@@ -302,0 +341,0 @@ exports.cssFileFilter = cssFileFilter;

{
"name": "@vanilla-extract/integration",
"version": "1.2.0",
"version": "1.3.0",
"description": "Zero-runtime Stylesheets-in-TypeScript",
"main": "dist/vanilla-extract-integration.cjs.js",
"module": "dist/vanilla-extract-integration.esm.js",
"files": [

@@ -18,3 +17,3 @@ "/dist"

"dependencies": {
"@vanilla-extract/css": "^1.3.0",
"@vanilla-extract/css": "^1.4.1",
"chalk": "^4.1.1",

@@ -21,0 +20,0 @@ "dedent": "^0.7.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc