Skip to content

Commit

Permalink
Merge branch 'master' into update-dotenv-expand
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Jun 23, 2019
2 parents bc15db1 + 7ad25fd commit 3a7fcb6
Show file tree
Hide file tree
Showing 40 changed files with 1,100 additions and 1,009 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
@@ -0,0 +1,7 @@
# Always use unix style line-endings
* text eol=lf
*.jpeg binary
*.jpg binary
*.png binary
*.wasm binary
*.woff2 binary
1 change: 1 addition & 0 deletions .github/FUNDING.yml
@@ -0,0 +1 @@
open_collective: parcel
1 change: 1 addition & 0 deletions .prettierrc
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"bracketSpacing": false,
"endOfLine": "lf"
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -69,7 +69,7 @@ While contributing to parcel, you may need to run a local version of parcel and

To do this, you have multiple options:

* If you had **parcel** installed globally, you can run `yarn global remove parcel` and then `cd` to your own copy of parcel and run `yarn link`. This way, the global parcel in your PATH would reference to the local copy. To make sure you have it installed globally, just run `parcel --version`.
* If you had **parcel** installed globally, you can run `yarn global remove parcel-bundler` and then `cd` to your own copy of parcel and run `yarn link`. This way, the global parcel in your PATH would reference to the local copy. To make sure you have it installed globally, just run `parcel --version`.

* Another option would be to run `yarn link` in your own copy of parcel directory and then go to the directory, _which you want to test your copy of parcel in_, and run `yarn link parcel-bundler`, so that locally your copy of parcel is the one used in its npm scripts.

Expand Down
2 changes: 1 addition & 1 deletion packages/core/babel-register/package.json
Expand Up @@ -13,6 +13,6 @@
"@babel/core": "^7.0.0"
},
"dependencies": {
"@babel/register": "^7.0.0"
"@babel/register": "^7.4.4"
}
}
2 changes: 1 addition & 1 deletion packages/core/integration-tests/package.json
Expand Up @@ -12,7 +12,7 @@
"test-ci": "yarn test --reporter mocha-multi-reporters --reporter-options configFile=./test/mochareporters.json"
},
"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/core": "^7.4.4",
"@jetbrains/kotlinc-js-api": "^1.2.12",
"@parcel/fs": "^1.11.0",
"@parcel/test-utils": "^1.12.0",
Expand Down
Expand Up @@ -6,19 +6,19 @@
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/browser": "1.0.1",
"elm/core": "1.0.2",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.0.0",
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
"elm/virtual-dom": "1.0.2"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
}
10 changes: 5 additions & 5 deletions packages/core/integration-tests/test/integration/elm/elm.json
Expand Up @@ -6,19 +6,19 @@
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/browser": "1.0.1",
"elm/core": "1.0.2",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.0.0",
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
"elm/virtual-dom": "1.0.2"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
}
@@ -0,0 +1,4 @@
var b = require('./b');

