* Fixing dynamic require missing from webpack
When running `yarn pack` with a bundledDependency yarn was throwing
an error: An unexpected error occurred: "Cannot find module \".\"".
This was due to yarn's cli.js being transpiled to on line 110321:
```
var thePackage = !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());
```
This line comes from e849d3e2f0/lib/pkg.js (L20)
and is a dynamic require. This commit impements a fix for this based on the guidence from https://github.com/webpack/webpack/issues/4175#issuecomment-450746682
This code was originally added with #5966
* Update CHANGELOG.md
* Set up CI with Azure Pipelines
* Update azure-pipelines.yml
* Update azure-pipelines.yml
* Update package.json
* Adds debug
* Tries using bash
* Tweaks timeouts
* Fixes various things related to the win32 compat
* I get the same 22 failed tests with/without the delay.
* Fix makeFakeBinary for win32.
It needs the ".cmd" extension, otherwise it's ignored.
Remove #!/bin/sh and instead add @echo off to clean output
Use errorCode 0 so we get output and not a Command failed
* Check custom output instead of versions.
Running fake binaries there was no way to get local versions of node or yarn. Am I missing something?
* Remove quotes from echo (not removed in Windows).
Replace ; by /n as the former doesn't actually break statements in Windows batch files.
* Some tweaks
* Fixes syntax
* Fixes tests on Windows
* Adds test reporting
* Fixes things (?)
* Fixes indent
* Always run the test result publishing
* Fixes yml
* Use node scripts to avoid Windows interoperability issues.
* Fixes the "must use the same Node as Yarn itself" test
* Fixes escaping from within the tests
* Removes the accidental .only flag
* Fixes a test on Windows
* Add support for different drives in Windows.
So if code is in D: but temporary folder is in C:, don't try to find a relative path but stay on the absolute one.
* No need to getPackageLocation
* Add support for environment and arguments by using a custom solution instead of cmd-shim.
* Missing escape on path in pnpapi test.
* Some cleaning
* Runs tests on all three platforms
* Fixes write paths
* Fixes normalizePath
* Disables pkg-tests from CircleCI (moved to Azure)
* Increase Windows timeouts and better name Test results (#6680)
* Increase timeout in Windows, we're seeing tests failing randomly and others close to default 5 sec.
* Distinguish tests published from each job.
* Pass name as vmImage is not available
* Remove unnecessary detect unfinished tests.
* Using strategy var instead of parameter
* Use variables instead of strategy
* Revert "Disables pkg-tests from CircleCI (moved to Azure)"
This reverts commit 8f724620b6.
* Initial pnp implementation
* Adds the pnp-env directory for quick checks
* Improves the "yarn node" command so that it works with pnp
Branch: yarn-node-pnp
* Adds the pnp tests to the pkg-tests testsuite
Branch: pkg-tests
* Fixes various issues with the pnp map generation
Branch: pnp-map-improvements
* Remove the scriptsPrependNodePath option
Branch: lifecycle-wrappers-remove-option
* Adds tests to ensure that the lifecycle scripts are called with the right binaries
Branch: lifecycle-wrappers-tests
* Fixes linting
Branch: lifecycle-wrappers-flowlint
* Improve the error message when an optional required dependency hasn't been installed
Branch: lifecycle-wrappers-improve-pnp-error
* Implements lifecycle wrappers
Branch: lifecycle-wrappers-main
* Adds .pnp.js files to the gitignore
* Fallbacks to the toplevel dependencies when a transitive dependency cannot be resolved
* Fixes an issue inside the pkg-tests helper
Branch: pkg-tests-helper-definition
* Improves the fixtures so that they also return info about their dev and peer dependencies
Branch: dev-peer-fixtures
* Finishes to hide plugnplay behind a yarnrc option (`plugnplay-experimental`)
Branch: option-plugnplay-experimental
* Adds failing tests for pnp peer dependencies
Branch: pnp-peer-dependencies-failing
* Prettifies the generated pnp files
* Adds the plugnplay flag to the integrity check
* Removes the pnp file at link-time if installing with pnp disabled
* Improves pnp maps compatibility
* Prevents "yarn check" from checking the node_modules existence when under pnp
* Adds a missing package to the request cache
* Fixes tests
Branch: pnp-fix-tests
* Reimplements the resolution to correctly account for peer dependencies
Branch: better-faster-stronger
* Externalizes the creation of proxy scripts
Branch: portable-proxy-scripts
* Implements support for `yarn run` within pnp-enabled installations
Branch: pnp-yarn-run
* Makes it possible for dependency binaries to require their own dependencies
Branch: pnp-yarn-run-dependencies
* Moves the pnp embed api into its own file
* Adds the test folder to Jest error messages
Branch: jest-better-message
* Improves peer dependency tests
Branch: peer-deps-tests
* Adds tests for require.resolve
Branch: require-resolve-tests
* Refactors the pnp file
Branch: pnp-file-refactoring
* Updates the build-webpack script to include a custom resolver
Branch: webpack-resolver
* Fixes tests
Branch: fix-tests
* Generates virtual when using peer dependencies
Branch: virtual-packages
* Refactors the generated pnp files to use the newly generated maps
Branch: pnp-refactor-find
* Implements Module._findPath
Branch: module-findpath
* Adds tests for workspaces
Branch: workspace-tests
* Fixes top level detection
Branch: fix-top-level-detection
* Implements workspaces support in pnp
Branch: pnp-workspaces
* Automatically adds workspaces as dependencies of the top-level
Branch: auto-workspace-dependencies
* Updates the cache path to include the 'node_modules' string
Branch: node-modules-cache
* Prevents pnp from bootstrapping when running non-pnp-installed scripts
Branch: fix-npm-run
* Installs peer dependencies symlinks inside a project folder
Branch: per-project-virtual-deps
* Adds a sample application that showcases webpack, babel, react, jest
Branch: sample-app
* Ignores the .pnp directory
Branch: ignore-pnp
* Implements a blacklist that throws nicer errors when a package is required through a realpath'd path.
Branch: location-blacklist
* Changes the order the locations are matched to package locators
Branch: location-to-locator-match-order
* Automatically adds packages as dependencies of themselves if possible
Branch: implicit-self
* Updates the node resolution
Branch: node-resolution-improvements
* Ensures that binaries are set as executable in the cache
Branch: chmod-bins
* Disables integrity checks when running under pnp
Branch: pnp-no-integrity
* Makes the .pnp.js file an actual executable that can be used as a resolution server
Branch: pnp-executable
* Removes pnp-env
* Fixes a few tests
* Fixes snapshots
* Fixes the lockfile not being written when using pnp
Branch: fix-lockfile
* Fixes the `yarn node` command being incorrectly forwarded arguments
Branch: fix-yarn-node
* Uses symlinks instead of a script for bin indirection to allow calling them directly through Node
Branch: bin-symlinks
* Adds a `yarn bin <name>` command that returns the path of the specified bin on the disk
Branch: yarn-bin-name
* Implements an --into option to yarn node/yarn run
Branch: opt-into
* Implements the `--pnp` option
Branch: pnp-option
* Adds new tests for checking that packages are correctly locked
Branch: lock-tests
* Bugfixes
This diff ships with two fixes:
- Fixes calling a pnp script from a non-pnp scripts
- Fixes relative requires from binaries
It also adds tests for all those cases
Branch: bugfixes
* Fixes workspace registration
Branch: workspace-registration-fix
* Uses --enable-pnp (alias --pnp) and --disable-pnp
Branch: instalconfig-pnp
* Adds the issuer into the error messages when requesting a package one shouldn't have access to.
Branch: via-issuer
* Implements extendedQualifiedPathResolution
Branch: extended-qualified-path-resolution
* Changes the return of the pnp daemon to return json data
* Implements custom shebangs for the pnp file
* Changes the return of the pnp-exposed functions to return null with builtins
* Various fixes & improvements
* Adds a test, prettier, fixes a test
* Don't iterate on the registries
* Renames YARN_PLUGNPLAY_EXPERIMENTAL into YARN_PLUGNPLAY_OVERRIDE
* Avoids touching the .pnp.js file when it doesn't need to change
* Reworks the cache path to contain the "node_modules/<pkg-name>" string
* Shims resolve#isCore
* Improves error messages
* Fixes the environment cast to allow passing false/0
* Implements a pnp blacklist settings
* Fixes the fallback resolution to use _resolveFilename instead of _finePath
* Fixes fallback relative path resolution
* Implements require.cache
* Prevents pnp from being enabled on Windows
* Removes absolute paths from the pnp files
* Implements a super basic offline cache integration
* feat(pnp): eject package command (#92)
* test(pnp): support ejecting packages
* feat(pnp): eject package command
* test(pnp): use fs.readdir instead of fs.readdirSync
* test(pnp): do not expect specific error message
* refactor(pnp): move eject logic to package linker
* fix(pnp): change ejected folder to .pnp/ejected/pkgName-pkgVersion/node_modules/pkgName
* fix(pnp): do not re-eject package
* test(pnp): do not rely on installConfig
* Fixes yarn bin
* Preserves the node_modules components in zip paths
* Fixes the offline cache
* Adds a VERSIONS field into the generated resolver
* Exposes the "extensions" option to "resolveRequest"
* Renames yarn eject into yarn unplug
* Tweaks yarn unplug
* Removes packageMainEntry from the package information
* Makes "unplug" print the list of unplugged packages
* Unplugs postinstall packages automatically
* Renames things
* Adds a warning on Windows to notify that PnP settings are ignored at the moment
* Fixes the default shebang
* Exports pnpapi
* Reworks the resolve shim to only affect liftoff
* Guards the pnp file against fs extensions
* Fixes the resolve shim
* Fixes a broken test
* Re-enables the focus tests
* Stops relying on bash for test scripts
* Fixes nohoist
* Revert "Fixes a broken test"
This reverts commit 84358aa507.
* Ensures that the getPackageInformation function returns an absolute path
The Webpack config for the modern build was adjusted recently to add a loader,
which is used as a workaround for a bug introduced by a recent dependency
update. The legacy config needed the same update.
The Webpack config was also updated in superficial ways to follow
recommendations made for migrating from Webpack v1 to v2 (e.g. using
`module.rules` instead of `module.loaders`). These changes should have no
functional impact, and should make migrating to future versions of Webpack
easier.
fix#6269
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->
**Summary**
Went down a rabbit hole with the formula, and noticed that the script wasn't updated.
<!-- Is the feature a substantial feature request? Please use https://github.com/yarnpkg/rfcs -->
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
**Test plan**
Not sure. @Daniel15 maybe has some thoughts?
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
**Summary**
This diff simply adds a script to easily generate the changelog between the current tag and the previous one.
**Test plan**
Manually ran `yarn changelog`.
**Summary**
This PR removes the custom Docker image we have and adds all node versions to CircleCI tests. The
aim is to levearge increased granularity and parallelism that the new CircleCI workflows provide.
**Test plan**
All new steps on CircleCI should pass.
**Summary**
Yarn 1.1.0 release failed due to a bug in npm@5:
https://github.com/npm/npm/issues/16723. This patch uses `npx` to
force using `np@4` when publishing in `update-npm.sh`.
**Test plan**
CircleCI
* Fix: always use origin/master instead of master for homebrew
**Summary**
Fixes#3415. The old homebrew update script updated the repo
from remote but did not update the local `master` branch, thus
had the potential for conflicts and mismatches. This patch
forces it to use `origin/master` instead and uses the latest
up-to-date version from the source.
**Test plan**
N/A
* Stay on master
**Summary**
We've been using `node -p -e` where `-e` is redundant since
it is implied by `-p`: https://nodejs.org/api/cli.html#cli_p_print_script
This patch removes those extra `-e`s.
**Test plan**
All bundles should build on CI without errors.
**Summary**
Resolves#4021
This fixes the workspace command so that it runs in the correct directory and adds a test to validate it.
Previously the command was also relying on `process.argv` to get the executable path for `node` and `yarn`. However, that ends up being unreliable if yarn was run as part of another process (aka `jest`).
**Test plan**
Added integration tests.
**Summary**
Fixes#3758. Makes the top-level folder in the tar archives have a name like `yarn-vX.Y.Z` instead of `dist` using the `--transform` and `-s` options in `tar` (they are different in GNU and BSD `tar`).
**Test plan**
Run `yarn build-dist` and then `tar -ztvf artifacts/yarn-v1.0.0.tar.gz`. Make sure the output lists all the files under `yarn-v1.0.0` directory.
**Summary**
Fixes#4057.
**Test plan**
CI should pass, especially with `build-dist` job.
Manual:
- Run `yarn build-dist`
- Run `node artifacts/yarn-0.28.0.js --version`
- Run `./dist/bin/yarn --version`
Make sure all above commands work without errors.
**Summary**
Refs #3524. We are using `process.exit()` pretty liberally although it is [strongly advised not to use it](https://nodejs.org/api/process.html#process_process_exit_code) since it may cause the `stdout` to get corrupted/terminated before a full flush. This patch changes all possible `process.exit(code)` calls with `process.exitCode = code` statements.
We'd also ideally enable [no-process-exit](http://eslint.org/docs/rules/no-process-exit) rule in ESLint but it requires an upgrade to ESLint v4 which should be handled separately.
**Test plan**
Expect tests to pass and actually finish (not run indefinitely due to `yarn` not exiting at all). Also, the script referenced in #3524 to output something like the following:
```
DATA 18
DATA 8192
DATA 8192
DATA 5392
DATA 15
EXIT 0
```
* Remove unneeded package.json fields from dist
We don't need dependencies and devDependencies in the package.json within the Yarn distributable, as the dependencies are bundled with Yarn itself. We also don't need "scripts" or "jest" as they're purely for development
* Add script for publishing to npm
* Add Jenkins job for publishing to npm
* add prettier and prettying everything
* fix scripts and run yarn prettier
* fix scripts again and run yarn prettier
* use eslint-plugin-prettify instead of custom scripts
Instead of always grabbing the Yarn version number from yarnpkg.com, allow it to be passed in as command line argument.
Updates Jenkins bump-version job to pass it in.
References https://github.com/yarnpkg/website/issues/471
Instead of including all the raw JS files in the dist tarball, just use the single Yarn JS file that's built as part of the build, along with a few other files that are required. This significantly reduces the number of files in the tarball:
```
C:\src\yarn\dist (bundle-as-dist) (yarn@0.23.0-0)
λ find .
.
./bin
./bin/node-gyp-bin
./bin/node-gyp-bin/node-gyp
./bin/node-gyp-bin/node-gyp.cmd
./bin/yarn
./bin/yarn.cmd
./bin/yarn.js
./bin/yarnpkg
./bin/yarnpkg.cmd
./lib
./lib/v8-compile-cache.js
./lib/yarn-cli.js
./LICENSE
./package.json
```
There are three .js files in the archive:
- `lib/v8-compile-cache.js`: Speeds up instantiation time by using the V8 code cache (https://www.npmjs.com/package/v8-compile-cache). This needs to be separate as it has to load **before** the bulk of the application code is loaded, so it can **not** be bundled
- `lib/yarn-cli.js`: Contains all the bundled Yarn code
- `bin/yarn.js`: Entry point to the app, just like today. Loads `v8-compile-cache` then loads `yarn-cli`
This change means that **only** the JavaScript files that are actually used are included, resulting in a nice file size reduction for the installation packages:

Differences are due to differing compression algorithms: Debian packages use xz or LZMA, RedHat uses gzip, Windows installer uses Cabinet
They're also slightly faster to extract:

Testing was performed on my desktop computer (Intel Core i5 6500, Samsung 850 Evo 1TB SSD, Windows 10), with testing for Linux stuff (like installing the Debian package) tested in a Docker container.
Raw data: https://docs.google.com/spreadsheets/d/1d8jdf3DU_GUFdotlPl08PkYa8SkzStK2tgnQ54ivsm0/edit?usp=sharing
Performance is very slightly faster when using `v8-compile-cache` along with the bundled file, but it's not extremely significant (`yarn --version` went from 0.19s to 0.14s on my BuyVM server). The difference might be bigger on servers with slower disks (HDD) or with more overloaded servers.
I also deleted the `build-dist.ps1` file because we _should_ be able to assume that Bash is available on Windows, particularly if Git is installed (as it comes with Git Bash). I need to verify that this works on AppVeyor.
Previously, packages named with `-loader` suffix could be specified as loaders within Webpack without requiring the suffix to be named explicitly. Webpack 2.1.0-beta.26 no longer looks for `-loader` suffix automatically, and packages have to therefore be named explicitly or `-loader` can be added to `resolveLoader.moduleExtensions`.
See: https://github.com/webpack/webpack/releases/tag/v2.1.0-beta.26
- Old versions of Mac OS (10.10 and below) require the `-t` option for `mktemp`
- The check for GPG wasn't returning correctly, and tried to run GPG even when not available
Closes#2012Closes#1984