Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New CSS pipeline based on @parcel/css #7538

Merged
merged 15 commits into from Jan 11, 2022
14 changes: 12 additions & 2 deletions packages/core/core/src/Environment.js
@@ -1,8 +1,14 @@
// @flow
import type {EnvironmentOptions, FilePath} from '@parcel/types';
import type {
EnvironmentOptions,
Environment as IEnvironment,
FilePath,
} from '@parcel/types';
import type {Environment, InternalSourceLocation} from './types';
import {hashString} from '@parcel/hash';
import {toInternalSourceLocation} from './utils';
import PublicEnvironment from './public/Environment';
import {environmentToInternalEnvironment} from './public/Environment';

const DEFAULT_ENGINES = {
browsers: ['> 0.25%'],
Expand Down Expand Up @@ -107,13 +113,17 @@ export function createEnvironment({
export function mergeEnvironments(
projectRoot: FilePath,
a: Environment,
b: ?EnvironmentOptions,
b: ?(EnvironmentOptions | IEnvironment),
): Environment {
// If merging the same object, avoid copying.
if (a === b || !b) {
return a;
}

if (b instanceof PublicEnvironment) {
return environmentToInternalEnvironment(b);
}

// $FlowFixMe - ignore the `id` that is already on a
return createEnvironment({
...a,
Expand Down
16 changes: 8 additions & 8 deletions packages/core/integration-tests/test/cache.js
Expand Up @@ -3971,7 +3971,7 @@ describe('cache', function () {
let pluginContents = await overlayFS.readFile(plugin, 'utf8');
await overlayFS.writeFile(
plugin,
pluginContents.replace('green', 'blue'),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parcel/css prints this as #00f, so had to change the color to something that prints the same in both transformers

pluginContents.replace('green', 'red'),
);
},
},
Expand All @@ -3982,7 +3982,7 @@ describe('cache', function () {
b.bundleGraph.getBundles()[0].filePath,
'utf8',
);
assert(output.includes('background: blue'));
assert(output.includes('background: red'));
});

it('should invalidate when a JS postcss config changes', async function () {
Expand All @@ -4009,7 +4009,7 @@ describe('cache', function () {
let configContents = await inputFS.readFile(config, 'utf8');
await inputFS.writeFile(
config,
configContents.replace('red', 'blue'),
configContents.replace('red', 'green'),
);
await sleep(100);
},
Expand All @@ -4021,7 +4021,7 @@ describe('cache', function () {
b.bundleGraph.getBundles()[0].filePath,
'utf8',
);
assert(output.includes('background-color: blue'));
assert(output.includes('background-color: green'));
});

it('should invalidate when a JSON postcss config changes', async function () {
Expand All @@ -4041,7 +4041,7 @@ describe('cache', function () {
);
await overlayFS.writeFile(
path.join(inputDir, '.postcssrc'),
configContents.replace('green', 'blue'),
configContents.replace('green', 'red'),
);
},
},
Expand All @@ -4052,7 +4052,7 @@ describe('cache', function () {
b.bundleGraph.getBundles()[0].filePath,
'utf8',
);
assert(output.includes('background-color: blue'));
assert(output.includes('background-color: red'));
});

it('should invalidate when a closer postcss config is added', async function () {
Expand All @@ -4072,7 +4072,7 @@ describe('cache', function () {
);
await overlayFS.writeFile(
path.join(inputDir, 'nested', '.postcssrc'),
configContents.replace('green', 'blue'),
configContents.replace('green', 'red'),
);
},
},
Expand All @@ -4083,7 +4083,7 @@ describe('cache', function () {
b.bundleGraph.getBundles()[0].filePath,
'utf8',
);
assert(output.includes('background-color: blue'));
assert(output.includes('background-color: red'));
});
});

Expand Down