Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/v2' into wbinnssmith/merge-v2-…
Browse files Browse the repository at this point in the history
…2022-04-22

* upstream/v2:
  Register swc error handler (#8032)
  Correctly emit warnings for unnecessary PostCSS plugins in package.json (#8024)
  Pass targets for swc/helpers to Rust and only filter them for preset env (#8020)
  • Loading branch information
lettertwo committed May 2, 2022
2 parents b7d7cfa + c576758 commit 56c5965
Show file tree
Hide file tree
Showing 25 changed files with 499 additions and 294 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {bar} from "./other.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const bar = "bar";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as helpers from "@swc/helpers";
import * as bar from "./bar";
import * as foo from "foo";

export default [helpers, bar, foo];

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"browserslist": "ie 11"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.foo {
color: #fff;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const map = require('./foo.css');

module.exports = {
foo: map.foo,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: blue;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require('./index.css');
var foo = require('./foo');

module.exports = function () {
return foo.foo;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"postcss": {
"modules": true,
"plugins": {
"autoprefixer": {
"grid": true
}
}
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Boom = () => {
const littleBoom = ['hello', 'world']
return <div>{...littleBoom.map(el => el)}</div>
}
class X {
#x(){}
#x(){}
}
console.log(Boom, X);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"react": "^18.1.0"
},
"browserslist": "ie 11"
}
Empty file.
8 changes: 8 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5109,6 +5109,14 @@ describe('javascript', function () {
assert.deepEqual(res, {a: 4});
});

it('should not use arrow functions for reexport declarations unless supported', async function () {
let b = await bundle(
path.join(__dirname, 'integration/js-export-arrow-support/index.js'),
);
let content = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
assert(!content.includes('=>'));
});

it('should support import namespace declarations of other ES modules', async function () {
let b = await bundle(
path.join(__dirname, 'integration/js-import-namespace/a.js'),
Expand Down
31 changes: 31 additions & 0 deletions packages/core/integration-tests/test/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ describe('postcss', () => {
assert(css.includes(`.${cssClass}`));
});

it('should build successfully with only postcss-modules config in package.json', async () => {
let b = await bundle(
path.join(
__dirname,
'/integration/postcss-modules-config-package/index.js',
),
);

assertBundles(b, [
{
name: 'index.js',
assets: ['foo.css', 'foo.js', 'index.css', 'index.js'],
},
{
name: 'index.css',
assets: ['foo.css', 'index.css'],
},
]);

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

let value = output();
assert(/foo_[0-9a-z]/.test(value));

let cssClass = value.match(/(foo_[0-9a-z])/)[1];

let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8');
assert(css.includes(`.${cssClass}`));
});

it('should support transforming with postcss twice with the same result', async () => {
let b = await bundle(
path.join(__dirname, '/integration/postcss-plugins/index.js'),
Expand Down
59 changes: 59 additions & 0 deletions packages/core/integration-tests/test/transpilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,65 @@ describe('transpilation', function () {
});
});

it('should print errors from transpilation', async function () {
let source = path.join(
__dirname,
'/integration/transpilation-invalid/index.js',
);
// $FlowFixMe
await assert.rejects(() => bundle(source), {
name: 'BuildError',
diagnostics: [
{
codeFrames: [
{
codeHighlights: [
{
message: null,
start: {
column: 15,
line: 3,
},
end: {
column: 43,
line: 3,
},
},
],
filePath: source,
},
],
hints: null,
message: 'Spread children are not supported in React.',
origin: '@parcel/transformer-js',
},
{
codeFrames: [
{
codeHighlights: [
{
message: null,
start: {
column: 4,
line: 7,
},
end: {
column: 4,
line: 7,
},
},
],
filePath: source,
},
],
hints: null,
message: 'duplicate private name #x.',
origin: '@parcel/transformer-js',
},
],
});
});

describe('tests needing the real filesystem', () => {
afterEach(async () => {
if (process.platform === 'win32') {
Expand Down
Loading

0 comments on commit 56c5965

Please sign in to comment.