b.setValue(2);
module.exports = b.value;
@@ -0,0 +1,3 @@
exports.setValue = function (value) {
exports.value = value;
}
@@ -0,0 +1 @@
module.exports = require('./b');
@@ -0,0 +1 @@
export default 2;
@@ -1,6 +1,7 @@
output = {
id: module.id,
hot: module.hot,
moduleRequire: module.require,
type: typeof module,
exports: exports,
exportsType: typeof exports,
Expand Down
@@ -0,0 +1,3 @@
(function(){
output = require('./b');
})();
@@ -0,0 +1,4 @@
const x = [1, 2]
const [a, b] = x;

module.exports = [a, b];
@@ -0,0 +1,4 @@
{
"private": true,
"browserslist": ["node 8"]
}
@@ -0,0 +1,3 @@
(function(){
output = require('./b');
})();
@@ -0,0 +1,7 @@
const x = {
a: 4,
b: 2
}
const {a, b} = x;

module.exports = [a, b];
@@ -0,0 +1,4 @@
{
"private": true,
"browserslist": ["node 8"]
}
@@ -0,0 +1,2 @@
import Test from './b';
output = Test.create();
@@ -0,0 +1,9 @@
export default class Test {
constructor() {
this.foo = 'bar';
}

static create() {
return new Test();
}
}
@@ -0,0 +1,5 @@
{
"name": "default-export-class-rename",
"private": true,
"browserslist": ["last 1 Chrome version"]
}
@@ -0,0 +1,3 @@
import {foo} from './b';

output = foo;
@@ -0,0 +1,4 @@
export const foo = 2;

export function bar() {}
bar.displayName = 'hello';
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/mochareporters.json
@@ -1,5 +1,5 @@
{
"reporterEnabled": "mocha-junit-reporter",
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "junit-testresults.xml"
}
Expand Down
83 changes: 82 additions & 1 deletion packages/core/integration-tests/test/scope-hoisting.js
Expand Up @@ -299,7 +299,7 @@ describe('scope hoisting', function() {
);
} catch (err) {
threw = true;
assert.equal(err.message, "export 'Test' is not defined");
assert.equal(err.message, "Export 'Test' is not defined (1:8)");
}

assert(threw);
Expand Down Expand Up @@ -549,6 +549,37 @@ describe('scope hoisting', function() {
let output = await run(b);
assert.deepEqual(output, 'bar');
});

it('should shake pure property assignments', async function() {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/es6/pure-assignment/a.js'
)
);

let output = await run(b);
assert.deepEqual(output, 2);

let contents = await fs.readFile(
path.join(__dirname, 'dist/a.js'),
'utf8'
);
assert(!/bar/.test(contents));
assert(!/displayName/.test(contents));
});

it('should correctly rename references to default exported classes', async function() {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/es6/default-export-class-rename/a.js'
)
);

let output = await run(b);
assert.deepEqual(output.foo, 'bar');
});
});

describe('commonjs', function() {
Expand Down Expand Up @@ -877,6 +908,7 @@ describe('scope hoisting', function() {
let output = await run(b);
assert.equal(output.id, b.entryAsset.id);
assert.equal(output.hot, null);
assert.equal(output.moduleRequire, null);
assert.equal(output.type, 'object');
assert.deepEqual(output.exports, {});
assert.equal(output.exportsType, 'object');
Expand Down Expand Up @@ -1172,5 +1204,54 @@ describe('scope hoisting', function() {
let output = await run(b);
assert.deepEqual(output, 42);
});

it('should insert __esModule interop flag when importing from an ES module', async function() {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/commonjs/interop-require-es-module/a.js'
)
);

let output = await run(b);
assert.equal(output.__esModule, true);
assert.equal(output.default, 2);
});

it('should support assigning to exports from inside a function', async function() {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/commonjs/export-assign-scope/a.js'
)
);

let output = await run(b);
assert.deepEqual(output, 2);
});

it('should support wrapping array destructuring declarations', async function() {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/commonjs/wrap-destructuring-array/a.js'
)
);

let output = await run(b);
assert.deepEqual(output, [1, 2]);
});

it('should support wrapping object destructuring declarations', async function() {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/commonjs/wrap-destructuring-object/a.js'
)
);

