Skip to content

Commit

Permalink
Merge branch 'v2' into parallel-request-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
gorakong committed Apr 5, 2022
2 parents e4c6323 + a8a4f51 commit 02afc8d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
56 changes: 28 additions & 28 deletions packages/core/integration-tests/test/css-modules.js
Expand Up @@ -31,9 +31,9 @@ describe('css modules', () => {
assert.equal(typeof output, 'function');

let value = output();
assert(/foo_[0-9a-zA-Z]/.test(value));
assert(/[_0-9a-zA-Z]+_foo/.test(value));

let cssClass = value.match(/(foo_[0-9a-zA-Z])/)[1];
let cssClass = value.match(/([_0-9a-zA-Z]+_foo)/)[1];

let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8');
assert(css.includes(`.${cssClass}`));
Expand All @@ -60,7 +60,7 @@ describe('css modules', () => {
]);

let output = await run(b);
assert(/b-2_[0-9a-zA-Z]/.test(output));
assert(/[_0-9a-zA-Z]+_b-2/.test(output));

let css = await outputFS.readFile(
b.getBundles().find(b => b.type === 'css').filePath,
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('css modules', () => {
assert(!js.includes('unused'));

let output = await run(b);
assert(/b-2_[0-9a-zA-Z]/.test(output));
assert(/[_0-9a-zA-Z]+_b-2/.test(output));

let css = await outputFS.readFile(
b.getBundles().find(b => b.type === 'css').filePath,
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('css modules', () => {
]);

let {output} = await run(b, null, {require: false});
assert(/b-2_[0-9a-zA-Z]/.test(output));
assert(/[_0-9a-zA-Z]+_b-2/.test(output));

let css = await outputFS.readFile(
b.getBundles().find(b => b.type === 'css').filePath,
Expand Down Expand Up @@ -185,8 +185,8 @@ describe('css modules', () => {
assert(js.includes('unused'));

let output = await run(b);
assert(/b-2_[0-9a-zA-Z]/.test(output['b-2']));
assert(/unused_[0-9a-zA-Z]/.test(output['unused']));
assert(/[_0-9a-zA-Z]+_b-2/.test(output['b-2']));
assert(/[_0-9a-zA-Z]+_unused/.test(output['unused']));

let css = await outputFS.readFile(
b.getBundles().find(b => b.type === 'css').filePath,
Expand Down Expand Up @@ -233,15 +233,15 @@ describe('css modules', () => {
let value = output();
const composes1Classes = value.composes1.split(' ');
const composes2Classes = value.composes2.split(' ');
assert(composes1Classes[0].startsWith('composes1_'));
assert(composes1Classes[1].startsWith('test_'));
assert(composes2Classes[0].startsWith('composes2_'));
assert(composes2Classes[1].startsWith('test_'));
assert(composes1Classes[0].endsWith('_composes1'));
assert(composes1Classes[1].endsWith('_test'));
assert(composes2Classes[0].endsWith('_composes2'));
assert(composes2Classes[1].endsWith('_test'));

let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8');
let cssClass1 = value.composes1.match(/(composes1_[0-9a-zA-Z]+)/)[1];
let cssClass1 = value.composes1.match(/([_0-9a-zA-Z]+_composes1)/)[1];
assert(css.includes(`.${cssClass1}`));
let cssClass2 = value.composes2.match(/(composes2_[0-9a-zA-Z]+)/)[1];
let cssClass2 = value.composes2.match(/([_0-9a-zA-Z]+_composes2)/)[1];
assert(css.includes(`.${cssClass2}`));
});

Expand Down Expand Up @@ -280,8 +280,8 @@ describe('css modules', () => {

let value = output();
const composes3Classes = value.composes3.split(' ');
assert(composes3Classes[0].startsWith('composes3_'));
assert(composes3Classes[1].startsWith('test_'));
assert(composes3Classes[0].endsWith('_composes3'));
assert(composes3Classes[1].endsWith('_test'));

let css = await outputFS.readFile(path.join(distDir, 'index2.css'), 'utf8');
assert(css.includes('height: 200px;'));
Expand All @@ -308,8 +308,8 @@ describe('css modules', () => {

let value = output();
const composes4Classes = value.composes4.split(' ');
assert(composes4Classes[0].startsWith('composes4_'));
assert(composes4Classes[1].startsWith('test_'));
assert(composes4Classes[0].endsWith('_composes4'));
assert(composes4Classes[1].endsWith('_test'));

let css = await outputFS.readFile(path.join(distDir, 'index3.css'), 'utf8');
assert(css.includes('height: 100px;'));
Expand Down Expand Up @@ -345,14 +345,14 @@ describe('css modules', () => {

let value = output();
const composes5Classes = value.composes5.split(' ');
assert(composes5Classes[0].startsWith('composes5_'));
assert(composes5Classes[1].startsWith('intermediate_'));
assert(composes5Classes[2].startsWith('test_'));
assert(composes5Classes[0].endsWith('_composes5'));
assert(composes5Classes[1].endsWith('_intermediate'));
assert(composes5Classes[2].endsWith('_test'));

let css = await outputFS.readFile(path.join(distDir, 'index4.css'), 'utf8');
assert(css.includes('height: 100px;'));
assert(css.includes('height: 300px;'));
assert(css.indexOf('.test_') < css.indexOf('.intermediate_'));
assert(css.indexOf('_test') < css.indexOf('_intermediate'));
});

it('should support composes imports for multiple selectors', async () => {
Expand All @@ -376,9 +376,9 @@ describe('css modules', () => {

let value = output();
const composes6Classes = value.composes6.split(' ');
assert(composes6Classes[0].startsWith('composes6_'));
assert(composes6Classes[1].startsWith('test_'));
assert(composes6Classes[2].startsWith('test-2_'));
assert(composes6Classes[0].endsWith('_composes6'));
assert(composes6Classes[1].endsWith('_test'));
assert(composes6Classes[2].endsWith('_test-2'));
});

it('should throw an error when importing a missing class', async function () {
Expand Down Expand Up @@ -490,8 +490,8 @@ describe('css modules', () => {
]);

let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8');
assert(css.includes('@keyframes test'));
assert(!css.includes('@keyframes unused'));
assert(/@keyframes _[_0-9a-zA-Z]+_test/.test(css));
assert(!css.includes('unused'));
});

it('should not double optimize css modules processed with postcss', async function () {
Expand Down Expand Up @@ -564,7 +564,7 @@ describe('css modules', () => {
},
);

assert.deepEqual(res, [['page1', 'a_1ZEqVW']]);
assert.deepEqual(res, [['page1', '_1ZEqVW_a']]);

res = [];
await runBundle(
Expand All @@ -575,7 +575,7 @@ describe('css modules', () => {
},
);

assert.deepEqual(res, [['page2', 'foo_4fY2uG foo_1ZEqVW foo_j1UkRG']]);
assert.deepEqual(res, [['page2', '_4fY2uG_foo _1ZEqVW_foo j1UkRG_foo']]);

assertBundles(b, [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/less.js
Expand Up @@ -202,10 +202,10 @@ describe('less', function () {

let output = await run(b);
assert.equal(typeof output, 'function');
assert(output().startsWith('index_'));
assert(output().endsWith('_index'));

let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8');
assert(css.includes('.index_'));
assert(/\.[_0-9a-zA-Z]+_index/.test(css));
});

it('should throw an exception when using webpack syntax', async function () {
Expand Down
14 changes: 7 additions & 7 deletions packages/core/integration-tests/test/monorepos.js
Expand Up @@ -214,7 +214,7 @@ describe('monorepos', function () {
path.join(distDir, '/pkg-b/src/index.css'),
'utf8',
);
assert(contents.includes('.foo_'));
assert(/\.[_0-9a-zA-Z]+_foo/.test(contents));
} finally {
inputFS.chdir(oldcwd);
}
Expand Down Expand Up @@ -290,7 +290,7 @@ describe('monorepos', function () {
),
'utf8',
);
assert(contents.includes('.foo_'));
assert(/\.[_0-9a-zA-Z]+_foo/.test(contents));

contents = await outputFS.readFile(
path.join(
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('monorepos', function () {
path.join(distDir, '/pkg-b/src/index.css'),
'utf8',
);
assert(contents.includes('.foo_'));
assert(/\.[_0-9a-zA-Z]+_foo/.test(contents));
} finally {
inputFS.chdir(oldcwd);
}
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('monorepos', function () {
path.join(distDir, '/pkg-b/src/index.css'),
'utf8',
);
assert(contents.includes('.foo_'));
assert(/\.[_0-9a-zA-Z]+_foo/.test(contents));
} finally {
inputFS.chdir(oldcwd);
}
Expand Down Expand Up @@ -566,7 +566,7 @@ describe('monorepos', function () {
),
'utf8',
);
assert(contents.includes('.foo_'));
assert(/\.[_0-9a-zA-Z]+_foo/.test(contents));

contents = await outputFS.readFile(
path.join(
Expand Down Expand Up @@ -828,7 +828,7 @@ describe('monorepos', function () {
),
'utf8',
);
assert(contents.includes('.foo_'));
assert(/\.[_0-9a-zA-Z]+_foo/.test(contents));

contents = await outputFS.readFile(
path.join(
Expand All @@ -846,7 +846,7 @@ describe('monorepos', function () {
),
'utf8',
);
assert(contents.includes('.foo_'));
assert(/\.[_0-9a-zA-Z]+_foo/.test(contents));

contents = await outputFS.readFile(
path.join(
Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/stylus.js
Expand Up @@ -140,10 +140,10 @@ describe('stylus', function () {

let output = await run(b);
assert.equal(typeof output, 'function');
assert(output().startsWith('index_'));
assert(output().endsWith('_index'));

let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8');
assert(css.includes('.index_'));
assert(/\.[_0-9a-zA-Z]+_index/.test(css));
});

it('should support requiring stylus files with glob dependencies', async function () {
Expand Down

0 comments on commit 02afc8d

Please sign in to comment.