Skip to content

Commit

Permalink
Merge branch 'master' into support-entry-progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Nov 4, 2018
2 parents 351114f + 10ff7a5 commit 8c5e74f
Show file tree
Hide file tree
Showing 40 changed files with 1,079 additions and 483 deletions.
15 changes: 5 additions & 10 deletions .travis.yml
Expand Up @@ -21,23 +21,19 @@ matrix:
include:
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=basic
env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=basic
stage: basic
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=lint-unit
env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=lint-unit
stage: advanced
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
stage: advanced
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 ALTERNATIVE_SORT=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
env: NO_WATCH_TESTS=1 ALTERNATIVE_SORT=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
stage: advanced
- os: linux
node_js: "10"
Expand Down Expand Up @@ -74,5 +70,4 @@ after_success:

notifications:
slack:
secure:
JduSdKWwbnLCwo7Z4E59SGE+Uw832UwnXzQiKEpg1BV45MYDPRiGltly1tRHmPh9OGjvGx3XSkC2tNGOBLtL4UL2SCkf012x0t7jDutKRfcv/njynl8jk8l+UhPmaWiHXDQAgGiiKdL4RfzPLW3HeVHCOWm0LKMzcarTa8tw+rE=
secure: JduSdKWwbnLCwo7Z4E59SGE+Uw832UwnXzQiKEpg1BV45MYDPRiGltly1tRHmPh9OGjvGx3XSkC2tNGOBLtL4UL2SCkf012x0t7jDutKRfcv/njynl8jk8l+UhPmaWiHXDQAgGiiKdL4RfzPLW3HeVHCOWm0LKMzcarTa8tw+rE=
3 changes: 1 addition & 2 deletions appveyor.yml
Expand Up @@ -32,5 +32,4 @@ test_script:
- cmd: yarn istanbul report --report lcovonly
- cmd: yarn unlink webpack
- cmd: yarn global add codecov && codecov -F %job_part% --disable=gcov
- cmd:
del /F /Q .jest-cache\\haste-map* .jest-cache\\perf-cache* 2> null || Ver > null
- cmd: del /F /Q .jest-cache\\haste-map* .jest-cache\\perf-cache* 2> null || Ver > null
68 changes: 55 additions & 13 deletions azure-pipelines.yml
Expand Up @@ -4,9 +4,9 @@ jobs:
vmImage: ubuntu-16.04
steps:
- task: NodeTool@0
displayName: "Install Node.js"
inputs:
versionSpec: "^10.10.0"
displayName: "Install Node.js"
- script: |
curl -o- -L https://yarnpkg.com/install.sh | bash
displayName: "Install Yarn"
Expand All @@ -26,17 +26,32 @@ jobs:
- script: |
set -e
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn test:basic --ci
yarn test:unit --ci
export JEST_JUNIT_OUTPUT=./basic-junit.xml
yarn test:basic --ci --reporters=jest-junit
export JEST_JUNIT_OUTPUT=./unit-junit.xml
yarn test:unit --ci --reporters=jest-junit
displayName: "Run basic tests"
- task: PublishTestResults@2
inputs:
testRunTitle: "basic"
testResultsFiles: "**/basic-junit.xml"
condition: succeededOrFailed()
displayName: "Publish basic test results"
- task: PublishTestResults@2
inputs:
testRunTitle: "unit"
testResultsFiles: "**/unit-junit.xml"
condition: succeededOrFailed()
displayName: "Publish unit test results"

- job: lint
pool:
vmImage: ubuntu-16.04
steps:
- task: NodeTool@0
displayName: "Install Node.js"
inputs:
versionSpec: "^10.10.0"
displayName: "Install Node.js"
- script: |
curl -o- -L https://yarnpkg.com/install.sh | bash
displayName: "Install Yarn"
Expand All @@ -58,7 +73,14 @@ jobs:
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn lint
displayName: "Run linting"
- job: linux
- task: PublishTestResults@2
inputs:
testRunTitle: "lint"
testResultsFiles: "**/junit.xml"
condition: succeededOrFailed()
displayName: "Publish lint results"

