Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Log if there are duplicate packages 👬 #377

Closed
wants to merge 90 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
5fafb5c
Update Wepback to latest version 😇
pirelenito Jun 20, 2017
c36ebe4
Enable scope hoisting as a build optimization 📦
pirelenito Jun 20, 2017
48ef17e
Log if there are duplicate packages 👬
pirelenito Jun 30, 2017
626105f
Merge branch 'v10' into webpack-3
pirelenito Jul 10, 2017
d4bf032
Update extract-text-webpack-plugin to get style order fix 🤒
pirelenito Jul 14, 2017
19f78a1
Also bump webpack and webpack-dev-server ☠️
pirelenito Jul 14, 2017
2b8f478
Update node versions in travis and appveyor 📈
pirelenito Jul 14, 2017
44283e7
Merge pull request #373 from saguijs/webpack-3
pirelenito Jul 14, 2017
5947831
11.0.0-rc.0
pirelenito Jul 14, 2017
c55ec14
Use Chrome Headless by default to run unit tests 😑
Jul 14, 2017
a205a7d
Bump the karma-chrome-launcher version ☝️
Jul 14, 2017
8b34825
Use custom ChromeHeadless launcher
Jul 15, 2017
537c2b3
Specify 'trusty' as ubuntu version to be able to install Chrome 🚀
Jul 17, 2017
ba961a5
Remove the custom launcher for ChromeHeadless ✂️
Jul 17, 2017
fe345f1
Run Chrome and PhantomJS tests in Travis 📝
Jul 17, 2017
809b88b
Specify node version for all test variations 💿
Jul 17, 2017
1d3f8c3
Show the browser name in which tests are running 🅰️
Jul 17, 2017
766e77e
Fallback to PhanthomJS if CHROME_BIN is not set 🔙
Jul 17, 2017
400cf4e
Do not run other tests while test_create_project
Jul 17, 2017
5042f7d
Fix Travis not correctly using Chrome when available 🔥
pirelenito Jul 19, 2017
434fe28
Merge pull request #379 from saguijs/use-chrome-headless-to-run-unit-…
pirelenito Jul 19, 2017
acda5a5
11.0.0-rc.1
pirelenito Jul 19, 2017
cc74875
Disable symlink resolving in Webpack config
xaviervia Jul 25, 2017
b191c29
Merge pull request #382 from saguijs/no-symlinks
pirelenito Jul 25, 2017
0cf9227
11.0.0-rc.2
pirelenito Jul 25, 2017
ca478f6
Merge branch 'v10' into v11
pirelenito Jul 25, 2017
01dbf62
Enable cache of transliped code
Jul 27, 2017
14d2614
Merge pull request #384 from saguijs/enable-transpile-cache-for-babel…
pirelenito Jul 27, 2017
cd23cf7
11.0.0-rc.3
pirelenito Jul 27, 2017
70c9249
Load `babel-plugin-syntax-dynamic-import` plugin (#385)
npejo Jul 28, 2017
e213588
11.0.0-rc.4
pirelenito Jul 28, 2017
6d4faef
Non-intrusive ESLint messages while in development 🕺
pirelenito Jul 28, 2017
c18770d
Force Travis to use old environment to test PhantomJS 🤧
pirelenito Jul 28, 2017
3cf451d
Bump all dependencies to latest stable except postcss-loader 🐡 (#380)
pirelenito Jul 28, 2017
1c7b4b7
Merge pull request #386 from saguijs/friendlier-eslint-in-development
pirelenito Jul 28, 2017
4b96ae3
11.0.0-rc.5
pirelenito Jul 28, 2017
22b02f0
11.0.0
pirelenito Jul 28, 2017
13fa52d
Remove the DedupePlugin
Aug 1, 2017
d2989f6
Merge pull request #387 from saguijs/remove-dedupe-plugin
pirelenito Aug 1, 2017
db28523
11.0.1
pirelenito Aug 1, 2017
c6d3aa9
Remove the ModuleConcatenationPlugin
Aug 2, 2017
eb2bf6e
Merge pull request #388 from saguijs/disable-module-concatenation-plugin
pirelenito Aug 2, 2017
f8d518d
11.0.2
pirelenito Aug 2, 2017
666166a
Add the case-sensitive-paths-webpack-plugin webpack plugin
Aug 6, 2017
217cb45
Add the local ip address to the webpack-dev-server/client path
Aug 6, 2017
d5e691b
Merge pull request #392 from saguijs/warn-case-mismatch-in-path
pirelenito Aug 6, 2017
8b25d57
Merge pull request #393 from saguijs/fix-hmr-setup
pirelenito Aug 6, 2017
054faf9
11.1.0
pirelenito Aug 6, 2017
42d4a1b
Spelling correction in successful build message
icenine457 Aug 24, 2017
a653343
Update README.md
xaviervia Aug 25, 2017
5db1f87
Merge pull request #399 from icenine457/v11
pirelenito Aug 25, 2017
1782578
Update README.md
xaviervia Aug 25, 2017
7d627fb
Test creating a new project with the latest version of Node and npm 🤧
pirelenito Aug 25, 2017
368563e
Replace `prepublish` with `prepare`
pirelenito Aug 25, 2017
12bb026
Merge pull request #400 from saguijs/xaviervia-patch-1
pirelenito Aug 25, 2017
a7ec66d
Merge pull request #401 from saguijs/test-project-creation-in-latest-…
pirelenito Aug 25, 2017
f478492
Merge pull request #402 from saguijs/stop-using-prepublish
pirelenito Aug 25, 2017
9135f52
Add missing ESLint dependencies
xaviervia Oct 31, 2017
08a8d95
Drop integrated testing with PhantomJS 😲
pirelenito Oct 31, 2017
0c2365f
Ignore lock files while we don't decide on a standard 👨‍💻
pirelenito Oct 31, 2017
d2ed05b
Merge pull request #407 from saguijs/fix-eslint-missing-dependencies
pirelenito Oct 31, 2017
98f2370
11.2.0
pirelenito Oct 31, 2017
d4d9c19
Revert "Add missing ESLint dependencies"
pirelenito Oct 31, 2017
f649d0d
Fix issues/warnings with missing dependencies 🙀
pirelenito Oct 31, 2017
4bcb588
Merge pull request #410 from saguijs/fix-dependencies-issue
pirelenito Oct 31, 2017
19ff8e7
11.3.0
pirelenito Oct 31, 2017
ffd0864
Set minChunks to 2 by default
Nov 8, 2017
ebc2d85
Merge pull request #412 from saguijs/set-minchunks-value-in-the-commo…
pirelenito Nov 8, 2017
78faff9
Make Travis responsible for building before publishing 🤷‍♂️
pirelenito Nov 8, 2017
801c4ca
v11.4.0
pirelenito Nov 8, 2017
e1d810e
v11.4.1
pirelenito Nov 8, 2017
3a5b482
Fix Travis cleaning built assets before publishing 🐔
pirelenito Nov 8, 2017
d4f1ca9
v11.4.2
pirelenito Nov 8, 2017
e5f5801
Fix `Chunk.modules is deprecated` by updating webpack-md5-hash
pirelenito Dec 7, 2017
73a9c4a
Merge pull request #416 from saguijs/fix-deprecation-warning
pirelenito Dec 7, 2017
a8de424
v11.4.3
pirelenito Dec 7, 2017
52483f3
Add support for `chunks` configuration for pages
Dec 26, 2017
c2147f6
Use `chunks` configuration when building pages in order to enable/dis…
Dec 26, 2017
8142b02
Update README.md
Dec 26, 2017
38b4a22
Fix unit tests
Dec 26, 2017
09683cb
Pass `chunks` as part of `sharedSaguiConfig` instead of an argument
Dec 26, 2017
42e9b7e
Make it clear that external dependencies refer to `node_modules` in R…
Dec 26, 2017
2e51730
Change example code for independent page in README.md
Dec 26, 2017
5b31622
Flatten `chunks` documentation in README.md
Dec 26, 2017
044ec93
Fix issues
Jan 2, 2018
52c110f
Fix more issues
Jan 2, 2018
5884302
Integration tests for chunks configuration
pirelenito Jan 2, 2018
209e913
Merge pull request #417 from saguijs/add-configuration-for-vendor-and…
pirelenito Jan 2, 2018
a5fae77
v11.5.0
pirelenito Jan 2, 2018
c0053d2
Merge remote-tracking branch 'origin/master' into duplicate-packages
pirelenito Jan 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
lib
tmp
npm-debug.log
package-lock.json
yarn.lock
57 changes: 43 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
language: node_js
node_js:
- 6.10.3
- 8.0.0
sudo: false

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash # until yarn is
- export PATH=$HOME/.yarn/bin:$PATH # pre-installed
- curl -o- -L https://yarnpkg.com/install.sh | bash # until yarn is
- export PATH=$HOME/.yarn/bin:$PATH # pre-installed

script:
- node bin/ci.js
env:
matrix:
- TEST_TYPE=lint_and_test_unit
- TEST_TYPE=integration_test
- TEST_TYPE=test_create_project_npm
- TEST_TYPE=test_create_project_yarn
- node bin/ci.js

matrix:
include:
- sudo: false
env: TEST_TYPE=lint_and_test_unit
node_js: 6.11.1

# test creating a new project with the LTS version
- sudo: false
env: TEST_TYPE=test_create_project_npm
node_js: 6.11.1

# test creating a new project with the latest version
- sudo: false
env: TEST_TYPE=test_create_project_npm
node_js: 8.4.0

- sudo: false
env: TEST_TYPE=test_create_project_yarn
node_js: 6.11.1

# Test with Chrome available
- dist: trusty
addons:
chrome: stable
sudo: false
env:
- TEST_TYPE=integration_test
- BROWSER=Chrome
node_js: 6.11.1

cache:
directories:
- node_modules
- node_modules

before_deploy:
- npm prune
- npm run build

deploy:
skip_cleanup: true
provider: npm
email: [email protected]
api_key:
Expand Down
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ Sagui will automatically run every test file that follows this convention.

Under the hood it uses [Karma test runner](http://karma-runner.github.io/) to allow running the tests in the most diverse browsers and even through [Selenium](http://docs.seleniumhq.org/) (not natively).

By default Sagui uses [PhantomJS](http://phantomjs.org/) to run the tests headlessly. To **speed up installing the dependencies** (`npm install`) it is advisable to have PhantomJS [installed globally](https://github.com/Medium/phantomjs#using-phantomjs-from-disk) in the machine.
To run the tests Sagui uses [Chrome Headless](https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md), but it fallbacks to [PhantomJS](http://phantomjs.org/) if Chrome is not installed on the machine.

Make sure either of these browsers is installed to be able to run the tests:

- [Chrome](https://www.google.com/chrome/browser/desktop/index.html)
- [PhantomJS](https://github.com/Medium/phantomjs#using-phantomjs-from-disk)

To open the tests in a browser (or in multiple browsers!), simply follow the link Karma outputs when you start running the script `test:unit:watch`. Running them in a browser allows you to set breakpoints and debug your code properly. Note watch mode is necessary, else tests will stop running when finished.

Expand Down Expand Up @@ -167,6 +172,43 @@ The previous configuration will expect and build the files:
- `src/index.html` => `dist/index.html`
- `src/index.js` => `dist/index.js`

#### Excluding a page from chunks

If you want a page to be excluded from either the [vendor](#chunksvendor) or [common](#chunkscommon) chunk, then you can do so by providing an object with a `name` and `independent` flag (set to `true`) instead of just the name of the page.

```js
// sagui.config.js
module.exports = {
pages: ['index', 'about', { name: 'demo', independent: true }]
}
```

### `chunks.vendor`

If you want all your external dependencies (`node_modules`) in your [pages](#pages) to be bundled together in a "vendor" chunk, then set this flag to `true`. By default it is set to `false`.

```js
// sagui.config.js
module.exports = {
chunks: {
vendor: true
}
}
```

### `chunks.common`

If you do not want all the common dependencies of your [pages](#pages) to be bundled together in a "common" chunk, then set this flag to `false`. By default it is set to `true`.

```js
// sagui.config.js
module.exports = {
chunks: {
common: false
}
}
```

### `libraries`

Create **reusable libraries** that can be shared across applications. Sagui will take care of the build process so that external libraries are not bundled and that you have a CommonJS module as the output.
Expand Down Expand Up @@ -409,6 +451,19 @@ For more information about configuring Karma, check the [Karma documentation](ht

## Gotchas

### `Invalid Host header` - Accessing dev server from outside `localhost`

By default, Webpack disables access to the development server for hosts other than `localhost`, which means the development server will not be accessible from outside. If you want to give external access to the development server, you can set the `develop.disableHostCheck` to `true`:

```js
// sagui.config.js
module.exports = {
develop: {
disableHostCheck: true
}
}
```

### React Router

For [`react-router`](https://github.com/ReactTraining/react-router) to work on the development server, an absolute static path for the output has to be configured on Webpack. You can do that by adding this configuration to `sagui.config.js`:
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "{build}"

environment:
matrix:
- nodejs_version: "8.0.0"
- nodejs_version: "8.1.4"
platform: x64
TEST_TYPE: lint_and_test_unit

- nodejs_version: "8.0.0"
- nodejs_version: "8.1.4"
platform: x64
TEST_TYPE: integration_test

- nodejs_version: "8.0.0"
- nodejs_version: "8.1.4"
platform: x64
TEST_TYPE: test_create_project_npm

Expand Down
4 changes: 2 additions & 2 deletions bin/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (process.env.TEST_TYPE === 'integration_test') {
if (process.env.TEST_TYPE === 'test_create_project_npm') {
// # builds Sagui before installing
exec('npm run build', saguiPath)
exec('npm pack')
exec('npm pack --ignore-scripts')

var npmProjectPath = createTempFolder()

Expand All @@ -47,7 +47,7 @@ if (process.env.TEST_TYPE === 'test_create_project_npm') {
if (process.env.TEST_TYPE === 'test_create_project_yarn') {
// # builds Sagui before installing
exec('npm run build', saguiPath)
exec('npm pack')
exec('npm pack --ignore-scripts')

var yarnProjectPath = createTempFolder()

Expand Down
54 changes: 30 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sagui",
"version": "10.0.2",
"version": "11.5.0",
"description": "Front-end tooling in a single dependency",
"preferGlobal": false,
"bin": {
Expand All @@ -24,7 +24,6 @@
"test:integration:watch": "npm run test:integration -- --watch",
"test:unit": "mocha --timeout 0 --compilers js:babel-register --recursive --reporter spec ./src",
"test:unit:watch": "npm run test:unit -- --watch --watch-extensions json",
"prepublish": "not-in-install && npm prune && npm test && npm run build || in-install",
"postinstall": "node ./bin/sagui.js update"
},
"standard": {
Expand Down Expand Up @@ -53,76 +52,83 @@
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-register": "^6.24.0",
"chai": "^3.5.0",
"in-publish": "^2.0.0",
"jsdom": "^9.12.0",
"chai": "^4.1.0",
"jsdom": "^11.1.0",
"mocha": "^3.2.0",
"snazzy": "^7.0.0",
"temp": "^0.8.3",
"tmp": "0.0.31"
},
"dependencies": {
"ajv": "^4.11.6",
"autoprefixer": "^6.7.7",
"ajv": "^5.2.2",
"autoprefixer": "^7.1.2",
"babel-core": "^6.24.0",
"babel-eslint": "^7.2.1",
"babel-loader": "^6.4.1",
"babel-loader": "^7.1.1",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-react-jsx-self": "^6.22.0",
"babel-plugin-transform-react-jsx-source": "^6.22.0",
"babel-preset-env": "^1.3.3",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"chalk": "^1.1.3",
"case-sensitive-paths-webpack-plugin": "^2.1.1",
"chalk": "^2.0.1",
"clean-webpack-plugin": "^0.1.16",
"commander": "^2.9.0",
"css-loader": "^0.28.0",
"deep-equal": "^1.0.1",
"duplicate-package-checker-webpack-plugin": "^2.0.2",
"eslint": "^3.19.0",
"eslint-config-prettier": "^1.7.0",
"eslint-config-prettier": "^2.3.0",
"eslint-config-standard": "10.2.0",
"eslint-config-standard-jsx": "4.0.1",
"eslint-loader": "^1.7.1",
"eslint-plugin-flowtype": "^2.32.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^4.2.2",
"eslint-plugin-import": "~2.2.0",
"eslint-plugin-node": "~4.2.2",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"extract-text-webpack-plugin": "^2.1.0",
"eslint-plugin-promise": "~3.5.0",
"eslint-plugin-react": "~6.10.0",
"eslint-plugin-standard": "~3.0.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.1",
"flow-bin": "0.43.1",
"fs-extra": "^2.1.2",
"flow-bin": "0.50.0",
"fs-extra": "^4.0.0",
"glob": "^7.1.1",
"happypack": "^3.0.3",
"html-loader": "^0.4.5",
"html-webpack-plugin": "^2.28.0",
"ip": "^1.1.5",
"jasmine-core": "^2.5.2",
"karma": "^1.6.0",
"karma-chrome-launcher": "^2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-detect-browsers": "^2.2.5",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.3",
"lodash.merge": "^4.6.0",
"lodash.uniq": "^4.5.0",
"node-sass": "^4.5.2",
"null-loader": "^0.1.1",
"parent-module": "^0.1.0",
"phantomjs-prebuilt": "^2.1.14",
"postcss-loader": "^1.3.3",
"prettier": "^1.3.1",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.3",
"standard": "^10.0.1",
"style-loader": "^0.16.1",
"style-loader": "^0.18.2",
"template-directory": "^2.0.0",
"url-loader": "^0.5.8",
"webpack": "^2.3.3",
"webpack-dev-server": "^2.4.2",
"webpack-md5-hash": "0.0.5",
"webpack": "^3.2.0",
"webpack-dev-server": "^2.5.1",
"webpack-md5-hash": "0.0.6",
"webpack-merge": "^4.1.0",
"yaml-loader": "^0.4.0"
"yaml-loader": "^0.5.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import('./lib').then(module => {
module()
})
3 changes: 3 additions & 0 deletions spec/fixtures/project-content-with-dynamic-import/src/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function() {
console.log('The lib is loaded')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import SimpleModule from './SimpleModule'

console.log(SimpleModule)
Binary file not shown.
Binary file not shown.

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.

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

7 changes: 7 additions & 0 deletions spec/fixtures/project-with-independent-page/sagui.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
pages: ['index', 'about', { name: 'demo', independent: true }],
chunks: {
vendor: true,
common: true,
}
}
11 changes: 11 additions & 0 deletions spec/fixtures/project-with-independent-page/src/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>
<body>
<div id="root"></div>
</body>
</html>
5 changes: 5 additions & 0 deletions spec/fixtures/project-with-independent-page/src/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import shared from './shared'
import dependencyA from 'dependencyA'

shared()
dependencyA()
11 changes: 11 additions & 0 deletions spec/fixtures/project-with-independent-page/src/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>
<body>
<div id="root"></div>
</body>
</html>
Loading