Skip to content

Commit

Permalink
New CSS pipeline based on @parcel/css (#7538)
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Jan 11, 2022
1 parent f53ffe7 commit dbe2f10
Show file tree
Hide file tree
Showing 36 changed files with 1,618 additions and 1,065 deletions.
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'),
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

0 comments on commit dbe2f10

Please sign in to comment.