- job: Linux
dependsOn:
- basic
- lint
Expand All @@ -75,9 +97,9 @@ jobs:
node_version: ^6.14.4
steps:
- task: NodeTool@0
displayName: "Install Node.js"
inputs:
versionSpec: $(node_version)
displayName: "Install Node.js $(node_version)"
- script: |
curl -o- -L https://yarnpkg.com/install.sh | bash
displayName: "Install Yarn"
Expand All @@ -98,9 +120,16 @@ jobs:
set -e
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn cover:init
yarn cover:integration --ci --maxWorkers=2
yarn cover:integration --ci --maxWorkers=2 --reporters=jest-junit
displayName: "Run tests with coverage"
- job: macos
- task: PublishTestResults@2
inputs:
testRunTitle: "Linux with Node.js $(node_version)"
testResultsFiles: "**/junit.xml"
condition: succeededOrFailed()
displayName: "Publish test results"

- job: macOS
dependsOn:
- basic
- lint
Expand All @@ -117,9 +146,9 @@ jobs:
node_version: ^6.14.4
steps:
- task: NodeTool@0
displayName: "Install Node.js"
inputs:
versionSpec: $(node_version)
displayName: "Install Node.js $(node_version)"
- script: |
curl -o- -L https://yarnpkg.com/install.sh | bash
displayName: "Install Yarn"
Expand All @@ -140,9 +169,16 @@ jobs:
set -e
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn cover:init
yarn cover:integration --ci
yarn cover:integration --ci --reporters=jest-junit
displayName: "Run tests with coverage"
- job: windows
- task: PublishTestResults@2
inputs:
testRunTitle: "macOS with Node.js $(node_version)"
testResultsFiles: "**/junit.xml"
condition: succeededOrFailed()
displayName: "Publish test results"

- job: Windows
dependsOn:
- basic
- lint
Expand All @@ -159,9 +195,9 @@ jobs:
node_version: ^6.14.4
steps:
- task: NodeTool@0
displayName: "Install Node.js"
inputs:
versionSpec: $(node_version)
displayName: "Install Node.js $(node_version)"
- script: |
npm install --global yarn
displayName: "Install Yarn"
Expand All @@ -178,5 +214,11 @@ jobs:
displayName: "Install dependencies"
- script: |
set -e
yarn cover:init && yarn cover:integration --ci --maxWorkers=2
yarn cover:init && yarn cover:integration --ci --maxWorkers=2 --reporters=jest-junit
displayName: "Run tests with coverage"
- task: PublishTestResults@2
inputs:
testRunTitle: "Windows with Node.js $(node_version)"
testResultsFiles: "**/junit.xml"
condition: succeededOrFailed()
displayName: "Publish test results"
8 changes: 4 additions & 4 deletions examples/README.md
@@ -1,6 +1,6 @@
# Examples
## Aggressive Merging
[aggressive-merging](aggressive-merging)
[aggressive-merging](aggressive-merging)

## Chunk
[chunkhash](chunkhash)
Expand Down Expand Up @@ -31,9 +31,9 @@

[code-splitting-bundle-loader](code-splitting-bundle-loader) example demonstrating Code Splitting through the builder loader

[code-splitting-harmony](code-splitting-harmony)
[code-splitting-harmony](code-splitting-harmony)

[code-splitting-native-import-context](code-splitting-native-import-context)
[code-splitting-native-import-context](code-splitting-native-import-context)

[code-splitting-specify-chunk-name](code-splitting-specify-chunk-name)

Expand Down Expand Up @@ -110,7 +110,7 @@ If you think an example is missing, please report it as issue. :)

# Building an Example
1. Run `yarn` in the root of the project.
2. Run `yarn link webpack` in the root of the project.
2. Run `yarn setup` in the root of the project.
3. Run `yarn add --dev webpack-cli` in the root of the project.
4. Run `node build.js` in the specific example directory. (Ex: `cd examples/commonjs && node build.js`)