let output = await run(b);
assert.deepEqual(output, [4, 2]);
});
});
});
38 changes: 20 additions & 18 deletions packages/core/parcel-bundler/package.json
Expand Up @@ -15,18 +15,18 @@
"index.js"
],
"dependencies": {
"@babel/code-frame": "^7.0.0 <7.4.0",
"@babel/core": "^7.0.0 <7.4.0",
"@babel/generator": "^7.0.0 <7.4.0",
"@babel/parser": "^7.0.0 <7.4.0",
"@babel/plugin-transform-flow-strip-types": "^7.0.0 <7.4.0",
"@babel/plugin-transform-modules-commonjs": "^7.0.0 <7.4.0",
"@babel/plugin-transform-react-jsx": "^7.0.0 <7.4.0",
"@babel/preset-env": "^7.0.0 <7.4.0",
"@babel/runtime": "^7.0.0 <7.4.0",
"@babel/template": "^7.0.0 <7.4.0",
"@babel/traverse": "^7.0.0 <7.4.0",
"@babel/types": "^7.0.0 <7.4.0",
"@babel/code-frame": "^7.0.0",
"@babel/core": "^7.4.4",
"@babel/generator": "^7.4.4",
"@babel/parser": "^7.4.4",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/preset-env": "^7.4.4",
"@babel/runtime": "^7.4.4",
"@babel/template": "^7.4.4",
"@babel/traverse": "^7.4.4",
"@babel/types": "^7.4.4",
"@iarna/toml": "^2.2.0",
"@parcel/fs": "^1.11.0",
"@parcel/logger": "^1.11.0",
Expand All @@ -40,12 +40,14 @@
"clone": "^2.1.1",
"command-exists": "^1.2.6",
"commander": "^2.11.0",
"core-js": "^2.6.5",
"cross-spawn": "^6.0.4",
"css-modules-loader-core": "^1.1.0",
"cssnano": "^4.0.0",
"deasync": "^0.1.14",
"dotenv": "^5.0.0",
"dotenv-expand": "^5.1.0",
"envinfo": "^7.3.1",
"fast-glob": "^2.2.2",
"filesize": "^3.6.0",
"get-port": "^3.2.0",
Expand Down Expand Up @@ -74,10 +76,10 @@
"ws": "^5.1.1"
},
"devDependencies": {
"@babel/cli": "^7.0.0 <7.4.0",
"@babel/plugin-syntax-export-default-from": "^7.0.0 <7.4.0",
"@babel/plugin-syntax-export-namespace-from": "^7.0.0 <7.4.0",
"@babel/plugin-transform-runtime": "^7.0.0 <7.4.0",
"@babel/cli": "^7.4.4",
"@babel/plugin-syntax-export-default-from": "^7.0.0",
"@babel/plugin-syntax-export-namespace-from": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-flow": "^7.0.0 <7.4.0",
"@parcel/babel-register": "^1.11.0 <7.4.0",
"@parcel/test-utils": "^1.12.0",
Expand All @@ -89,7 +91,7 @@
"codecov": "^3.0.0",
"coffeescript": "^2.0.3",
"cross-env": "^5.1.1",
"elm": "^0.19.0",
"elm": "^0.19.0-bugfix6",
"elm-hot": "^1.0.1",
"eslint": "^4.13.0",
"glslify-bundle": "^5.0.0",
Expand All @@ -104,7 +106,7 @@
"mocha-multi-reporters": "^1.1.7",
"ncp": "^2.0.0",
"nib": "^1.1.2",
"node-elm-compiler": "^5.0.1",
"node-elm-compiler": "^5.0.3",
"nyc": "^11.1.0",
"postcss-modules": "^1.4.1",
"posthtml-extend": "^0.2.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/parcel-bundler/src/Asset.js
Expand Up @@ -9,6 +9,7 @@ const syncPromise = require('./utils/syncPromise');
const logger = require('@parcel/logger');
const Resolver = require('./Resolver');
const objectHash = require('./utils/objectHash');
const t = require('babel-types');

/**
* An Asset represents a file in the dependency tree. Assets can have multiple
Expand Down Expand Up @@ -204,7 +205,7 @@ class Asset {
if (!this.id) {
this.id =
this.options.production || this.options.scopeHoist
? md5(this.relativeName, 'base64').slice(0, 4)
? t.toIdentifier(md5(this.relativeName, 'base64')).slice(0, 4)
: this.relativeName;
}

Expand Down

0 comments on commit 3a7fcb6

Please sign in to comment.