Expand Down
43 changes: 39 additions & 4 deletions lib/BasicEvaluatedExpression.js
Expand Up @@ -29,11 +29,13 @@ class BasicEvaluatedExpression {
this.regExp = null;
this.string = null;
this.quasis = null;
this.parts = null;
this.array = null;
this.items = null;
this.options = null;
this.prefix = null;
this.postfix = null;
this.expression = null;
}

isNull() {
Expand Down Expand Up @@ -105,10 +107,36 @@ class BasicEvaluatedExpression {
: undefined;
}
if (this.isTemplateString()) {
for (const quasi of this.quasis) {
if (quasi.asBool()) return true;
const str = this.asString();
if (typeof str === "string") return str !== "";
}
return undefined;
}

asString() {
if (this.isBoolean()) return `${this.bool}`;
if (this.isNull()) return "null";
if (this.isString()) return this.string;
if (this.isNumber()) return `${this.number}`;
if (this.isRegExp()) return `${this.regExp}`;
if (this.isArray()) {
let array = [];
for (const item of this.items) {
const itemStr = item.asString();
if (itemStr === undefined) return undefined;
array.push(itemStr);
}
return `${array}`;
}
if (this.isConstArray()) return `${this.array}`;
if (this.isTemplateString()) {
let str = "";
for (const part of this.parts) {
const partStr = part.asString();
if (partStr === undefined) return undefined;
str += partStr;
}
// can't tell if string will be empty without executing
return str;
}
return undefined;
}
Expand Down Expand Up @@ -184,9 +212,11 @@ class BasicEvaluatedExpression {
return this;
}

setTemplateString(quasis) {
setTemplateString(quasis, parts, kind) {
this.type = TypeTemplateString;
this.quasis = quasis;
this.parts = parts;
this.templateStringKind = kind;
return this;
}

Expand All @@ -206,6 +236,11 @@ class BasicEvaluatedExpression {
this.range = range;
return this;
}

setExpression(expression) {
this.expression = expression;
return this;
}
}

module.exports = BasicEvaluatedExpression;
10 changes: 9 additions & 1 deletion lib/ConstPlugin.js
Expand Up @@ -279,7 +279,15 @@ class ConstPlugin {
(expression.operator === "||" && !bool);

if (param.isBoolean() || keepRight) {
const dep = new ConstDependency(`${bool}`, param.range);
// for case like
//
// return'development'===process.env.NODE_ENV&&'foo'
//
// we need a space before the bool to prevent result like
//
// returnfalse&&'foo'
//
const dep = new ConstDependency(` ${bool}`, param.range);
dep.loc = expression.loc;
parser.state.current.addDependency(dep);
} else {
Expand Down
10 changes: 7 additions & 3 deletions lib/DefinePlugin.js
Expand Up @@ -21,11 +21,15 @@ class RuntimeValue {
}

exec(parser) {
for (const fileDependency of this.fileDependencies) {
parser.state.module.buildInfo.fileDependencies.add(fileDependency);
if (this.fileDependencies === true) {
parser.state.module.buildInfo.cacheable = false;
} else {
for (const fileDependency of this.fileDependencies) {
parser.state.module.buildInfo.fileDependencies.add(fileDependency);
}
}

return this.fn();
return this.fn({ module: parser.state.module });
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/HotModuleReplacementPlugin.js
Expand Up @@ -255,7 +255,7 @@ module.exports = class HotModuleReplacementPlugin {
for (const key of Object.keys(records.chunkHashs)) {
const chunkId = isNaN(+key) ? key : +key;
const currentChunk = compilation.chunks.find(
chunk => chunk.id === chunkId
chunk => `${chunk.id}` === key
);
if (currentChunk) {
const newModules = currentChunk
Expand Down

0 comments on commit 8c5e74f

Please sign in to comment.