diff --git a/.flowconfig b/.flowconfig index 522d3c0d306..ba6ee95f4f4 100644 --- a/.flowconfig +++ b/.flowconfig @@ -36,4 +36,4 @@ untyped-import untyped-type-import [version] -0.160.1 +0.161.0 diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 4c6b57a4cc5..7f2eeea9653 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -71,9 +71,11 @@ jobs: - target: arm-unknown-linux-gnueabihf arch: armhf strip: arm-linux-gnueabihf-strip + cflags: -mfpu=neon - target: aarch64-unknown-linux-gnu arch: arm64 strip: aarch64-linux-gnu-strip + cflags: '' name: ${{ matrix.target }} runs-on: ubuntu-latest steps: @@ -94,6 +96,7 @@ jobs: run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} + CFLAGS: ${{ matrix.cflags }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts @@ -119,8 +122,10 @@ jobs: include: - target: x86_64-unknown-linux-musl strip: strip + cflags: -msse4.2 - target: aarch64-unknown-linux-musl strip: aarch64-linux-musl-strip + cflags: '' name: ${{ matrix.target }} runs-on: ubuntu-latest container: @@ -150,6 +155,7 @@ jobs: run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} + CFLAGS: ${{ matrix.cflags }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 65c9ab23542..b6a34074dc5 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -70,9 +70,11 @@ jobs: - target: arm-unknown-linux-gnueabihf arch: armhf strip: arm-linux-gnueabihf-strip + cflags: -mfpu=neon - target: aarch64-unknown-linux-gnu arch: arm64 strip: aarch64-linux-gnu-strip + cflags: '' name: ${{ matrix.target }} runs-on: ubuntu-latest steps: @@ -93,6 +95,7 @@ jobs: run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} + CFLAGS: ${{ matrix.cflags }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts @@ -118,8 +121,10 @@ jobs: include: - target: x86_64-unknown-linux-musl strip: strip + cflags: -msse4.2 - target: aarch64-unknown-linux-musl strip: aarch64-linux-musl-strip + cflags: '' name: ${{ matrix.target }} runs-on: ubuntu-latest container: @@ -149,6 +154,7 @@ jobs: run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} + CFLAGS: ${{ matrix.cflags }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts diff --git a/.prettierrc b/.prettierrc index c957da40809..6e76d2a1a1e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,6 +3,7 @@ "endOfLine": "lf", "singleQuote": true, "trailingComma": "all", + "arrowParens": "avoid", "overrides": [ { "files": [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e80d0e87c..83415dcc280 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,38 @@ All notable changes to Parcel will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and Parcel adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.0.1] - 2021-11-08 + +### Fixed + +- Don't load PostCSS and PostHTML config when inside node_modules - [Details](https://github.com/parcel-bundler/parcel/pull/7088) +- Fix unknown language in Vue templates with external scripts/styles - [Details](https://github.com/parcel-bundler/parcel/pull/7056) +- Fix "Callback must be a function" error when auto installing - [Details](https://github.com/parcel-bundler/parcel/pull/7103) +- Fix issue with named imports and object properties of the same name - [Details](https://github.com/parcel-bundler/parcel/issues/7094) and [follow up](https://github.com/parcel-bundler/parcel/pull/7228) +- Bump SWC - [Details](https://github.com/parcel-bundler/parcel/pull/7114) +- Fix issue with `@tailwindcss/forms` and PostCSS nodes missing a `source` property - [Details](https://github.com/parcel-bundler/parcel/pull/7079) +- Fix issue with ESM default interop and `new` expressions - [Details](https://github.com/parcel-bundler/parcel/pull/7113) +- Support `.yml` for YAML files, in addition to `.yaml` - [Details](https://github.com/parcel-bundler/parcel/pull/7192) +- Log warning instead of crash if image optimizer fails - [Details](https://github.com/parcel-bundler/parcel/pull/7119) +- Add missing dependency to `@parcel/config-webextension` - [Details](https://github.com/parcel-bundler/parcel/pull/7193) +- Update package.json to include the repository - [Details](https://github.com/parcel-bundler/parcel/pull/7184) +- Fix serve mode with target override and target source fields [Details](https://github.com/parcel-bundler/parcel/pull/7187) +- Improve performance of webpack loader detection, which affected large data urls - [Details](https://github.com/parcel-bundler/parcel/pull/7226) +- Update SWC to properly retain `this` context - [Details](https://github.com/parcel-bundler/parcel/pull/7216) +- Sync `engines.parcel` with core version when releasing nightlies - [Details](https://github.com/parcel-bundler/parcel/pull/7207) +- Fix export in TypeScript type definitions for `@parcel/core` - [Details](https://github.com/parcel-bundler/parcel/pull/7250) +- Add missing dependency on `@parcel/diagnostic` to `@parcel/transformer-typescript-types` - [Details](https://github.com/parcel-bundler/parcel/pull/7248) +- Resolve GLSL relative to the importer, not the asset - [Details](https://github.com/parcel-bundler/parcel/pull/7263) + +### Experiments + +- Update esbuild dependency in `@parcel/optimizer-esbuild` plugin - [Details](https://github.com/parcel-bundler/parcel/pull/7233) +- Add experimental `@parcel/optimizer-swc` plugin - [Details](https://github.com/parcel-bundler/parcel/pull/7212) + +## [2.0.0] - 2021-10-13 + +See the [blog post](https://parceljs.org/blog/v2/). + ## [1.12.3] - 2019-03-20 - Downgrade all internal Babel packages to `<7.4.0` because of bugs in that release. diff --git a/Cargo.lock b/Cargo.lock index 5b8f28ade7b..cab5d85cbf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,9 +26,9 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "ahash" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom 0.2.3", "once_cell", @@ -67,9 +67,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "ast_node" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93f52ce8fac3d0e6720a92b0576d737c01b1b5db4dd786e962e5925f00bf755" +checksum = "e96d5444b02f3080edac8a144f6baf29b2fb6ff589ad4311559731a7c7529381" dependencies = [ "darling", "pmutil", @@ -137,9 +137,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.7.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" [[package]] name = "bytemuck" @@ -155,9 +155,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" dependencies = [ "jobserver", ] @@ -246,9 +246,9 @@ dependencies = [ [[package]] name = "crc" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10c2722795460108a7872e1cd933a85d6ec38abc4baecad51028f702da28889f" +checksum = "49fc9a695bca7f35f5f4c15cddc84415f66a74ea78eef08e90c5024f2b540e23" dependencies = [ "crc-catalog", ] @@ -452,15 +452,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.4" @@ -572,6 +563,15 @@ dependencies = [ "unindent", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "is-macro" version = "0.1.9" @@ -670,9 +670,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.101" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" +checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673" [[package]] name = "libdeflate-sys" @@ -701,6 +701,15 @@ dependencies = [ "cc", ] +[[package]] +name = "lock_api" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.14" @@ -761,9 +770,9 @@ dependencies = [ [[package]] name = "mozjpeg-sys" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2d207e7338a9a58abfc8a9d247bc9cc42a1b3eaa0a4e7014272825a00015a2" +checksum = "215a592d91abceb187028dfc6d9c07811bdfc5584d4ada50a4d387d82ed0aedc" dependencies = [ "cc", "dunce", @@ -785,15 +794,15 @@ dependencies = [ [[package]] name = "napi-build" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbe11972c601a48aa12a0e2aa032e9e251655ce6c6836cac26e5c0b3b5a5dcc" +checksum = "87375bacff0768dd606ccf870eae936efd21e3245af9e7b37ae44f969d48be8a" [[package]] name = "napi-derive" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7ed160148f94ee17936f00288029cb0cfb37c08bbace9f514f735dcd869ed7" +checksum = "4d57bc36513971ab3c60e5af84092662fb1b2fa686d0ef4aadab0d0fb6414bb9" dependencies = [ "proc-macro2", "quote", @@ -802,9 +811,9 @@ dependencies = [ [[package]] name = "napi-sys" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43563506c466587478849d80f46383d859b91bbec586580dadeb3639588f2f7e" +checksum = "67cf20e0081fea04e044aa4adf74cfea8ddc0324eec2894b1c700f4cafc72a56" [[package]] name = "nasm-rs" @@ -933,7 +942,7 @@ dependencies = [ "byteorder", "clap", "cloudflare-zlib", - "crc 2.0.0", + "crc 2.1.0", "crossbeam-channel", "filetime", "image", @@ -1023,6 +1032,37 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "path-clean" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" + [[package]] name = "path-slash" version = "0.1.4" @@ -1031,9 +1071,9 @@ checksum = "3cacbb3c4ff353b534a67fb8d7524d00229da4cb1dc8c79f4db96e375ab5b619" [[package]] name = "pathdiff" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877630b3de15c0b64cc52f659345724fbf6bdad9bd9566699fc53688f3c34a34" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "percent-encoding" @@ -1085,6 +1125,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + [[package]] name = "pmutil" version = "0.5.3" @@ -1110,9 +1156,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "precomputed-hash" @@ -1128,18 +1174,18 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] @@ -1248,19 +1294,25 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "retain_mut" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c17925a9027d298a4603d286befe3f9dc0e8ed02523141914eb628798d6e5b" +checksum = "448296241d034b96c11173591deaa1302f2c17b56092106c1f92c1bc0183a8c9" [[package]] name = "rgb" -version = "0.8.27" +version = "0.8.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fddb3b23626145d1776addfc307e1a1851f60ef6ca64f376bcb889697144cf0" +checksum = "a27fa03bb1e3e2941f52d4a555a395a72bf79b0a85fbbaab79447050c97d978c" dependencies = [ "bytemuck", ] +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -1371,9 +1423,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f9e390c27c3c0ce8bc5d725f6e4d30a29d26659494aa4b17535f7522c5c950" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", @@ -1401,9 +1453,9 @@ checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" [[package]] name = "smallvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "sourcemap" @@ -1470,12 +1522,13 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" +checksum = "923f0f39b6267d37d23ce71ae7235602134b250ace715dd2c90421998ddac0c6" dependencies = [ "lazy_static", "new_debug_unreachable", + "parking_lot", "phf_shared", "precomputed-hash", "serde", @@ -1520,9 +1573,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "swc_atoms" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "837a3ef86c2817228e733b6f173c821fd76f9eb21a0bc9001a826be48b00b4e7" +checksum = "9f5229fe227ff0060e13baa386d6e368797700eab909523f730008d191ee53ae" dependencies = [ "string_cache", "string_cache_codegen", @@ -1530,9 +1583,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.12.1" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0100bddbd0b5587223a862dedc9556715d066205e7e1954ca080567693923ee5" +checksum = "0c96fee6d6608c3022c455fd8a670ecb52f60c3a3ec4ea911ef0b173bd40dd1d" dependencies = [ "ahash", "ast_node", @@ -1540,11 +1593,10 @@ dependencies = [ "cfg-if 0.1.10", "either", "from_variant", - "fxhash", - "log", "num-bigint", "once_cell", "owning_ref", + "rustc-hash", "scoped-tls", "serde", "sourcemap", @@ -1552,15 +1604,16 @@ dependencies = [ "swc_eq_ignore_macros", "swc_visit", "termcolor", + "tracing", "unicode-width", "url", ] [[package]] name = "swc_ecma_ast" -version = "0.52.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa0efb0e13ba6545e2b86336937e1641594f78c48484b85c2dc9582eaccb41e1" +checksum = "a3a8d411060714c3fe2abbb15cddab1f78929d34409f47495eea77490694a52f" dependencies = [ "is-macro", "num-bigint", @@ -1572,25 +1625,28 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.70.2" +version = "0.78.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7940bff62e5caf62fe6732ce4f07e52c3c208cb58cd9299f7f7c92dddab2bf72" +checksum = "17f553750c724f1c35169c5821a507e3431e54ef6d60135affab84ca709ba3d6" dependencies = [ "bitflags", + "memchr", "num-bigint", + "once_cell", "sourcemap", "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_codegen_macros", "swc_ecma_parser", + "tracing", ] [[package]] name = "swc_ecma_codegen_macros" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51af418026cb4ea588e2b15fa206c44e09a3184b718e12a0919729c7c3ad20d3" +checksum = "bdbf826c739281cdb3b3c23883fd1a7586ea1c15b1287530e7123a7fad8f0e25" dependencies = [ "pmutil", "proc-macro2", @@ -1601,35 +1657,34 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.18.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f718f0335f9ab7437fecf9f3d73ae6a24c03a3d3f46910a68261703d407f03" +checksum = "8175736fa6f87725ee3736bb601d934444bd8b0e3b6b9032842fd0f189368e87" dependencies = [ + "ahash", "anyhow", "dashmap", - "fxhash", - "log", "normpath", "once_cell", + "path-clean", "serde", "serde_json", "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_visit", + "tracing", ] [[package]] name = "swc_ecma_parser" -version = "0.70.2" +version = "0.76.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "042a901352b84cefbb64916a010ee33f621a7e341ced2b2fa60035858f3146a5" +checksum = "f410fad7848bf376f31b621bde573858325d8127a71fbbe2d5effbe897420bb3" dependencies = [ "either", "enum_kind", - "fxhash", "lexical", - "log", "num-bigint", "serde", "smallvec", @@ -1637,17 +1692,19 @@ dependencies = [ "swc_common", "swc_ecma_ast", "swc_ecma_visit", + "tracing", + "typed-arena 2.0.1", "unicode-xid", ] [[package]] name = "swc_ecma_preset_env" -version = "0.42.1" +version = "0.63.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdb885d7b8ad47fb5f62cff0b36f61d6282b3548a566b8760a800c00de23679" +checksum = "fa3ac0ad38409e19ee9c55120fb20c16311978fa2746d425e21a704f837f6d5f" dependencies = [ + "ahash", "dashmap", - "fxhash", "indexmap", "once_cell", "semver 0.9.0", @@ -1666,9 +1723,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.71.1" +version = "0.92.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2124504a4203cab8f903b8e8be49dbd6c4bad2b0405ba0c8188f952c224c44b" +checksum = "20274f70994cacecf98728cffcc29f7e89bf9d72452ac7f912db72230b261451" dependencies = [ "swc_atoms", "swc_common", @@ -1688,11 +1745,10 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.31.1" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b26e191df68943565f22059d31b02967e60a62c4f76533b5b5106546785a8e2e" +checksum = "6d47323456ee73ecffa584a3964cc82dbf3daee2c7c72221d1f2130d3e42312d" dependencies = [ - "fxhash", "once_cell", "phf", "scoped-tls", @@ -1703,13 +1759,14 @@ dependencies = [ "swc_ecma_parser", "swc_ecma_utils", "swc_ecma_visit", + "tracing", ] [[package]] name = "swc_ecma_transforms_classes" -version = "0.17.1" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad5a845d5ec140ba8580c6b8d0f51ce417b86395a7b74c4280bb6cdae3c042c6" +checksum = "b26b5cc2e20bc232d366361a52347266b34443ec561bda7f2f00da83801a2e76" dependencies = [ "swc_atoms", "swc_common", @@ -1721,12 +1778,12 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "0.34.2" +version = "0.49.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda7278fdc9598ec43d40aa795ec7049532194bbcea861dd89bfe0ad3901446d" +checksum = "57a1f9555fcc50eb59d19dc0b4c7d95cbb771f0a3cb319c9f8cded0630569ba8" dependencies = [ + "ahash", "arrayvec", - "fxhash", "indexmap", "is-macro", "num-bigint", @@ -1745,9 +1802,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_macros" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7680ada61fa22c2164c3f32864efba31566710b503c30631ccc3b6f0fa800bc" +checksum = "18712e4aab969c6508dff3540ade6358f1e013464aa58b3d30da2ab2d9fcbbed" dependencies = [ "pmutil", "proc-macro2", @@ -1758,13 +1815,13 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "0.38.1" +version = "0.55.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79229bac86ac213d69c6d5957f9ee281979a9a7c6e5b94ca360a8a4429c6021" +checksum = "e10bbeb92d5a3d13b1d2c9e016d5735bd511c29ed199a7eb732aef868cb0f1e7" dependencies = [ "Inflector", + "ahash", "anyhow", - "fxhash", "indexmap", "pathdiff", "serde", @@ -1780,14 +1837,13 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.41.1" +version = "0.62.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2600bc3bd557353511cd90b336943ae30e8807bce989a420cb004953fb940a" +checksum = "804930bf18b7a467a0c309129ecdc7a07f378ffc0c6a963c6a0e592b4eeff53e" dependencies = [ + "ahash", "dashmap", - "fxhash", "indexmap", - "log", "once_cell", "retain_mut", "serde_json", @@ -1796,18 +1852,19 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_parser", "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", + "tracing", ] [[package]] name = "swc_ecma_transforms_proposal" -version = "0.38.1" +version = "0.55.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637093e49ee993b16fb7bf8918f3d409c986fc77850440a3c779de85d1442cfb" +checksum = "0cc9a9d26f33973ebc3f34d78551b3c4444c2bc1eeb89b2b376d08db7f73c649" dependencies = [ "either", - "fxhash", "serde", "smallvec", "swc_atoms", @@ -1816,16 +1873,18 @@ dependencies = [ "swc_ecma_parser", "swc_ecma_transforms_base", "swc_ecma_transforms_classes", + "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", ] [[package]] name = "swc_ecma_transforms_react" -version = "0.39.1" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18bf8799eb49b25f0632b9e60b7871b3f77e18fecb1972e4932ba08005b5c85f" +checksum = "174789f88a5df9c6c714eb174bb392d2eb5a0692e310ceca39816536d4157716" dependencies = [ + "ahash", "base64 0.13.0", "dashmap", "indexmap", @@ -1839,35 +1898,35 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_parser", "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", ] [[package]] name = "swc_ecma_transforms_typescript" -version = "0.40.2" +version = "0.58.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98099e3db58fb758715736ea9c8fa68d238e6527f0bfb4a3af0bf7ea063b9162" +checksum = "bf3fe7d40381ecf9e25039a82c5084a8d54ca8f143665a078ff077ef86940aec" dependencies = [ - "fxhash", "serde", "swc_atoms", "swc_common", "swc_ecma_ast", "swc_ecma_parser", "swc_ecma_transforms_base", + "swc_ecma_transforms_react", "swc_ecma_utils", "swc_ecma_visit", ] [[package]] name = "swc_ecma_utils" -version = "0.44.2" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c811bca37142f7fe21ce800784db1d537645762ffe8d8a52e2a7179d8cc1723" +checksum = "7c073f1cfbf53314e6c4b02cc2d19b96202d15ff8cd13cafb01331a3e645b39e" dependencies = [ "once_cell", - "scoped-tls", "swc_atoms", "swc_common", "swc_ecma_ast", @@ -1877,9 +1936,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.38.1" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c6721dfbcb8bea64383edb0d59ccb02bc1e140024f2e0f8766792a14f5f466" +checksum = "3839eb1dfad16550140d59462187de81fc536c53c53035a25fc40cbf01cc5042" dependencies = [ "num-bigint", "swc_atoms", @@ -1890,9 +1949,9 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "0.63.1" +version = "0.84.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba53c5582d6e5881b093ece9aaa4b561465afab0560abb19948f2c4bbff1bdb9" +checksum = "8ca7d514168991ecf5e548ff3eb4af82e810b4f50cfd0031e7ded90357cbfb02" dependencies = [ "swc_ecma_ast", "swc_ecma_codegen", @@ -1928,9 +1987,9 @@ dependencies = [ [[package]] name = "swc_visit" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a423caa0b4585118164dbad8f1ad52b592a9a9370b25decc4d84c6b4309132c0" +checksum = "f8511a4788ab29daf00bee23e425aac92c9be4eec74c98fec4a45d0e710be695" dependencies = [ "either", "swc_visit_macros", @@ -2000,9 +2059,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5241dd6f21443a3606b432718b166d3cedc962fd4b8bea54a8bc7f514ebda986" +checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" dependencies = [ "tinyvec_macros", ] @@ -2013,12 +2072,50 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tracing" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +dependencies = [ + "lazy_static", +] + [[package]] name = "typed-arena" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d" +[[package]] +name = "typed-arena" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae" + [[package]] name = "typenum" version = "1.14.0" @@ -2027,9 +2124,9 @@ checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "unicode-bidi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-normalization" @@ -2042,9 +2139,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" @@ -2214,5 +2311,5 @@ dependencies = [ "adler32", "byteorder", "crc 1.8.1", - "typed-arena", + "typed-arena 1.7.0", ] diff --git a/flow-libs/ansi-html.js.flow b/flow-libs/ansi-html.js.flow index a23ff90fed5..b07d088f115 100644 --- a/flow-libs/ansi-html.js.flow +++ b/flow-libs/ansi-html.js.flow @@ -1,5 +1,5 @@ // @flow -declare module 'ansi-html' { +declare module 'ansi-html-community' { declare module.exports: (input: string) => string; } diff --git a/flow-libs/posthtml.js.flow b/flow-libs/posthtml.js.flow index ed5df61a951..2aa63c44310 100644 --- a/flow-libs/posthtml.js.flow +++ b/flow-libs/posthtml.js.flow @@ -31,6 +31,8 @@ declare module 'posthtml' { ... }; + declare type PostHTMLExpression = $Shape | $Shape[] + declare var walk: (fn: (node: PostHTMLNode) => PostHTMLNode | PostHTMLNode[]) => void; declare var process: ( tree: PostHTMLTree | string, @@ -41,11 +43,13 @@ declare module 'posthtml' { messages: Array, ... }>; + declare var match: (expression: PostHTMLExpression, fn: (node: PostHTMLNode) => PostHTMLNode) => void; declare class Api { static walk: typeof walk; walk: typeof walk; process: typeof process; + match: typeof match; } declare class PostHTML extends Api { diff --git a/package.json b/package.json index 892dab33b71..925359a20f6 100644 --- a/package.json +++ b/package.json @@ -22,17 +22,16 @@ "unlink-all": "node scripts/unlink-all.js packages", "check": "flow check", "lint": "eslint . && prettier \"./packages/*/*/{src,bin,test}/**/*.{js,json,md}\" --list-different && cargo fmt --all -- --check", - "lint:readme": "node scripts/validate-readme-toc.js", - "prepublishOnly": "yarn build && yarn build-ts && node scripts/update-config-dependencies.js", + "prepublishOnly": "yarn build && yarn build-ts && yarn adjust-versions", "test:unit": "cross-env NODE_ENV=test mocha", "test:integration": "yarn workspace @parcel/integration-tests test", "test:integration-ci": "yarn workspace @parcel/integration-tests test-ci", "test": "yarn test:unit && yarn test:integration", - "update-readme-toc": "doctoc README.md", "nightly:release": "lerna publish -y --canary --preid nightly --dist-tag=nightly --exact --force-publish=* --no-git-tag-version --no-push", - "tag:prerelease": "lerna version --exact --force-publish=* --no-git-tag-version --no-push && node scripts/update-config-dependencies.js", - "tag:release": "lerna version --force-publish=* --no-git-tag-version --no-push && node scripts/update-config-dependencies.js", - "release": "lerna publish -y from-package --dist-tag=next --no-git-tag-version --no-push", + "tag:prerelease": "lerna version --exact --force-publish=* --no-git-tag-version --no-push && yarn adjust-versions --exact", + "tag:release": "lerna version --force-publish=* --no-git-tag-version --no-push && yarn adjust-versions", + "adjust-versions": "node scripts/update-config-dependencies.js && node scripts/update-engines.js", + "release": "lerna publish -y from-package --pre-dist-tag=next --no-git-tag-version --no-push", "prepare": "husky install" }, "devDependencies": { @@ -41,9 +40,8 @@ "@napi-rs/cli": "1.0.4", "@types/node": "^15.12.4", "cross-env": "^7.0.0", - "doctoc": "^1.4.0", "eslint": "^7.20.0", - "flow-bin": "0.160.1", + "flow-bin": "0.161.0", "glob": "^7.1.6", "gulp": "^4.0.2", "gulp-babel": "^8.0.0", @@ -53,7 +51,7 @@ "mocha": "^8.3.0", "mocha-junit-reporter": "^2.0.0", "mocha-multi-reporters": "^1.5.1", - "prettier": "1.19.1", + "prettier": "2.4.1", "rimraf": "^2.6.3", "semver": "^5.4.1", "sinon": "^7.3.1" diff --git a/packages/bundlers/default/package.json b/packages/bundlers/default/package.json index bb686466d3c..832adbfb4ee 100644 --- a/packages/bundlers/default/package.json +++ b/packages/bundlers/default/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/bundler-default", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,13 +17,13 @@ "source": "src/DefaultBundler.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/hash": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/hash": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "nullthrows": "^1.1.1" } } diff --git a/packages/bundlers/default/src/DefaultBundler.js b/packages/bundlers/default/src/DefaultBundler.js index c7c834b4e8e..aa3a00320a6 100644 --- a/packages/bundlers/default/src/DefaultBundler.js +++ b/packages/bundlers/default/src/DefaultBundler.js @@ -246,9 +246,8 @@ export default (new Bundler({ ); for (let candidate of candidates) { - let bundleGroups = bundleGraph.getBundleGroupsContainingBundle( - candidate, - ); + let bundleGroups = + bundleGraph.getBundleGroupsContainingBundle(candidate); if ( Array.from(bundleGroups).every( group => diff --git a/packages/compressors/brotli/package.json b/packages/compressors/brotli/package.json index e295cbcf171..da5c760c86a 100644 --- a/packages/compressors/brotli/package.json +++ b/packages/compressors/brotli/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/compressor-brotli", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,9 +17,9 @@ "source": "src/BrotliCompressor.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/compressors/gzip/package.json b/packages/compressors/gzip/package.json index c0659f8d69a..d4e0204fb19 100644 --- a/packages/compressors/gzip/package.json +++ b/packages/compressors/gzip/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/compressor-gzip", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,9 +17,9 @@ "source": "src/GzipCompressor.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/compressors/raw/package.json b/packages/compressors/raw/package.json index 9d73543c7a8..70c64b029b0 100644 --- a/packages/compressors/raw/package.json +++ b/packages/compressors/raw/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/compressor-raw", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,9 +17,9 @@ "source": "src/RawCompressor.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/configs/default/index.json b/packages/configs/default/index.json index 4c3da0c9b3f..bda82bd3089 100644 --- a/packages/configs/default/index.json +++ b/packages/configs/default/index.json @@ -18,7 +18,7 @@ "*.toml": ["@parcel/transformer-toml"], "*.webmanifest": ["@parcel/transformer-webmanifest"], "webmanifest:*.{json,webmanifest}": ["@parcel/transformer-webmanifest"], - "*.yaml": ["@parcel/transformer-yaml"], + "*.{yaml,yml}": ["@parcel/transformer-yaml"], "*.{glsl,vert,frag}": ["@parcel/transformer-glsl"], "*.{gql,graphql}": ["@parcel/transformer-graphql"], "*.{styl,stylus}": ["@parcel/transformer-stylus"], @@ -26,7 +26,7 @@ "*.less": ["@parcel/transformer-less"], "*.{css,pcss}": ["@parcel/transformer-postcss", "@parcel/transformer-css"], "*.sss": ["@parcel/transformer-sugarss"], - "*.{htm,html}": [ + "*.{htm,html,xhtml}": [ "@parcel/transformer-posthtml", "@parcel/transformer-html" ], @@ -41,6 +41,7 @@ "custom:*.vue": ["@parcel/transformer-vue"], "*.{png,jpg,jpeg,webp}": ["@parcel/transformer-image"], "*.svg": ["@parcel/transformer-svg"], + "*.{xml,rss,atom}": ["@parcel/transformer-xml"], "url:*": ["...", "@parcel/transformer-raw"] }, "namers": ["@parcel/namer-default"], @@ -53,16 +54,17 @@ "optimizers": { "data-url:*": ["...", "@parcel/optimizer-data-url"], "*.css": ["@parcel/optimizer-cssnano"], - "*.html": ["@parcel/optimizer-htmlnano"], + "*.{html,xhtml}": ["@parcel/optimizer-htmlnano"], "*.{js,mjs,cjs}": ["@parcel/optimizer-terser"], "*.svg": ["@parcel/optimizer-svgo"], "*.{jpg,jpeg,png}": ["@parcel/optimizer-image"] }, "packagers": { - "*.html": "@parcel/packager-html", + "*.{html,xhtml}": "@parcel/packager-html", "*.css": "@parcel/packager-css", "*.{js,mjs,cjs}": "@parcel/packager-js", "*.svg": "@parcel/packager-svg", + "*.{xml,rss,atom}": "@parcel/packager-xml", "*.ts": "@parcel/packager-ts", "*.{jsonld,svg,webmanifest}": "@parcel/packager-raw-url", "*": "@parcel/packager-raw" diff --git a/packages/configs/default/package.json b/packages/configs/default/package.json index d09148de533..8d3fe1f3f16 100644 --- a/packages/configs/default/package.json +++ b/packages/configs/default/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/config-default", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -18,61 +18,63 @@ "test-ci": "mocha" }, "dependencies": { - "@parcel/bundler-default": "2.0.0-rc.0", - "@parcel/compressor-raw": "2.0.0-rc.0", - "@parcel/namer-default": "2.0.0-rc.0", - "@parcel/optimizer-cssnano": "2.0.0-rc.0", - "@parcel/optimizer-htmlnano": "2.0.0-rc.0", - "@parcel/optimizer-image": "2.0.0-rc.0", - "@parcel/optimizer-svgo": "2.0.0-rc.0", - "@parcel/optimizer-terser": "2.0.0-rc.0", - "@parcel/packager-css": "2.0.0-rc.0", - "@parcel/packager-html": "2.0.0-rc.0", - "@parcel/packager-js": "2.0.0-rc.0", - "@parcel/packager-raw": "2.0.0-rc.0", - "@parcel/packager-svg": "2.0.0-rc.0", - "@parcel/reporter-dev-server": "2.0.0-rc.0", - "@parcel/resolver-default": "2.0.0-rc.0", - "@parcel/runtime-browser-hmr": "2.0.0-rc.0", - "@parcel/runtime-js": "2.0.0-rc.0", - "@parcel/runtime-react-refresh": "2.0.0-rc.0", - "@parcel/runtime-service-worker": "2.0.0-rc.0", - "@parcel/transformer-babel": "2.0.0-rc.0", - "@parcel/transformer-css": "2.0.0-rc.0", - "@parcel/transformer-html": "2.0.0-rc.0", - "@parcel/transformer-image": "2.0.0-rc.0", - "@parcel/transformer-js": "2.0.0-rc.0", - "@parcel/transformer-json": "2.0.0-rc.0", - "@parcel/transformer-postcss": "2.0.0-rc.0", - "@parcel/transformer-posthtml": "2.0.0-rc.0", - "@parcel/transformer-raw": "2.0.0-rc.0", - "@parcel/transformer-react-refresh-wrap": "2.0.0-rc.0", - "@parcel/transformer-svg": "2.0.0-rc.0" + "@parcel/bundler-default": "^2.0.1", + "@parcel/compressor-raw": "^2.0.1", + "@parcel/namer-default": "^2.0.1", + "@parcel/optimizer-cssnano": "^2.0.1", + "@parcel/optimizer-htmlnano": "^2.0.1", + "@parcel/optimizer-image": "^2.0.1", + "@parcel/optimizer-svgo": "^2.0.1", + "@parcel/optimizer-terser": "^2.0.1", + "@parcel/packager-css": "^2.0.1", + "@parcel/packager-html": "^2.0.1", + "@parcel/packager-js": "^2.0.1", + "@parcel/packager-raw": "^2.0.1", + "@parcel/packager-svg": "^2.0.1", + "@parcel/reporter-dev-server": "^2.0.1", + "@parcel/resolver-default": "^2.0.1", + "@parcel/runtime-browser-hmr": "^2.0.1", + "@parcel/runtime-js": "^2.0.1", + "@parcel/runtime-react-refresh": "^2.0.1", + "@parcel/runtime-service-worker": "^2.0.1", + "@parcel/transformer-babel": "^2.0.1", + "@parcel/transformer-css": "^2.0.1", + "@parcel/transformer-html": "^2.0.1", + "@parcel/transformer-image": "^2.0.1", + "@parcel/transformer-js": "^2.0.1", + "@parcel/transformer-json": "^2.0.1", + "@parcel/transformer-postcss": "^2.0.1", + "@parcel/transformer-posthtml": "^2.0.1", + "@parcel/transformer-raw": "^2.0.1", + "@parcel/transformer-react-refresh-wrap": "^2.0.1", + "@parcel/transformer-svg": "^2.0.1" }, "parcelDependencies": { - "@parcel/optimizer-data-url": "2.0.0-rc.0", - "@parcel/packager-raw-url": "2.0.0-rc.0", - "@parcel/packager-ts": "2.0.0-rc.0", - "@parcel/transformer-coffeescript": "2.0.0-rc.0", - "@parcel/transformer-elm": "2.0.0-rc.0", - "@parcel/transformer-glsl": "2.0.0-rc.0", - "@parcel/transformer-graphql": "2.0.0-rc.0", - "@parcel/transformer-inline-string": "2.0.0-rc.0", - "@parcel/transformer-jsonld": "2.0.0-rc.0", - "@parcel/transformer-less": "2.0.0-rc.0", - "@parcel/transformer-mdx": "2.0.0-rc.0", - "@parcel/transformer-pug": "2.0.0-rc.0", - "@parcel/transformer-sass": "2.0.0-rc.0", - "@parcel/transformer-stylus": "2.0.0-rc.0", - "@parcel/transformer-sugarss": "2.0.0-rc.0", - "@parcel/transformer-toml": "2.0.0-rc.0", - "@parcel/transformer-typescript-types": "2.0.0-rc.0", - "@parcel/transformer-vue": "2.0.0-rc.0", - "@parcel/transformer-webmanifest": "2.0.0-rc.0", - "@parcel/transformer-worklet": "2.0.0-rc.0", - "@parcel/transformer-yaml": "2.0.0-rc.0" + "@parcel/optimizer-data-url": "^2.0.1", + "@parcel/packager-raw-url": "^2.0.1", + "@parcel/packager-ts": "^2.0.1", + "@parcel/packager-xml": "^2.0.1", + "@parcel/transformer-coffeescript": "^2.0.1", + "@parcel/transformer-elm": "^2.0.1", + "@parcel/transformer-glsl": "^2.0.1", + "@parcel/transformer-graphql": "^2.0.1", + "@parcel/transformer-inline-string": "^2.0.1", + "@parcel/transformer-jsonld": "^2.0.1", + "@parcel/transformer-less": "^2.0.1", + "@parcel/transformer-mdx": "^2.0.1", + "@parcel/transformer-pug": "^2.0.1", + "@parcel/transformer-sass": "^2.0.1", + "@parcel/transformer-stylus": "^2.0.1", + "@parcel/transformer-sugarss": "^2.0.1", + "@parcel/transformer-toml": "^2.0.1", + "@parcel/transformer-typescript-types": "^2.0.1", + "@parcel/transformer-vue": "^2.0.1", + "@parcel/transformer-webmanifest": "^2.0.1", + "@parcel/transformer-worklet": "^2.0.1", + "@parcel/transformer-xml": "^2.0.1", + "@parcel/transformer-yaml": "^2.0.1" }, "peerDependencies": { - "@parcel/core": "^2.0.0-alpha.3.1" + "@parcel/core": "^2.0.0" } } diff --git a/packages/configs/webextension/package.json b/packages/configs/webextension/package.json index 35510b7276b..cea27e410fa 100644 --- a/packages/configs/webextension/package.json +++ b/packages/configs/webextension/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/config-webextension", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -15,8 +15,9 @@ }, "main": "index.json", "dependencies": { - "@parcel/config-default": "2.0.0-rc.0", - "@parcel/packager-raw-url": "2.0.0-rc.0", - "@parcel/transformer-webextension": "2.0.0-rc.0" + "@parcel/config-default": "^2.0.1", + "@parcel/packager-raw-url": "^2.0.1", + "@parcel/transformer-raw": "^2.0.1", + "@parcel/transformer-webextension": "^2.0.1" } } diff --git a/packages/core/cache/package.json b/packages/core/cache/package.json index a45582465a1..eba2385b63b 100644 --- a/packages/core/cache/package.json +++ b/packages/core/cache/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/cache", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -24,11 +24,11 @@ "check-ts": "tsc --noEmit index.d.ts" }, "dependencies": { - "@parcel/logger": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/logger": "^2.0.1", + "@parcel/utils": "^2.0.1", "lmdb-store": "^1.5.5" }, "peerDependencies": { - "@parcel/core": "^2.0.0-alpha.3.1" + "@parcel/core": "^2.0.0" } } diff --git a/packages/core/codeframe/package.json b/packages/core/codeframe/package.json index 998eca24d1a..41c70669234 100644 --- a/packages/core/codeframe/package.json +++ b/packages/core/codeframe/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/codeframe", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { diff --git a/packages/core/codeframe/src/codeframe.js b/packages/core/codeframe/src/codeframe.js index 5f60794a376..3eca8729395 100644 --- a/packages/core/codeframe/src/codeframe.js +++ b/packages/core/codeframe/src/codeframe.js @@ -121,9 +121,8 @@ export default function codeFrame( // Split input into lines and highlight syntax let lines = code.split(NEWLINE); - let syntaxHighlightedLines = (opts.syntaxHighlighting - ? highlightSyntax(code, opts.language) - : code + let syntaxHighlightedLines = ( + opts.syntaxHighlighting ? highlightSyntax(code, opts.language) : code ) .replace(TAB_REPLACE_REGEX, TAB_REPLACEMENT) .split(NEWLINE); diff --git a/packages/core/core/index.d.ts b/packages/core/core/index.d.ts index 5da6802752e..ae736883951 100644 --- a/packages/core/core/index.d.ts +++ b/packages/core/core/index.d.ts @@ -2,7 +2,7 @@ import type {InitialParcelOptions, BuildEvent, BuildSuccessEvent, AsyncSubscript import type {FarmOptions} from '@parcel/workers'; import type WorkerFarm from '@parcel/workers'; -export default class Parcel { +export class Parcel { constructor(options: InitialParcelOptions); run(): Promise; watch( @@ -11,3 +11,5 @@ export default class Parcel { } export declare function createWorkerFarm(options?: Partial): WorkerFarm; + +export default Parcel; diff --git a/packages/core/core/package.json b/packages/core/core/package.json index bd76f26b6d5..a8b05139a88 100644 --- a/packages/core/core/package.json +++ b/packages/core/core/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/core", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -24,19 +24,19 @@ "check-ts": "tsc --noEmit index.d.ts" }, "dependencies": { - "@parcel/cache": "2.0.0-rc.0", - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/events": "2.0.0-rc.0", - "@parcel/fs": "2.0.0-rc.0", - "@parcel/graph": "2.0.0-rc.0", - "@parcel/hash": "2.0.0-rc.0", - "@parcel/logger": "2.0.0-rc.0", - "@parcel/package-manager": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", - "@parcel/types": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", - "@parcel/workers": "2.0.0-rc.0", + "@parcel/cache": "^2.0.1", + "@parcel/diagnostic": "^2.0.1", + "@parcel/events": "^2.0.1", + "@parcel/fs": "^2.0.1", + "@parcel/graph": "^2.0.1", + "@parcel/hash": "^2.0.1", + "@parcel/logger": "^2.0.1", + "@parcel/package-manager": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "@parcel/types": "^2.0.1", + "@parcel/utils": "^2.0.1", + "@parcel/workers": "^2.0.1", "abortcontroller-polyfill": "^1.1.9", "base-x": "^3.0.8", "browserslist": "^4.6.6", @@ -47,7 +47,6 @@ "json5": "^1.0.1", "micromatch": "^4.0.2", "nullthrows": "^1.1.1", - "querystring": "^0.2.0", "semver": "^5.4.1" }, "devDependencies": { diff --git a/packages/core/core/src/AssetGraph.js b/packages/core/core/src/AssetGraph.js index a35eaa6e06c..5f749e6f208 100644 --- a/packages/core/core/src/AssetGraph.js +++ b/packages/core/core/src/AssetGraph.js @@ -24,7 +24,7 @@ import type { import invariant from 'assert'; import {hashString, Hash} from '@parcel/hash'; -import {hashObject, objectSortedEntries} from '@parcel/utils'; +import {hashObject} from '@parcel/utils'; import nullthrows from 'nullthrows'; import {ContentGraph} from '@parcel/graph'; import {createDependency} from './Dependency'; @@ -44,6 +44,7 @@ type AssetGraphOpts = {| type SerializedAssetGraph = {| ...SerializedContentGraph, hash?: ?string, + symbolPropagationRan: boolean, |}; export function nodeFromDep(dep: Dependency): DependencyNode { @@ -72,9 +73,7 @@ export function nodeFromAssetGroup(assetGroup: AssetGroup): AssetGroupNode { ':' + (assetGroup.pipeline ?? '') + ':' + - (assetGroup.query - ? JSON.stringify(objectSortedEntries(assetGroup.query)) - : ''), + (assetGroup.query ?? ''), ), type: 'asset_group', value: assetGroup, @@ -113,12 +112,14 @@ export default class AssetGraph extends ContentGraph { onNodeRemoved: ?(nodeId: NodeId) => mixed; hash: ?string; envCache: Map; + symbolPropagationRan: boolean; constructor(opts: ?AssetGraphOpts) { if (opts) { - let {hash, ...rest} = opts; + let {hash, symbolPropagationRan, ...rest} = opts; super(rest); this.hash = hash; + this.symbolPropagationRan = symbolPropagationRan; } else { super(); this.setRootNodeId( @@ -130,6 +131,7 @@ export default class AssetGraph extends ContentGraph { ); } this.envCache = new Map(); + this.symbolPropagationRan = false; } // $FlowFixMe[prop-missing] @@ -142,6 +144,7 @@ export default class AssetGraph extends ContentGraph { return { ...super.serialize(), hash: this.hash, + symbolPropagationRan: this.symbolPropagationRan, }; } @@ -308,17 +311,21 @@ export default class AssetGraph extends ContentGraph { ) { return true; } - - let {sideEffects, canDefer = true} = childNode.value; - let dependency = node.value; - let previouslyDeferred = childNode.deferred; + // Node types are proved above + let dependencyNode = node; + let assetGroupNode = childNode; + + let {sideEffects, canDefer = true} = assetGroupNode.value; + let dependency = dependencyNode.value; + let dependencyPreviouslyDeferred = dependencyNode.hasDeferred; + let assetGroupPreviouslyDeferred = assetGroupNode.deferred; let defer = this.shouldDeferDependency(dependency, sideEffects, canDefer); - node.hasDeferred = defer; - childNode.deferred = defer; + dependencyNode.hasDeferred = defer; + assetGroupNode.deferred = defer; - if (!previouslyDeferred && defer) { + if (!dependencyPreviouslyDeferred && defer) { this.markParentsWithHasDeferred(nodeId); - } else if (previouslyDeferred && !defer) { + } else if (assetGroupPreviouslyDeferred && !defer) { this.unmarkParentsWithHasDeferred(childNodeId); } diff --git a/packages/core/core/src/BundleGraph.js b/packages/core/core/src/BundleGraph.js index 9207b26dfef..6621f520fe6 100644 --- a/packages/core/core/src/BundleGraph.js +++ b/packages/core/core/src/BundleGraph.js @@ -11,7 +11,6 @@ import type { NodeId, SerializedContentGraph, } from '@parcel/graph'; -import querystring from 'querystring'; import type { Asset, @@ -91,6 +90,7 @@ type SerializedBundleGraph = {| bundleContentHashes: Map, assetPublicIds: Set, publicIdByAssetId: Map, + symbolPropagationRan: boolean, |}; function makeReadOnlySet(set: Set): $ReadOnlySet { @@ -117,22 +117,26 @@ export default class BundleGraph { _bundleContentHashes: Map; _targetEntryRoots: Map = new Map(); _graph: ContentGraph; + _symbolPropagationRan /*: boolean*/; constructor({ graph, publicIdByAssetId, assetPublicIds, bundleContentHashes, + symbolPropagationRan, }: {| graph: ContentGraph, publicIdByAssetId: Map, assetPublicIds: Set, bundleContentHashes: Map, + symbolPropagationRan: boolean, |}) { this._graph = graph; this._assetPublicIds = assetPublicIds; this._publicIdByAssetId = publicIdByAssetId; this._bundleContentHashes = bundleContentHashes; + this._symbolPropagationRan = symbolPropagationRan; } static fromAssetGraph( @@ -215,6 +219,7 @@ export default class BundleGraph { assetPublicIds, bundleContentHashes: new Map(), publicIdByAssetId, + symbolPropagationRan: assetGraph.symbolPropagationRan, }); } @@ -225,6 +230,7 @@ export default class BundleGraph { assetPublicIds: this._assetPublicIds, bundleContentHashes: this._bundleContentHashes, publicIdByAssetId: this._publicIdByAssetId, + symbolPropagationRan: this._symbolPropagationRan, }; } @@ -234,6 +240,7 @@ export default class BundleGraph { assetPublicIds: serialized.assetPublicIds, bundleContentHashes: serialized.bundleContentHashes, publicIdByAssetId: serialized.publicIdByAssetId, + symbolPropagationRan: serialized.symbolPropagationRan, }); } @@ -1500,16 +1507,18 @@ export default class BundleGraph { let hash = new Hash(); // TODO: sort?? this.traverseAssets(bundle, asset => { - hash.writeString( - [ - this.getAssetPublicId(asset), - asset.outputHash, - asset.filePath, - querystring.stringify(asset.query), - asset.type, - asset.uniqueKey, - ].join(':'), - ); + { + hash.writeString( + [ + this.getAssetPublicId(asset), + asset.outputHash, + asset.filePath, + asset.query, + asset.type, + asset.uniqueKey, + ].join(':'), + ); + } }); let hashHex = hash.finish(); @@ -1610,16 +1619,20 @@ export default class BundleGraph { } } - getUsedSymbolsAsset(asset: Asset): $ReadOnlySet { + getUsedSymbolsAsset(asset: Asset): ?$ReadOnlySet { let node = this._graph.getNodeByContentKey(asset.id); invariant(node && node.type === 'asset'); - return makeReadOnlySet(node.usedSymbols); + return this._symbolPropagationRan + ? makeReadOnlySet(node.usedSymbols) + : null; } - getUsedSymbolsDependency(dep: Dependency): $ReadOnlySet { + getUsedSymbolsDependency(dep: Dependency): ?$ReadOnlySet { let node = this._graph.getNodeByContentKey(dep.id); invariant(node && node.type === 'dependency'); - return makeReadOnlySet(node.usedSymbolsUp); + return this._symbolPropagationRan + ? makeReadOnlySet(node.usedSymbolsUp) + : null; } merge(other: BundleGraph) { diff --git a/packages/core/core/src/Environment.js b/packages/core/core/src/Environment.js index 0833f653050..733485f2f48 100644 --- a/packages/core/core/src/Environment.js +++ b/packages/core/core/src/Environment.js @@ -131,6 +131,7 @@ function getEnvironmentHash(env: Environment): string { env.outputFormat, env.sourceType, env.isLibrary, + env.shouldOptimize, env.shouldScopeHoist, env.sourceMap, ]), diff --git a/packages/core/core/src/PackagerRunner.js b/packages/core/core/src/PackagerRunner.js index a6d0c33d00d..c062edc9da4 100644 --- a/packages/core/core/src/PackagerRunner.js +++ b/packages/core/core/src/PackagerRunner.js @@ -563,7 +563,8 @@ export default class PackagerRunner { invalidationHash + bundle.target.publicUrl + bundleGraph.getHash(bundle) + - JSON.stringify(configResults), + JSON.stringify(configResults) + + this.options.mode, ); } @@ -588,9 +589,7 @@ export default class PackagerRunner { return devDepHashes; } - async readFromCache( - cacheKey: string, - ): Promise { diff --git a/packages/core/core/src/Parcel.js b/packages/core/core/src/Parcel.js index 70b3b24d79f..60d7a2cbb2d 100644 --- a/packages/core/core/src/Parcel.js +++ b/packages/core/core/src/Parcel.js @@ -109,10 +109,8 @@ export default class Parcel { await resolvedOptions.cache.ensure(); - let { - dispose: disposeOptions, - ref: optionsRef, - } = await this.#farm.createSharedReference(resolvedOptions); + let {dispose: disposeOptions, ref: optionsRef} = + await this.#farm.createSharedReference(resolvedOptions); this.#optionsRef = optionsRef; this.#disposable = new Disposable(); @@ -268,12 +266,8 @@ export default class Parcel { signal, }); - let { - bundleGraph, - bundleInfo, - changedAssets, - assetRequests, - } = await this.#requestTracker.runRequest(request, {force: true}); + let {bundleGraph, bundleInfo, changedAssets, assetRequests} = + await this.#requestTracker.runRequest(request, {force: true}); this.#requestedAssetIds.clear(); diff --git a/packages/core/core/src/ParcelConfig.js b/packages/core/core/src/ParcelConfig.js index 6650485bcf8..2ace49e0344 100644 --- a/packages/core/core/src/ParcelConfig.js +++ b/packages/core/core/src/ParcelConfig.js @@ -116,9 +116,7 @@ export default class ParcelConfig { }; } - _loadPlugin( - node: ParcelPluginNode, - ): Promise<{| + _loadPlugin(node: ParcelPluginNode): Promise<{| plugin: T, version: Semver, resolveFrom: ProjectPath, @@ -179,9 +177,8 @@ export default class ParcelConfig { } getValidatorNames(filePath: ProjectPath): Array { - let validators: PureParcelConfigPipeline = this._getValidatorNodes( - filePath, - ); + let validators: PureParcelConfigPipeline = + this._getValidatorNodes(filePath); return validators.map(v => v.packageName); } @@ -203,11 +200,8 @@ export default class ParcelConfig { pipeline?: ?string, allowEmpty?: boolean, ): Promise>>> { - let transformers: PureParcelConfigPipeline | null = this.matchGlobMapPipelines( - filePath, - this.transformers, - pipeline, - ); + let transformers: PureParcelConfigPipeline | null = + this.matchGlobMapPipelines(filePath, this.transformers, pipeline); if (!transformers || transformers.length === 0) { if (allowEmpty) { return []; diff --git a/packages/core/core/src/RequestTracker.js b/packages/core/core/src/RequestTracker.js index 41def55de58..98f729b30d7 100644 --- a/packages/core/core/src/RequestTracker.js +++ b/packages/core/core/src/RequestTracker.js @@ -799,9 +799,10 @@ export default class RequestTracker { this.signal = signal; } - startRequest( - request: StoredRequest, - ): {|requestNodeId: NodeId, deferred: Deferred|} { + startRequest(request: StoredRequest): {| + requestNodeId: NodeId, + deferred: Deferred, + |} { let didPreviouslyExist = this.graph.hasContentKey(request.id); let requestNodeId; if (didPreviouslyExist) { @@ -1032,7 +1033,7 @@ export default class RequestTracker { } async writeToCache() { - let cacheKey = `${PARCEL_VERSION}:${JSON.stringify(this.options.entries)}`; + let cacheKey = getCacheKey(this.options); let requestGraphKey = hashString(`${cacheKey}:requestGraph`); let snapshotKey = hashString(`${cacheKey}:snapshot`); @@ -1088,12 +1089,16 @@ export function getWatcherOptions(options: ParcelOptions): WatcherOptions { return {ignore}; } +function getCacheKey(options) { + return `${PARCEL_VERSION}:${JSON.stringify(options.entries)}:${options.mode}`; +} + async function loadRequestGraph(options): Async { if (options.shouldDisableCache) { return new RequestGraph(); } - let cacheKey = `${PARCEL_VERSION}:${JSON.stringify(options.entries)}`; + let cacheKey = getCacheKey(options); let requestGraphKey = hashString(`${cacheKey}:requestGraph`); let requestGraph = await options.cache.get(requestGraphKey); diff --git a/packages/core/core/src/Transformation.js b/packages/core/core/src/Transformation.js index 4511843dc92..bdd18698f51 100644 --- a/packages/core/core/src/Transformation.js +++ b/packages/core/core/src/Transformation.js @@ -24,7 +24,6 @@ import type {LoadedPlugin} from './ParcelConfig'; import path from 'path'; import {Readable} from 'stream'; import nullthrows from 'nullthrows'; -import {objectSortedEntries} from '@parcel/utils'; import logger, {PluginLogger} from '@parcel/logger'; import ThrowableDiagnostic, { errorToDiagnostic, @@ -561,7 +560,7 @@ export default class Transformation { a.value.pipeline, a.value.hash, a.value.uniqueKey, - a.value.query ? JSON.stringify(objectSortedEntries(a.value.query)) : '', + a.value.query ?? '', ]) .join(''); diff --git a/packages/core/core/src/applyRuntimes.js b/packages/core/core/src/applyRuntimes.js index fcd2a9a6707..34cc00e0cc5 100644 --- a/packages/core/core/src/applyRuntimes.js +++ b/packages/core/core/src/applyRuntimes.js @@ -4,6 +4,7 @@ import type {ContentKey} from '@parcel/graph'; import type {Dependency, NamedBundle as INamedBundle} from '@parcel/types'; import type {SharedReference} from '@parcel/workers'; import type { + Asset, AssetGroup, Bundle as InternalBundle, Config, @@ -18,7 +19,7 @@ import path from 'path'; import assert from 'assert'; import invariant from 'assert'; import nullthrows from 'nullthrows'; -import AssetGraph, {nodeFromAssetGroup} from './AssetGraph'; +import {nodeFromAssetGroup} from './AssetGraph'; import BundleGraph from './public/BundleGraph'; import InternalBundleGraph, {bundleGraphEdgeTypes} from './BundleGraph'; import {NamedBundle} from './public/Bundle'; @@ -58,7 +59,7 @@ export default async function applyRuntimes({ previousDevDeps: Map, devDepRequests: Map, configs: Map, -|}): Promise { +|}): Promise> { let runtimes = await config.getRuntimes(); let connections: Array = []; @@ -137,11 +138,8 @@ export default async function applyRuntimes({ await runDevDepRequest(api, devDepRequest); } - let runtimesAssetGraph = await reconcileNewRuntimes( - api, - connections, - optionsRef, - ); + let {assetGraph: runtimesAssetGraph, changedAssets} = + await reconcileNewRuntimes(api, connections, optionsRef); let runtimesGraph = InternalBundleGraph.fromAssetGraph( runtimesAssetGraph, @@ -245,13 +243,15 @@ export default async function applyRuntimes({ bundleGraph._graph.addEdge(dependencyNodeId, bundleGraphRuntimeNodeId); } } + + return changedAssets; } -async function reconcileNewRuntimes( +function reconcileNewRuntimes( api: RunAPI, connections: Array, optionsRef: SharedReference, -): Promise { +) { let assetGroups = connections.map(t => t.assetGroup); let request = createAssetGraphRequest({ name: 'Runtimes', @@ -260,5 +260,5 @@ async function reconcileNewRuntimes( }); // rebuild the graph - return (await api.runRequest(request, {force: true})).assetGraph; + return api.runRequest(request, {force: true}); } diff --git a/packages/core/core/src/assetUtils.js b/packages/core/core/src/assetUtils.js index 4ab3be355fc..0cf7cc44724 100644 --- a/packages/core/core/src/assetUtils.js +++ b/packages/core/core/src/assetUtils.js @@ -11,7 +11,6 @@ import type { Symbol, SourceLocation, Transformer, - QueryParameters, } from '@parcel/types'; import type { Asset, @@ -20,7 +19,6 @@ import type { Environment, ParcelOptions, } from './types'; -import {objectSortedEntries} from '@parcel/utils'; import {Readable} from 'stream'; import {PluginLogger} from '@parcel/logger'; @@ -47,7 +45,7 @@ type AssetOptions = {| hash?: ?string, idBase?: ?string, filePath: ProjectPath, - query?: ?QueryParameters, + query?: ?string, type: string, contentKey?: ?string, mapKey?: ?string, @@ -76,9 +74,6 @@ export function createAssetIdFromOptions(options: AssetOptions): string { options.idBase != null ? options.idBase : fromProjectPathRelative(options.filePath); - let queryString = options.query - ? JSON.stringify(objectSortedEntries(options.query)) - : ''; return hashString( idBase + @@ -88,7 +83,7 @@ export function createAssetIdFromOptions(options: AssetOptions): string { ':' + (options.pipeline ?? '') + ':' + - queryString, + (options.query ?? ''), ); } diff --git a/packages/core/core/src/public/Asset.js b/packages/core/core/src/public/Asset.js index d9bb86bec7d..88372c2f0c2 100644 --- a/packages/core/core/src/public/Asset.js +++ b/packages/core/core/src/public/Asset.js @@ -19,7 +19,6 @@ import type { Stats, MutableAssetSymbols as IMutableAssetSymbols, AssetSymbols as IAssetSymbols, - QueryParameters, BundleBehavior, } from '@parcel/types'; import type {Asset as AssetValue, ParcelOptions} from '../types'; @@ -42,10 +41,8 @@ const inspect = Symbol.for('nodejs.util.inspect.custom'); const uncommittedAssetValueToAsset: WeakMap = new WeakMap(); const committedAssetValueToAsset: WeakMap = new WeakMap(); -const assetValueToMutableAsset: WeakMap< - AssetValue, - MutableAsset, -> = new WeakMap(); +const assetValueToMutableAsset: WeakMap = + new WeakMap(); const _assetToAssetValue: WeakMap< IAsset | IMutableAsset | BaseAsset, @@ -83,13 +80,14 @@ export function assetFromValue( class BaseAsset { #asset: CommittedAsset | UncommittedAsset; + #query /*: ?URLSearchParams */; constructor(asset: CommittedAsset | UncommittedAsset) { this.#asset = asset; _assetToAssetValue.set(this, asset.value); } - // $FlowFixMe + // $FlowFixMe[unsupported-syntax] [inspect](): string { return `Asset(${this.filePath})`; } @@ -117,8 +115,11 @@ class BaseAsset { ); } - get query(): QueryParameters { - return this.#asset.value.query ?? {}; + get query(): URLSearchParams { + if (!this.#query) { + this.#query = new URLSearchParams(this.#asset.value.query ?? ''); + } + return this.#query; } get meta(): Meta { diff --git a/packages/core/core/src/public/Bundle.js b/packages/core/core/src/public/Bundle.js index 00793ad4c66..1c9ae0a2bc7 100644 --- a/packages/core/core/src/public/Bundle.js +++ b/packages/core/core/src/public/Bundle.js @@ -51,10 +51,8 @@ const _bundleToInternalBundle: WeakMap = new WeakMap(); export function bundleToInternalBundle(bundle: IBundle): InternalBundle { return nullthrows(_bundleToInternalBundle.get(bundle)); } -const _bundleToInternalBundleGraph: WeakMap< - IBundle, - BundleGraph, -> = new WeakMap(); +const _bundleToInternalBundleGraph: WeakMap = + new WeakMap(); export function bundleToInternalBundleGraph(bundle: IBundle): BundleGraph { return nullthrows(_bundleToInternalBundleGraph.get(bundle)); } diff --git a/packages/core/core/src/public/BundleGraph.js b/packages/core/core/src/public/BundleGraph.js index b94b5d34dcc..47372f53c08 100644 --- a/packages/core/core/src/public/BundleGraph.js +++ b/packages/core/core/src/public/BundleGraph.js @@ -47,7 +47,8 @@ type BundleFactory = ( ) => TBundle; export default class BundleGraph - implements IBundleGraph { + implements IBundleGraph +{ #graph: InternalBundleGraph; #options: ParcelOptions; #createBundle: BundleFactory; @@ -294,7 +295,7 @@ export default class BundleGraph .map(bundle => this.#createBundle(bundle, this.#graph, this.#options)); } - getUsedSymbols(v: IAsset | IDependency): $ReadOnlySet { + getUsedSymbols(v: IAsset | IDependency): ?$ReadOnlySet { if (v instanceof Asset) { return this.#graph.getUsedSymbolsAsset(assetToAssetValue(v)); } else { diff --git a/packages/core/core/src/public/Dependency.js b/packages/core/core/src/public/Dependency.js index 60cc46042d1..950bb54249a 100644 --- a/packages/core/core/src/public/Dependency.js +++ b/packages/core/core/src/public/Dependency.js @@ -26,10 +26,8 @@ const PriorityNames = Object.keys(Priority); const inspect = Symbol.for('nodejs.util.inspect.custom'); -const internalDependencyToDependency: WeakMap< - InternalDependency, - Dependency, -> = new WeakMap(); +const internalDependencyToDependency: WeakMap = + new WeakMap(); const _dependencyToInternalDependency: WeakMap< IDependency, InternalDependency, diff --git a/packages/core/core/src/public/MutableBundleGraph.js b/packages/core/core/src/public/MutableBundleGraph.js index e59a2d8ac9c..65c174fb8c5 100644 --- a/packages/core/core/src/public/MutableBundleGraph.js +++ b/packages/core/core/src/public/MutableBundleGraph.js @@ -27,8 +27,10 @@ import {fromProjectPathRelative} from '../projectPath'; import {BundleBehavior} from '../types'; import BundleGroup, {bundleGroupToInternalBundleGroup} from './BundleGroup'; -export default class MutableBundleGraph extends BundleGraph - implements IMutableBundleGraph { +export default class MutableBundleGraph + extends BundleGraph + implements IMutableBundleGraph +{ #graph /*: InternalBundleGraph */; #options /*: ParcelOptions */; #bundlePublicIds /*: Set */ = new Set(); @@ -102,9 +104,8 @@ export default class MutableBundleGraph extends BundleGraph dependencyNode.id, ); let resolvedNodeId = this.#graph._graph.getNodeIdByContentKey(resolved.id); - let assetNodes = this.#graph._graph.getNodeIdsConnectedFrom( - dependencyNodeId, - ); + let assetNodes = + this.#graph._graph.getNodeIdsConnectedFrom(dependencyNodeId); this.#graph._graph.addEdge(dependencyNodeId, bundleGroupNodeId); this.#graph._graph.replaceNodeIdsConnectedTo(bundleGroupNodeId, assetNodes); this.#graph._graph.addEdge( @@ -191,7 +192,9 @@ export default class MutableBundleGraph extends BundleGraph id: bundleId, value: { id: bundleId, - hashReference: HASH_REF_PREFIX + bundleId, + hashReference: this.#options.shouldContentHash + ? HASH_REF_PREFIX + bundleId + : bundleId.slice(-8), type: opts.entryAsset ? opts.entryAsset.type : opts.type, env: opts.env ? environmentToInternalEnvironment(opts.env) diff --git a/packages/core/core/src/public/PluginOptions.js b/packages/core/core/src/public/PluginOptions.js index 41688e0f859..7ae8fdff268 100644 --- a/packages/core/core/src/public/PluginOptions.js +++ b/packages/core/core/src/public/PluginOptions.js @@ -13,10 +13,8 @@ import type {FileSystem} from '@parcel/fs'; import type {PackageManager} from '@parcel/package-manager'; import type {ParcelOptions} from '../types'; -let parcelOptionsToPluginOptions: WeakMap< - ParcelOptions, - PluginOptions, -> = new WeakMap(); +let parcelOptionsToPluginOptions: WeakMap = + new WeakMap(); export default class PluginOptions implements IPluginOptions { #options /*: ParcelOptions */; diff --git a/packages/core/core/src/public/Symbols.js b/packages/core/core/src/public/Symbols.js index 32ae9ca92be..cca19f14c0d 100644 --- a/packages/core/core/src/public/Symbols.js +++ b/packages/core/core/src/public/Symbols.js @@ -97,10 +97,8 @@ export class AssetSymbols implements IAssetSymbols { } } -let valueToMutableAssetSymbols: WeakMap< - Asset, - MutableAssetSymbols, -> = new WeakMap(); +let valueToMutableAssetSymbols: WeakMap = + new WeakMap(); export class MutableAssetSymbols implements IMutableAssetSymbols { /*:: @@iterator(): Iterator<[ISymbol, {|local: ISymbol, loc: ?SourceLocation, meta?: ?Meta|}]> { return ({}: any); } diff --git a/packages/core/core/src/requests/AssetGraphRequest.js b/packages/core/core/src/requests/AssetGraphRequest.js index 89969dff840..791bfd63baf 100644 --- a/packages/core/core/src/requests/AssetGraphRequest.js +++ b/packages/core/core/src/requests/AssetGraphRequest.js @@ -24,6 +24,7 @@ import invariant from 'assert'; import nullthrows from 'nullthrows'; import {PromiseQueue} from '@parcel/utils'; import {hashString} from '@parcel/hash'; +import logger from '@parcel/logger'; import ThrowableDiagnostic, {md} from '@parcel/diagnostic'; import {BundleBehavior, Priority} from '../types'; import AssetGraph from '../AssetGraph'; @@ -78,7 +79,8 @@ export default function createAssetGraphRequest( type: 'asset_graph_request', id: input.name, run: async input => { - let prevResult = await input.api.getPreviousResult(); + let prevResult = + await input.api.getPreviousResult(); let builder = new AssetGraphBuilder(input, prevResult); return builder.build(); }, @@ -132,7 +134,7 @@ export class AssetGraphBuilder { this.requestedAssetIds = requestedAssetIds ?? new Set(); this.shouldBuildLazily = shouldBuildLazily ?? false; this.cacheKey = hashString( - `${PARCEL_VERSION}${name}${JSON.stringify(entries) ?? ''}`, + `${PARCEL_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}`, ); this.queue = new PromiseQueue(); @@ -203,7 +205,11 @@ export class AssetGraphBuilder { return dep; }), ); - if (entryDependencies.some(d => d.value.env.shouldScopeHoist)) { + + this.assetGraph.symbolPropagationRan = entryDependencies.some( + d => d.value.env.shouldScopeHoist, + ); + if (this.assetGraph.symbolPropagationRan) { try { this.propagateSymbols(); } catch (e) { @@ -397,6 +403,26 @@ export class AssetGraphBuilder { } }); + const logFallbackNamespaceInsertion = ( + assetNode, + symbol, + depNode1, + depNode2, + ) => { + if (this.options.logLevel === 'verbose') { + logger.warn({ + message: `${fromProjectPathRelative( + assetNode.value.filePath, + )} reexports "${symbol}", which could be resolved either to the dependency "${ + depNode1.value.specifier + }" or "${ + depNode2.value.specifier + }" at runtime. Adding a namespace object to fall back on.`, + origin: '@parcel/core', + }); + } + }; + // Because namespace reexports introduce ambiguity, go up the graph from the leaves to the // root and remove requested symbols that aren't actually exported this.propagateSymbolsUp((assetNode, incomingDeps, outgoingDeps) => { @@ -420,7 +446,9 @@ export class AssetGraphBuilder { } } - let reexportedSymbols = new Set(); + // the symbols that are reexport (not used in `asset`) -> the corresponding outgoingDep(s) + // There could be multiple dependencies with non-statically analyzable exports + let reexportedSymbols = new Map(); for (let outgoingDep of outgoingDeps) { let outgoingDepSymbols = outgoingDep.value.symbols; if (!outgoingDepSymbols) continue; @@ -437,7 +465,20 @@ export class AssetGraphBuilder { } if (outgoingDepSymbols.get('*')?.local === '*') { - outgoingDep.usedSymbolsUp.forEach(s => reexportedSymbols.add(s)); + outgoingDep.usedSymbolsUp.forEach(s => { + // If the symbol could come from multiple assets at runtime, assetNode's + // namespace will be needed at runtime to perform the lookup on. + if (reexportedSymbols.has(s) && !assetNode.usedSymbols.has('*')) { + logFallbackNamespaceInsertion( + assetNode, + s, + nullthrows(reexportedSymbols.get(s)), + outgoingDep, + ); + assetNode.usedSymbols.add('*'); + } + reexportedSymbols.set(s, outgoingDep); + }); } for (let s of outgoingDep.usedSymbolsUp) { @@ -454,7 +495,19 @@ export class AssetGraphBuilder { let reexported = assetSymbolsInverse?.get(local); if (reexported != null) { - reexported.forEach(s => reexportedSymbols.add(s)); + reexported.forEach(s => { + // see same code above + if (reexportedSymbols.has(s) && !assetNode.usedSymbols.has('*')) { + logFallbackNamespaceInsertion( + assetNode, + s, + nullthrows(reexportedSymbols.get(s)), + outgoingDep, + ); + assetNode.usedSymbols.add('*'); + } + reexportedSymbols.set(s, outgoingDep); + }); } } } @@ -501,7 +554,7 @@ export class AssetGraphBuilder { this.options.projectRoot, loc?.filePath, ) ?? undefined, - language: assetNode.value.type, + language: incomingDep.value.sourceAssetType ?? undefined, codeHighlights: [ { start: loc.start, @@ -726,9 +779,8 @@ export class AssetGraphBuilder { } } } else { - let connectedNodes = this.assetGraph.getNodeIdsConnectedTo( - queuedNodeId, - ); + let connectedNodes = + this.assetGraph.getNodeIdsConnectedTo(queuedNodeId); if (connectedNodes.length > 0) { queue.add(...connectedNodes); } diff --git a/packages/core/core/src/requests/AssetRequest.js b/packages/core/core/src/requests/AssetRequest.js index 65293c785f1..07db6a1e69f 100644 --- a/packages/core/core/src/requests/AssetRequest.js +++ b/packages/core/core/src/requests/AssetRequest.js @@ -12,7 +12,6 @@ import type { import type {ConfigAndCachePath} from './ParcelConfigRequest'; import type {TransformationResult} from '../Transformation'; -import {objectSortedEntries} from '@parcel/utils'; import nullthrows from 'nullthrows'; import {hashString} from '@parcel/hash'; import createParcelConfigRequest from './ParcelConfigRequest'; @@ -59,7 +58,7 @@ function getId(input: AssetRequestInput) { ':' + (input.pipeline ?? '') + ':' + - (input.query ? JSON.stringify(objectSortedEntries(input.query)) : ''), + (input.query ?? ''), ); } diff --git a/packages/core/core/src/requests/BundleGraphRequest.js b/packages/core/core/src/requests/BundleGraphRequest.js index 13da2f1dbac..fe07eddd575 100644 --- a/packages/core/core/src/requests/BundleGraphRequest.js +++ b/packages/core/core/src/requests/BundleGraphRequest.js @@ -5,6 +5,7 @@ import type {SharedReference} from '@parcel/workers'; import type ParcelConfig, {LoadedPlugin} from '../ParcelConfig'; import type {StaticRunOpts, RunAPI} from '../RequestTracker'; import type { + Asset, Bundle as InternalBundle, Config, DevDepRequest, @@ -63,10 +64,15 @@ type RunInput = {| ...StaticRunOpts, |}; +type BundleGraphResult = {| + bundleGraph: InternalBundleGraph, + changedAssets: Map, +|}; + type BundleGraphRequest = {| id: string, +type: 'bundle_graph_request', - run: RunInput => Async, + run: RunInput => Async, input: BundleGraphRequestInput, |}; @@ -164,7 +170,7 @@ class BundlerRunner { await runDevDepRequest(this.api, devDepRequest); } - async bundle(graph: AssetGraph): Promise { + async bundle(graph: AssetGraph): Promise { report({ type: 'buildProgress', phase: 'bundling', @@ -194,7 +200,13 @@ class BundlerRunner { // Deserialize, and store the original buffer in an in memory cache so we avoid // re-serializing it when sending to workers, and in build mode, when writing to cache on shutdown. let graph = deserializeToCache(cached); - this.api.storeResult(graph, cacheKey); + this.api.storeResult( + { + bundleGraph: graph, + changedAssets: new Map(), + }, + cacheKey, + ); return graph; } } @@ -273,7 +285,7 @@ class BundlerRunner { await this.nameBundles(internalBundleGraph); - await applyRuntimes({ + let changedAssets = await applyRuntimes({ bundleGraph: internalBundleGraph, api: this.api, config: this.config, @@ -300,8 +312,18 @@ class BundlerRunner { // Recompute the cache key to account for new dev dependencies and invalidations. cacheKey = await this.getCacheKey(graph); - this.api.storeResult(internalBundleGraph, cacheKey); - return internalBundleGraph; + this.api.storeResult( + { + bundleGraph: internalBundleGraph, + changedAssets: new Map(), + }, + cacheKey, + ); + + return { + bundleGraph: internalBundleGraph, + changedAssets, + }; } async getCacheKey(assetGraph: AssetGraph): Promise { @@ -323,7 +345,8 @@ class BundlerRunner { assetGraph.getHash() + configs + devDepRequests + - invalidations, + invalidations + + this.options.mode, ); } diff --git a/packages/core/core/src/requests/EntryRequest.js b/packages/core/core/src/requests/EntryRequest.js index 91f8d3cfddc..0c3b75d64cb 100644 --- a/packages/core/core/src/requests/EntryRequest.js +++ b/packages/core/core/src/requests/EntryRequest.js @@ -314,9 +314,7 @@ export class EntryResolver { }); } - async readPackage( - entry: FilePath, - ): Promise(createParcelConfigRequest()), ); - let { - devDepRequests, - configRequests, - bundleInfo, - invalidations, - } = await runPackage({ - bundle, - bundleGraphReference, - optionsRef, - configCachePath: cachePath, - previousDevDeps: devDeps, - invalidDevDeps, - previousInvalidations: api.getInvalidations(), - }); + let {devDepRequests, configRequests, bundleInfo, invalidations} = + await runPackage({ + bundle, + bundleGraphReference, + optionsRef, + configCachePath: cachePath, + previousDevDeps: devDeps, + invalidDevDeps, + previousInvalidations: api.getInvalidations(), + }); for (let devDepRequest of devDepRequests) { await runDevDepRequest(api, devDepRequest); diff --git a/packages/core/core/src/requests/ParcelBuildRequest.js b/packages/core/core/src/requests/ParcelBuildRequest.js index ea5a2a00215..72a51011338 100644 --- a/packages/core/core/src/requests/ParcelBuildRequest.js +++ b/packages/core/core/src/requests/ParcelBuildRequest.js @@ -73,7 +73,12 @@ async function run({input, api, options}: RunInput) { optionsRef, }); - let bundleGraph = await api.runRequest(bundleGraphRequest); + let {bundleGraph, changedAssets: changedRuntimeAssets} = await api.runRequest( + bundleGraphRequest, + ); + for (let [id, asset] of changedRuntimeAssets) { + changedAssets.set(id, asset); + } // $FlowFixMe Added in Flow 0.121.0 upgrade in #4381 (Windows only) dumpGraphToGraphViz(bundleGraph._graph, 'BundleGraph', bundleGraphEdgeTypes); diff --git a/packages/core/core/src/requests/ParcelConfigRequest.js b/packages/core/core/src/requests/ParcelConfigRequest.js index ed9b9409f61..546d59854f3 100644 --- a/packages/core/core/src/requests/ParcelConfigRequest.js +++ b/packages/core/core/src/requests/ParcelConfigRequest.js @@ -308,7 +308,7 @@ async function processMap( }, ], documentationURL: - 'https://v2.parceljs.org/features/dependency-resolution/#url-schemes', + 'https://parceljs.org/features/dependency-resolution/#url-schemes', }, }); } @@ -443,16 +443,8 @@ export async function processConfigChain( : '/extends'; let resolved = await resolveExtends(ext, filePath, key, options); extendedFiles.push(resolved); - let { - extendedFiles: moreExtendedFiles, - config: nextConfig, - } = await processExtendedConfig( - filePath, - key, - ext, - resolved, - options, - ); + let {extendedFiles: moreExtendedFiles, config: nextConfig} = + await processExtendedConfig(filePath, key, ext, resolved, options); extendedFiles = extendedFiles.concat(moreExtendedFiles); extStartConfig = extStartConfig ? mergeConfigs(extStartConfig, nextConfig) diff --git a/packages/core/core/src/requests/PathRequest.js b/packages/core/core/src/requests/PathRequest.js index 73bdcd62c93..347fbe12468 100644 --- a/packages/core/core/src/requests/PathRequest.js +++ b/packages/core/core/src/requests/PathRequest.js @@ -239,7 +239,7 @@ export class ResolverRunner { this.options.projectRoot, resultFilePath, ), - query: result.query, + query: result.query?.toString(), sideEffects: result.sideEffects, code: result.code, env: dependency.env, diff --git a/packages/core/core/src/requests/TargetRequest.js b/packages/core/core/src/requests/TargetRequest.js index 03d95e267ad..e4ed1429dde 100644 --- a/packages/core/core/src/requests/TargetRequest.js +++ b/packages/core/core/src/requests/TargetRequest.js @@ -154,10 +154,8 @@ export class TargetResolver { optionTargets = [exclusiveTarget]; } - let packageTargets: Map< - string, - Target | null, - > = await this.resolvePackageTargets(rootDir, exclusiveTarget); + let packageTargets: Map = + await this.resolvePackageTargets(rootDir, exclusiveTarget); let targets: Array; if (optionTargets) { if (Array.isArray(optionTargets)) { @@ -279,7 +277,7 @@ export class TargetResolver { } let serve = this.options.serveOptions; - if (serve) { + if (serve && targets.length > 0) { // In serve mode, we only support a single browser target. If the user // provided more than one, or the matching target is not a browser, throw. if (targets.length > 1) { @@ -322,8 +320,8 @@ export class TargetResolver { engines: {}, shouldOptimize: this.options.defaultTargetOptions.shouldOptimize, outputFormat: this.options.defaultTargetOptions.outputFormat, - shouldScopeHoist: this.options.defaultTargetOptions - .shouldScopeHoist, + shouldScopeHoist: + this.options.defaultTargetOptions.shouldScopeHoist, sourceMap: this.options.defaultTargetOptions.sourceMaps ? {} : undefined, @@ -593,7 +591,7 @@ export class TargetResolver { `The "${targetName}" field is meant for libraries. If you meant to output a ${ext} file, either remove the "${targetName}" field or choose a different target name.`, ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, }); } @@ -625,7 +623,7 @@ export class TargetResolver { `The "${targetName}" field is meant for libraries. The outputFormat must be either "commonjs" or "esmodule". Either change or remove the declared outputFormat.`, ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, }); } @@ -684,7 +682,7 @@ export class TargetResolver { `Either change the output file extension to .mjs, add "type": "module" to package.json, or remove the declared outputFormat.`, ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, }); } @@ -716,7 +714,7 @@ export class TargetResolver { `The "${targetName}" target is meant for libraries. Either remove the "scopeHoist" option, or use a different target name.`, ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, }); } @@ -859,7 +857,7 @@ export class TargetResolver { ], hints: [`Either remove the "scopeHoist" or "isLibrary" option.`], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, }); } @@ -1027,7 +1025,7 @@ export class TargetResolver { )}.`, ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, }); } @@ -1253,7 +1251,7 @@ function assertTargetsAreNotEntries( : '') + `Change the "${target.name}" field to point to an output file rather than your source code.`, ], - documentationURL: 'https://v2.parceljs.org/features/targets/', + documentationURL: 'https://parceljs.org/features/targets/', }, }); } diff --git a/packages/core/core/src/types.js b/packages/core/core/src/types.js index 565b43bc67a..6c498c47385 100644 --- a/packages/core/core/src/types.js +++ b/packages/core/core/src/types.js @@ -24,7 +24,6 @@ import type { OutputFormat, TargetDescriptor, HMROptions, - QueryParameters, DetailedReportOptions, } from '@parcel/types'; import type {SharedReference} from '@parcel/workers'; @@ -149,16 +148,15 @@ export const BundleBehavior = { isolated: 1, }; -export const BundleBehaviorNames: Array< - $Keys, -> = Object.keys(BundleBehavior); +export const BundleBehaviorNames: Array<$Keys> = + Object.keys(BundleBehavior); export type Asset = {| id: ContentKey, committed: boolean, hash: ?string, filePath: ProjectPath, - query: ?QueryParameters, + query: ?string, type: string, dependencies: Map, bundleBehavior: ?$Values, @@ -330,7 +328,7 @@ export type AssetRequestInput = {| pipeline?: ?string, optionsRef: SharedReference, isURL?: boolean, - query?: ?QueryParameters, + query?: ?string, |}; export type AssetRequestResult = Array; diff --git a/packages/core/core/src/worker.js b/packages/core/core/src/worker.js index 6fdb6db46e6..bb1467076f5 100644 --- a/packages/core/core/src/worker.js +++ b/packages/core/core/src/worker.js @@ -150,7 +150,8 @@ export async function childInit() { await initHash; } -const PKG_RE = /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/; +const PKG_RE = + /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/; export function invalidateRequireCache(workerApi: WorkerApi, file: string) { if (process.env.PARCEL_BUILD_ENV === 'test') { // Delete this module and all children in the same node_modules folder diff --git a/packages/core/core/test/AssetGraph.test.js b/packages/core/core/test/AssetGraph.test.js index 0741771adf7..5f5fc249f1a 100644 --- a/packages/core/core/test/AssetGraph.test.js +++ b/packages/core/core/test/AssetGraph.test.js @@ -253,7 +253,6 @@ describe('AssetGraph', () => { let req = { filePath: toProjectPath('/index.js'), env: DEFAULT_ENV, - query: {}, }; graph.resolveDependency(dep, req, '3'); @@ -267,7 +266,6 @@ describe('AssetGraph', () => { let req2 = { filePath: toProjectPath('/index.jsx'), env: DEFAULT_ENV, - query: {}, }; graph.resolveDependency(dep, req2, '4'); @@ -319,7 +317,7 @@ describe('AssetGraph', () => { }); let sourcePath = '/index.js'; let filePath = toProjectPath(sourcePath); - let req = {filePath, env: DEFAULT_ENV, query: {}}; + let req = {filePath, env: DEFAULT_ENV}; graph.resolveDependency(dep, req, '3'); let assets = [ createAsset({ @@ -486,7 +484,7 @@ describe('AssetGraph', () => { }); let sourcePath = '/index.js'; let filePath = toProjectPath(sourcePath); - let req = {filePath, env: DEFAULT_ENV, query: {}}; + let req = {filePath, env: DEFAULT_ENV}; graph.resolveDependency(dep, req, '123'); let dep1 = createDependency({ specifier: 'dependent-asset-1', @@ -566,7 +564,6 @@ describe('AssetGraph', () => { let indexAssetGroup = { filePath: toProjectPath('/index.js'), env: DEFAULT_ENV, - query: {}, }; graph.setRootConnections({assetGroups: [indexAssetGroup]}); let indexFooDep = createDependency({ @@ -600,7 +597,6 @@ describe('AssetGraph', () => { let fooAssetGroup = { filePath: toProjectPath('/foo.js'), env: DEFAULT_ENV, - query: {}, }; graph.resolveDependency(indexFooDep, fooAssetGroup, '0'); let fooAssetGroupNode = nodeFromAssetGroup(fooAssetGroup); @@ -626,7 +622,6 @@ describe('AssetGraph', () => { let utilsAssetGroup = { filePath: toProjectPath('/utils.js'), env: DEFAULT_ENV, - query: {}, }; let utilsAssetGroupNode = nodeFromAssetGroup(utilsAssetGroup); graph.resolveDependency(fooUtilsDep, utilsAssetGroup, '0'); @@ -646,7 +641,6 @@ describe('AssetGraph', () => { let barAssetGroup = { filePath: toProjectPath('/bar.js'), env: DEFAULT_ENV, - query: {}, }; graph.resolveDependency(indexBarDep, barAssetGroup, '0'); let barAssetGroupNode = nodeFromAssetGroup(barAssetGroup); diff --git a/packages/core/core/test/BundleGraph.test.js b/packages/core/core/test/BundleGraph.test.js index 6df5aeef958..9d65a8e4948 100644 --- a/packages/core/core/test/BundleGraph.test.js +++ b/packages/core/core/test/BundleGraph.test.js @@ -83,7 +83,7 @@ function createMockAssetGraph(ids: [string, string]) { }); let sourcePath = '/index.js'; let filePath = toProjectPath('/', sourcePath); - let req = {filePath, env: DEFAULT_ENV, query: {}}; + let req = {filePath, env: DEFAULT_ENV}; graph.resolveDependency(dep, nodeFromAssetGroup(req).value, '3'); let dep1 = createDependency({ diff --git a/packages/core/core/test/EntryRequest.test.js b/packages/core/core/test/EntryRequest.test.js index ccc870a7a02..6b5ca40a6f7 100644 --- a/packages/core/core/test/EntryRequest.test.js +++ b/packages/core/core/test/EntryRequest.test.js @@ -33,10 +33,10 @@ const INVALID_TARGET_SOURCE_NOT_FILE_FIXTURE_PATH = path.join( 'fixtures/invalid-target-source-not-file', ); -describe('EntryResolver', function() { +describe('EntryResolver', function () { let entryResolver = new EntryResolver({...DEFAULT_OPTIONS}); - it('rejects missing source in package.json', async function() { + it('rejects missing source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( @@ -76,7 +76,7 @@ describe('EntryResolver', function() { }, ); }); - it('rejects non-file source in package.json', async function() { + it('rejects non-file source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( @@ -115,7 +115,7 @@ describe('EntryResolver', function() { }, ); }); - it('rejects missing target source in package.json', async function() { + it('rejects missing target source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( @@ -159,7 +159,7 @@ describe('EntryResolver', function() { }, ); }); - it('rejects non-file target source in package.json', async function() { + it('rejects non-file target source in package.json', async function () { this.timeout(10000); // $FlowFixMe assert.rejects is Node 10+ await assert.rejects( diff --git a/packages/core/core/test/Environment.test.js b/packages/core/core/test/Environment.test.js index 485835d262c..67643f1e4e1 100644 --- a/packages/core/core/test/Environment.test.js +++ b/packages/core/core/test/Environment.test.js @@ -6,7 +6,7 @@ import {createEnvironment} from '../src/Environment'; describe('Environment', () => { it('assigns a default environment with nothing passed', () => { assert.deepEqual(createEnvironment(), { - id: '28ff5688dfa7d45e', + id: 'c242f987e3544367', context: 'browser', engines: { browsers: ['> 0.25%'], @@ -24,7 +24,7 @@ describe('Environment', () => { it('assigns a node context if a node engine is given', () => { assert.deepEqual(createEnvironment({engines: {node: '>= 10.0.0'}}), { - id: '3bae9fa4de65ce29', + id: '69e0ab7220ee8f7a', context: 'node', engines: { node: '>= 10.0.0', @@ -44,7 +44,7 @@ describe('Environment', () => { assert.deepEqual( createEnvironment({engines: {browsers: ['last 1 version']}}), { - id: '0006b4816a385465', + id: '4b5c9005af8c5b19', context: 'browser', engines: { browsers: ['last 1 version'], @@ -63,7 +63,7 @@ describe('Environment', () => { it('assigns default engines for node', () => { assert.deepEqual(createEnvironment({context: 'node'}), { - id: '5171f29d65a099c4', + id: 'f7c9644283a8698f', context: 'node', engines: { node: '>= 8.0.0', @@ -81,7 +81,7 @@ describe('Environment', () => { it('assigns default engines for browsers', () => { assert.deepEqual(createEnvironment({context: 'browser'}), { - id: '28ff5688dfa7d45e', + id: 'c242f987e3544367', context: 'browser', engines: { browsers: ['> 0.25%'], diff --git a/packages/core/core/test/Parcel.test.js b/packages/core/core/test/Parcel.test.js index ac3025d671b..2419cbaef9e 100644 --- a/packages/core/core/test/Parcel.test.js +++ b/packages/core/core/test/Parcel.test.js @@ -8,7 +8,7 @@ import assert from 'assert'; import path from 'path'; import Parcel, {createWorkerFarm} from '../src/Parcel'; -describe('Parcel', function() { +describe('Parcel', function () { this.timeout(75000); let workerFarm; diff --git a/packages/core/core/test/ParcelConfig.test.js b/packages/core/core/test/ParcelConfig.test.js index 54652c86c71..9cea05a6f95 100644 --- a/packages/core/core/test/ParcelConfig.test.js +++ b/packages/core/core/test/ParcelConfig.test.js @@ -312,7 +312,7 @@ describe('ParcelConfig', () => { }, ], documentationURL: - 'https://v2.parceljs.org/features/dependency-resolution/#url-schemes', + 'https://parceljs.org/features/dependency-resolution/#url-schemes', }, ], }, diff --git a/packages/core/core/test/PublicBundle.test.js b/packages/core/core/test/PublicBundle.test.js index 39fe7baf6ba..97338f16cd0 100644 --- a/packages/core/core/test/PublicBundle.test.js +++ b/packages/core/core/test/PublicBundle.test.js @@ -42,6 +42,7 @@ describe('Public Bundle', () => { assetPublicIds: new Set(), publicIdByAssetId: new Map(), bundleContentHashes: new Map(), + symbolPropagationRan: false, }); }); diff --git a/packages/core/core/test/PublicMutableBundleGraph.test.js b/packages/core/core/test/PublicMutableBundleGraph.test.js index 58328f17aa5..20fe2fae955 100644 --- a/packages/core/core/test/PublicMutableBundleGraph.test.js +++ b/packages/core/core/test/PublicMutableBundleGraph.test.js @@ -151,7 +151,7 @@ function createMockAssetGraph() { }); let filePath = toProjectPath('/', '/index.js'); - let req1 = {filePath, env: DEFAULT_ENV, query: {}}; + let req1 = {filePath, env: DEFAULT_ENV}; graph.resolveDependency(dep1, nodeFromAssetGroup(req1).value, '5'); graph.resolveAssetGroup( req1, @@ -170,7 +170,7 @@ function createMockAssetGraph() { ); filePath = toProjectPath('/', '/index2.js'); - let req2 = {filePath, env: DEFAULT_ENV, query: {}}; + let req2 = {filePath, env: DEFAULT_ENV}; graph.resolveDependency(dep2, nodeFromAssetGroup(req2).value, '7'); graph.resolveAssetGroup( req2, diff --git a/packages/core/core/test/TargetRequest.test.js b/packages/core/core/test/TargetRequest.test.js index 467bc0b1436..623c715ea45 100644 --- a/packages/core/core/test/TargetRequest.test.js +++ b/packages/core/core/test/TargetRequest.test.js @@ -120,7 +120,7 @@ describe('TargetResolver', () => { publicUrl: '/', distDir: normalizeSeparators(path.resolve('customA')), env: { - id: '7185aca026a1ba43', + id: '1d40417b63734b32', context: 'browser', includeNodeModules: true, engines: { @@ -141,7 +141,7 @@ describe('TargetResolver', () => { distEntry: 'b.js', distDir: normalizeSeparators(path.resolve('customB')), env: { - id: '923e2836f26d91cc', + id: '928f0d1c941b2e57', context: 'node', includeNodeModules: false, engines: { @@ -172,7 +172,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: '5b90122270d806a3', + id: 'b552bd32da37fa8b', context: 'node', engines: { node: '>= 8.0.0', @@ -206,7 +206,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: 'd569d73dba5024af', + id: '8804e4eb97e2703e', context: 'browser', engines: { browsers: ['last 1 version'], @@ -242,7 +242,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/assets', env: { - id: 'f68e756a9f45b317', + id: 'a7ed3e73c53f1923', context: 'browser', engines: { browsers: ['last 1 version'], @@ -288,7 +288,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: '5171f29d65a099c4', + id: 'f7c9644283a8698f', context: 'node', engines: { node: '>= 8.0.0', @@ -331,7 +331,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: '5b90122270d806a3', + id: 'b552bd32da37fa8b', context: 'node', engines: { node: '>= 8.0.0', @@ -365,7 +365,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: 'a06e3cc9e0541b70', + id: '1f28e9ceaf633d83', context: 'browser', engines: { browsers: ['last 1 version'], @@ -399,7 +399,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: 'd9b90540ac44a9db', + id: '767bf6e6b675c4f3', context: 'browser', engines: { browsers: ['ie11'], @@ -450,7 +450,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: '5b90122270d806a3', + id: 'b552bd32da37fa8b', context: 'node', engines: { node: '>= 8.0.0', @@ -484,7 +484,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: 'a06e3cc9e0541b70', + id: 'ed7c0e65adee71c9', context: 'browser', engines: { browsers: ['last 1 version'], @@ -518,7 +518,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: 'd9b90540ac44a9db', + id: 'f7692543e59e4c0a', context: 'browser', engines: { browsers: ['ie11'], @@ -561,7 +561,7 @@ describe('TargetResolver', () => { distEntry: undefined, publicUrl: 'www', env: { - id: '0d13493649c1b9ee', + id: 'ddb6ac7c9a3a9178', context: 'browser', engines: { browsers: '> 0.25%', @@ -604,7 +604,7 @@ describe('TargetResolver', () => { distDir: normalizeSeparators(path.resolve('customB')), publicUrl: '/', env: { - id: '7185aca026a1ba43', + id: '1d40417b63734b32', context: 'browser', engines: { browsers: ['> 0.25%'], @@ -646,7 +646,7 @@ describe('TargetResolver', () => { distDir: normalizeSeparators(path.resolve('customA')), publicUrl: '/', env: { - id: '7185aca026a1ba43', + id: '1d40417b63734b32', context: 'browser', engines: { browsers: ['> 0.25%'], @@ -675,7 +675,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: 'b58d7c211621cd65', + id: 'bebcf0293c911f03', context: 'node', engines: {}, includeNodeModules: false, @@ -737,7 +737,7 @@ describe('TargetResolver', () => { 'The "main" field is meant for libraries. If you meant to output a .html file, either remove the "main" field or choose a different target name.', ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, ], }); @@ -779,7 +779,7 @@ describe('TargetResolver', () => { 'The "main" field is meant for libraries. The outputFormat must be either "commonjs" or "esmodule". Either change or remove the declared outputFormat.', ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, ], }); @@ -832,7 +832,7 @@ describe('TargetResolver', () => { 'Either change the output file extension to .mjs, add "type": "module" to package.json, or remove the declared outputFormat.', ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, ], }); @@ -885,7 +885,7 @@ describe('TargetResolver', () => { 'Either remove the target\'s declared "outputFormat" or change the extension to .mjs or .js.', ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, ], }); @@ -938,7 +938,7 @@ describe('TargetResolver', () => { 'Either remove the target\'s declared "outputFormat" or change the extension to .cjs or .js.', ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, ], }); @@ -979,7 +979,7 @@ describe('TargetResolver', () => { 'The "main" target is meant for libraries. Either remove the "scopeHoist" option, or use a different target name.', ], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, ], }); @@ -1029,7 +1029,7 @@ describe('TargetResolver', () => { ], hints: ['Either remove the "scopeHoist" or "isLibrary" option.'], documentationURL: - 'https://v2.parceljs.org/features/targets/#library-targets', + 'https://parceljs.org/features/targets/#library-targets', }, ], }); @@ -1046,7 +1046,7 @@ describe('TargetResolver', () => { distEntry: 'index.mjs', publicUrl: '/', env: { - id: '82a58acaebe4fd7c', + id: 'fa77701547623794', context: 'browser', engines: {}, includeNodeModules: true, @@ -1084,7 +1084,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: '82a58acaebe4fd7c', + id: 'fa77701547623794', context: 'browser', engines: {}, includeNodeModules: true, @@ -1126,7 +1126,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/', env: { - id: '5b90122270d806a3', + id: 'b552bd32da37fa8b', context: 'node', engines: { node: '>= 8.0.0', @@ -1160,7 +1160,7 @@ describe('TargetResolver', () => { distEntry: 'index.js', publicUrl: '/assets', env: { - id: 'f68e756a9f45b317', + id: 'a7ed3e73c53f1923', context: 'browser', engines: { browsers: ['last 1 version'], @@ -1208,7 +1208,7 @@ describe('TargetResolver', () => { distDir: '.parcel-cache/dist', publicUrl: '/', env: { - id: '69f74e7f31319ffd', + id: '4a236f9275d0a351', context: 'browser', engines: {}, includeNodeModules: true, @@ -1238,7 +1238,7 @@ describe('TargetResolver', () => { ), publicUrl: '/', env: { - id: '04e06037831229c5', + id: 'a9c07d094d038c73', context: 'browser', engines: { browsers: ['Chrome 80'], @@ -1271,7 +1271,7 @@ describe('TargetResolver', () => { distEntry: undefined, publicUrl: '/', env: { - id: '04e06037831229c5', + id: 'a9c07d094d038c73', context: 'browser', engines: { browsers: ['Chrome 80'], @@ -1309,7 +1309,7 @@ describe('TargetResolver', () => { distEntry: undefined, publicUrl: '/', env: { - id: 'a06e3cc9e0541b70', + id: '1f28e9ceaf633d83', context: 'browser', engines: { browsers: ['last 1 version'], @@ -1337,7 +1337,7 @@ describe('TargetResolver', () => { distEntry: undefined, publicUrl: '/', env: { - id: '83bb584641584b67', + id: '824e113c03cab3c8', context: 'browser', engines: { browsers: ['IE 11'], diff --git a/packages/core/diagnostic/package.json b/packages/core/diagnostic/package.json index f9909f09a26..b654ef165bf 100644 --- a/packages/core/diagnostic/package.json +++ b/packages/core/diagnostic/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/diagnostic", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/core/diagnostic/src/diagnostic.js b/packages/core/diagnostic/src/diagnostic.js index 95251b40979..cc8b05331ae 100644 --- a/packages/core/diagnostic/src/diagnostic.js +++ b/packages/core/diagnostic/src/diagnostic.js @@ -313,22 +313,22 @@ export function md( return result.join('') + strings[strings.length - 1]; } -md.bold = function(s: TemplateInput): TemplateInput { +md.bold = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '**' + escapeMarkdown(`${s}`) + '**'}; }; -md.italic = function(s: TemplateInput): TemplateInput { +md.italic = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '_' + escapeMarkdown(`${s}`) + '_'}; }; -md.underline = function(s: TemplateInput): TemplateInput { +md.underline = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '__' + escapeMarkdown(`${s}`) + '__'}; }; -md.strikethrough = function(s: TemplateInput): TemplateInput { +md.strikethrough = function (s: TemplateInput): TemplateInput { // $FlowFixMe[invalid-computed-prop] return {[mdVerbatim]: '~~' + escapeMarkdown(`${s}`) + '~~'}; }; diff --git a/packages/core/fs/package.json b/packages/core/fs/package.json index 0c011ef0623..5e0f2ceb9d6 100644 --- a/packages/core/fs/package.json +++ b/packages/core/fs/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/fs", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { @@ -25,12 +25,12 @@ "check-ts": "tsc --noEmit index.d.ts" }, "dependencies": { - "@parcel/fs-search": "2.0.0-rc.0", - "@parcel/fs-write-stream-atomic": "2.0.0-rc.0", - "@parcel/types": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", - "@parcel/watcher": "2.0.0-alpha.10", - "@parcel/workers": "2.0.0-rc.0", + "@parcel/fs-search": "^2.0.1", + "@parcel/fs-write-stream-atomic": "^2.0.1", + "@parcel/types": "^2.0.1", + "@parcel/utils": "^2.0.1", + "@parcel/watcher": "^2.0.0", + "@parcel/workers": "^2.0.1", "graceful-fs": "^4.2.4", "mkdirp": "^0.5.1", "ncp": "^2.0.0", @@ -39,6 +39,6 @@ "utility-types": "^3.10.0" }, "peerDependencies": { - "@parcel/core": "^2.0.0-alpha.3.1" + "@parcel/core": "^2.0.0" } } diff --git a/packages/core/fs/src/MemoryFS.js b/packages/core/fs/src/MemoryFS.js index 890ff79d23d..93e25fe701b 100644 --- a/packages/core/fs/src/MemoryFS.js +++ b/packages/core/fs/src/MemoryFS.js @@ -138,10 +138,7 @@ export class MemoryFS implements FileSystem { // get realpath by following symlinks if (realpath) { let {root, dir, base} = path.parse(filePath); - let parts = dir - .slice(root.length) - .split(path.sep) - .concat(base); + let parts = dir.slice(root.length).split(path.sep).concat(base); let res = root; for (let part of parts) { res = path.join(res, part); diff --git a/packages/core/fs/src/OverlayFS.js b/packages/core/fs/src/OverlayFS.js index 375c0dffc3a..1dd40800a18 100644 --- a/packages/core/fs/src/OverlayFS.js +++ b/packages/core/fs/src/OverlayFS.js @@ -14,7 +14,7 @@ import packageJSON from '../package.json'; import {findAncestorFile, findNodeModule, findFirstFile} from './find'; function read(method) { - return async function(...args: Array) { + return async function (...args: Array) { try { return await this.writable[method](...args); } catch (err) { @@ -24,7 +24,7 @@ function read(method) { } function readSync(method) { - return function(...args: Array) { + return function (...args: Array) { try { return this.writable[method](...args); } catch (err) { @@ -34,13 +34,13 @@ function readSync(method) { } function write(method) { - return function(...args: Array) { + return function (...args: Array) { return this.writable[method](...args); }; } function checkExists(method) { - return function(filePath: FilePath, ...args: Array) { + return function (filePath: FilePath, ...args: Array) { if (this.writable.existsSync(filePath)) { return this.writable[method](filePath, ...args); } @@ -69,9 +69,8 @@ export class OverlayFS implements FileSystem { }; } - readFile: ( - ...args: Array - ) => Promise> = read('readFile'); + readFile: (...args: Array) => Promise> = + read('readFile'); writeFile: (...args: Array) => any = write('writeFile'); async copyFile(source: FilePath, destination: FilePath) { if (await this.writable.exists(source)) { @@ -86,30 +85,25 @@ export class OverlayFS implements FileSystem { ); } } - stat: ( - ...args: Array - ) => Promise> = read('stat'); + stat: (...args: Array) => Promise> = + read('stat'); unlink: (...args: Array) => any = write('unlink'); mkdirp: (...args: Array) => any = write('mkdirp'); rimraf: (...args: Array) => any = write('rimraf'); ncp: (...args: Array) => any = write('ncp'); - createReadStream: ( - filePath: FilePath, - ...args: Array - ) => any = checkExists('createReadStream'); + createReadStream: (filePath: FilePath, ...args: Array) => any = + checkExists('createReadStream'); createWriteStream: (...args: Array) => any = write('createWriteStream'); cwd: (...args: Array) => any = readSync('cwd'); chdir: (...args: Array) => any = readSync('chdir'); - realpath: (filePath: FilePath, ...args: Array) => any = checkExists( - 'realpath', - ); + realpath: (filePath: FilePath, ...args: Array) => any = + checkExists('realpath'); readFileSync: (...args: Array) => any = readSync('readFileSync'); statSync: (...args: Array) => any = readSync('statSync'); existsSync: (...args: Array) => any = readSync('existsSync'); - realpathSync: (filePath: FilePath, ...args: Array) => any = checkExists( - 'realpathSync', - ); + realpathSync: (filePath: FilePath, ...args: Array) => any = + checkExists('realpathSync'); async exists(filePath: FilePath): Promise { return ( diff --git a/packages/core/graph/package.json b/packages/core/graph/package.json index 48cf3915825..ffc43b2c8d9 100644 --- a/packages/core/graph/package.json +++ b/packages/core/graph/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/graph", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { diff --git a/packages/core/integration-tests/package.json b/packages/core/integration-tests/package.json index 00185cbecc6..a8faae6a5af 100644 --- a/packages/core/integration-tests/package.json +++ b/packages/core/integration-tests/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/integration-tests", - "version": "2.0.0-rc.0", + "version": "2.0.1", "private": true, "license": "MIT", "repository": { @@ -28,6 +28,7 @@ "cross-env": "^7.0.0", "elm": "^0.19.1-5", "elm-hot": "^1.1.5", + "exif-reader": "^1.0.3", "get-port": "^5.0.0", "graphql": "^15.0.0", "http-proxy-middleware": "^1.0.0", @@ -40,7 +41,7 @@ "ncp": "^2.0.0", "nib": "^1.1.2", "node-elm-compiler": "^5.0.5", - "parcel": "2.0.0-rc.0", + "parcel": "^2.0.1", "postcss": "^8.3.0", "postcss-custom-properties": "^11.0.0", "postcss-import": "^14.0.2", diff --git a/packages/core/integration-tests/test/api.js b/packages/core/integration-tests/test/api.js index 97ecfd92002..b2327e9d708 100644 --- a/packages/core/integration-tests/test/api.js +++ b/packages/core/integration-tests/test/api.js @@ -3,8 +3,8 @@ import path from 'path'; import assert from 'assert'; import {distDir, bundle, assertBundles, outputFS} from '@parcel/test-utils'; -describe('JS API', function() { - it('should respect distEntry', async function() { +describe('JS API', function () { + it('should respect distEntry', async function () { const NAME = 'custom-name.js'; let b = await bundle( @@ -27,7 +27,7 @@ describe('JS API', function() { assert(await outputFS.exists(path.join(distDir, NAME))); }); - it('should run additional reports from the options', async function() { + it('should run additional reports from the options', async function () { let b = await bundle( path.join(__dirname, '/integration/js-comment/index.js'), { diff --git a/packages/core/integration-tests/test/babel.js b/packages/core/integration-tests/test/babel.js index 09fe260eb6f..53c2f3d912a 100644 --- a/packages/core/integration-tests/test/babel.js +++ b/packages/core/integration-tests/test/babel.js @@ -21,9 +21,9 @@ import {md} from '@parcel/diagnostic'; const parcelCli = require.resolve('parcel/src/bin.js'); const inputDir = path.join(__dirname, '/input'); -describe('babel', function() { +describe('babel', function () { let subscription; - beforeEach(async function() { + beforeEach(async function () { // TODO maybe don't do this for all tests await sleep(100); await outputFS.rimraf(inputDir); @@ -38,7 +38,7 @@ describe('babel', function() { } }); - it.skip('should auto install @babel/core v7', async function() { + it.skip('should auto install @babel/core v7', async function () { let originalPkg = await fs.readFile( __dirname + '/integration/babel-7-autoinstall/package.json', ); @@ -61,7 +61,7 @@ describe('babel', function() { ); }); - it.skip('should auto install babel plugins', async function() { + it.skip('should auto install babel plugins', async function () { let originalPkg = await fs.readFile( __dirname + '/integration/babel-plugin-autoinstall/package.json', ); @@ -89,7 +89,7 @@ describe('babel', function() { ); }); - it('should support compiling with babel using .babelrc config', async function() { + it('should support compiling with babel using .babelrc config', async function () { await bundle(path.join(__dirname, '/integration/babelrc-custom/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); @@ -97,7 +97,7 @@ describe('babel', function() { assert(file.includes('hello there')); }); - it('should support compiling with babel using babel.config.json config without warnings', async function() { + it('should support compiling with babel using babel.config.json config without warnings', async function () { let messages = []; let loggerDisposable = Logger.onLog(message => { messages.push(message); @@ -116,12 +116,14 @@ describe('babel', function() { assert.deepEqual(messages, []); }); - it.skip('should support compiling with babel using browserslist for different environments', async function() { + it.skip('should support compiling with babel using browserslist for different environments', async function () { async function testBrowserListMultipleEnv(projectBasePath) { // Transpiled destructuring, like r = p.prop1, o = p.prop2, a = p.prop3; - const prodRegExp = /\S+ ?= ?\S+\.prop1,\s*?\S+ ?= ?\S+\.prop2,\s*?\S+ ?= ?\S+\.prop3;/; + const prodRegExp = + /\S+ ?= ?\S+\.prop1,\s*?\S+ ?= ?\S+\.prop2,\s*?\S+ ?= ?\S+\.prop3;/; // ES6 Destructuring, like in the source; - const devRegExp = /const ?{\s*prop1(:.+)?,\s*prop2(:.+)?,\s*prop3(:.+)?\s*} ?= ?.*/; + const devRegExp = + /const ?{\s*prop1(:.+)?,\s*prop2(:.+)?,\s*prop3(:.+)?\s*} ?= ?.*/; let file; // Dev build test await bundle(path.join(__dirname, projectBasePath, '/index.js')); @@ -147,7 +149,7 @@ describe('babel', function() { ); }); - it.skip('should compile node_modules with browserslist to app target', async function() { + it.skip('should compile node_modules with browserslist to app target', async function () { await bundle( path.join( __dirname, @@ -160,7 +162,7 @@ describe('babel', function() { assert(file.includes('function Bar')); }); - it('should strip away flow types', async function() { + it('should strip away flow types', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-strip-flow-types/index.js'), ); @@ -173,7 +175,7 @@ describe('babel', function() { assert(!file.includes('OptionsType')); }); - it('should support compiling with babel using babel.config.js config', async function() { + it('should support compiling with babel using babel.config.js config', async function () { await bundle( path.join(__dirname, '/integration/babel-config-js/src/index.js'), ); @@ -183,7 +185,7 @@ describe('babel', function() { assert(file.match(/return \d+;/)); }); - it('should support compiling with babel using babel.config.js config with a require in it', async function() { + it('should support compiling with babel using babel.config.js config with a require in it', async function () { await bundle( path.join(__dirname, '/integration/babel-config-js-require/src/index.js'), ); @@ -193,7 +195,7 @@ describe('babel', function() { assert(file.match(/return \d+;/)); }); - it('should support multitarget builds using a custom babel config with @parcel/babel-preset-env', async function() { + it('should support multitarget builds using a custom babel config with @parcel/babel-preset-env', async function () { let fixtureDir = path.join( __dirname, '/integration/babel-config-js-multitarget', @@ -215,7 +217,7 @@ describe('babel', function() { await outputFS.rimraf(path.join(fixtureDir, 'dist')); }); - it('should support multitarget builds using a custom babel config with @parcel/babel-plugin-transform-runtime', async function() { + it('should support multitarget builds using a custom babel config with @parcel/babel-plugin-transform-runtime', async function () { let fixtureDir = path.join( __dirname, '/integration/babel-config-js-multitarget-transform-runtime', @@ -240,7 +242,7 @@ describe('babel', function() { await outputFS.rimraf(path.join(fixtureDir, 'dist')); }); - it('should support building with custom babel config when running parcel globally', async function() { + it('should support building with custom babel config when running parcel globally', async function () { let tmpDir = tempy.directory(); let distDir = path.join(tmpDir, 'dist'); await fs.ncp( @@ -263,7 +265,7 @@ describe('babel', function() { assert(file.includes('hello there')); }); - it('should support merging .babelrc and babel.config.json in a monorepo', async function() { + it('should support merging .babelrc and babel.config.json in a monorepo', async function () { await bundle( path.join( __dirname, @@ -373,7 +375,7 @@ describe('babel', function() { } }); - it('should rebuild when .babelrc changes', async function() { + it('should rebuild when .babelrc changes', async function () { let inputDir = tempy.directory(); let differentPath = path.join(inputDir, 'differentConfig'); let configPath = path.join(inputDir, '.babelrc'); @@ -407,7 +409,7 @@ describe('babel', function() { assert(distFile.includes('something different')); }); - it('should invalidate babel.config.js across runs', async function() { + it('should invalidate babel.config.js across runs', async function () { let dateRe = /return (\d+);/; let fixtureDir = path.join(__dirname, '/integration/babel-config-js'); @@ -452,7 +454,7 @@ describe('babel', function() { assert.notEqual(firstDatestamp, secondDatestamp); }); - it('should invalidate when babel plugins are upgraded across runs', async function() { + it('should invalidate when babel plugins are upgraded across runs', async function () { let fixtureDir = path.join( __dirname, '/integration/babel-plugin-upgrade', @@ -502,7 +504,7 @@ describe('babel', function() { }); }); - it('should enable shippedProposals with @parcel/babel-preset-env in custom babelrc', async function() { + it('should enable shippedProposals with @parcel/babel-preset-env in custom babelrc', async function () { let b = await bundle( path.join( __dirname, @@ -518,7 +520,7 @@ describe('babel', function() { assert.strictEqual(output.default, 123); }); - it('should compile with custom babel plugin plus default transforms', async function() { + it('should compile with custom babel plugin plus default transforms', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/index.js'), ); @@ -533,7 +535,7 @@ describe('babel', function() { assert.strictEqual(output.default, 'hello'); }); - it('should compile with custom babel plugin and jsx', async function() { + it('should compile with custom babel plugin and jsx', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/jsx.js'), ); @@ -543,7 +545,7 @@ describe('babel', function() { assert(file.includes('React.createElement')); }); - it('should compile with custom babel plugin and typescript', async function() { + it('should compile with custom babel plugin and typescript', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/ts.ts'), ); @@ -559,7 +561,7 @@ describe('babel', function() { assert.strictEqual(output.default, 'hello'); }); - it('should compile with custom babel plugin and tsx', async function() { + it('should compile with custom babel plugin and tsx', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-custom/tsx.tsx'), ); @@ -570,7 +572,7 @@ describe('babel', function() { assert(file.includes('React.createElement')); }); - it('should warn when a babel config contains only redundant plugins', async function() { + it('should warn when a babel config contains only redundant plugins', async function () { let messages = []; let loggerDisposable = Logger.onLog(message => { messages.push(message); @@ -613,7 +615,7 @@ describe('babel', function() { md`Delete __${path.relative(process.cwd(), babelrcPath)}__`, ], documentationURL: - 'https://v2.parceljs.org/languages/javascript/#default-presets', + 'https://parceljs.org/languages/javascript/#default-presets', }, { origin: '@parcel/transformer-babel', @@ -641,14 +643,14 @@ describe('babel', function() { "Either remove __@babel/preset-env__ to use Parcel's builtin transpilation, or replace with __@parcel/babel-preset-env__", ], documentationURL: - 'https://v2.parceljs.org/languages/javascript/#custom-plugins', + 'https://parceljs.org/languages/javascript/#custom-plugins', }, ], }, ]); }); - it('should warn when a babel config contains redundant plugins', async function() { + it('should warn when a babel config contains redundant plugins', async function () { let messages = []; let loggerDisposable = Logger.onLog(message => { messages.push(message); @@ -697,7 +699,7 @@ describe('babel', function() { )}__`, ], documentationURL: - 'https://v2.parceljs.org/languages/javascript/#default-presets', + 'https://parceljs.org/languages/javascript/#default-presets', }, ], }, diff --git a/packages/core/integration-tests/test/bundler.js b/packages/core/integration-tests/test/bundler.js index 87929278e1e..13c1cca56f9 100644 --- a/packages/core/integration-tests/test/bundler.js +++ b/packages/core/integration-tests/test/bundler.js @@ -8,8 +8,8 @@ import { nextBundle, } from '@parcel/test-utils'; -describe.skip('bundler', function() { - it('should bundle once before exporting middleware', async function() { +describe.skip('bundler', function () { + it('should bundle once before exporting middleware', async function () { let b = bundler( path.join(__dirname, '/integration/bundler-middleware/index.js'), ); @@ -58,7 +58,7 @@ describe.skip('bundler', function() { }, 'before bundling'); }); - it('should support multiple entry points', async function() { + it('should support multiple entry points', async function () { let b = await bundle([ path.join(__dirname, '/integration/multi-entry/one.html'), path.join(__dirname, '/integration/multi-entry/two.html'), @@ -83,7 +83,7 @@ describe.skip('bundler', function() { ]); }); - it('should support multiple entry points as a glob', async function() { + it('should support multiple entry points as a glob', async function () { let b = await bundle( path.join(__dirname, '/integration/multi-entry/*.html'), ); diff --git a/packages/core/integration-tests/test/cache.js b/packages/core/integration-tests/test/cache.js index ab8b81980aa..817f6c1f5ba 100644 --- a/packages/core/integration-tests/test/cache.js +++ b/packages/core/integration-tests/test/cache.js @@ -107,7 +107,7 @@ async function testCache(update: UpdateFn | TestConfig, integration) { return b; } -describe('cache', function() { +describe('cache', function () { before(async () => { await inputFS.rimraf(path.join(__dirname, 'input')); }); @@ -116,13 +116,11 @@ describe('cache', function() { inputDir = path.join( __dirname, '/input', - Math.random() - .toString(36) - .slice(2), + Math.random().toString(36).slice(2), ); }); - it('should support updating a JS file', async function() { + it('should support updating a JS file', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -134,7 +132,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - it('should support adding a dependency', async function() { + it('should support adding a dependency', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -150,7 +148,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 8); }); - it('should support adding a dependency which changes the referenced bundles of a parent bundle', async function() { + it('should support adding a dependency which changes the referenced bundles of a parent bundle', async function () { async function exec(bundleGraph) { let calls = []; await run(bundleGraph, { @@ -178,7 +176,7 @@ describe('cache', function() { assert.deepEqual(await exec(b.bundleGraph), ['b', 'a']); }); - it('should error when deleting a file', async function() { + it('should error when deleting a file', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -190,7 +188,7 @@ describe('cache', function() { ); }); - it('should error when starting parcel from a broken state with no changes', async function() { + it('should error when starting parcel from a broken state with no changes', async function () { // $FlowFixMe await assert.rejects(async () => { await testCache(async () => { @@ -208,7 +206,7 @@ describe('cache', function() { ); }); - describe('babel', function() { + describe('babel', function () { let json = config => JSON.stringify(config); let cjs = config => `module.exports = ${JSON.stringify(config)}`; // TODO: not sure how to invalidate the ESM cache in node... @@ -235,8 +233,8 @@ describe('cache', function() { }); for (let {name, formatter, nesting} of configs) { - describe(name, function() { - it(`should support adding a ${name}`, async function() { + describe(name, function () { + it(`should support adding a ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -283,7 +281,7 @@ describe('cache', function() { ); }); - it(`should support updating a ${name}`, async function() { + it(`should support updating a ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -334,7 +332,7 @@ describe('cache', function() { ); }); - it(`should support deleting a ${name}`, async function() { + it(`should support deleting a ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -377,7 +375,7 @@ describe('cache', function() { ); }); - it(`should support updating an extended ${name}`, async function() { + it(`should support updating an extended ${name}`, async function () { let extendedName = '.babelrc-extended' + path.extname(name); let b = await testCache({ // Babel's config loader only works with the node filesystem @@ -436,7 +434,7 @@ describe('cache', function() { }); if (nesting) { - it(`should support adding a nested ${name}`, async function() { + it(`should support adding a nested ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -491,7 +489,7 @@ describe('cache', function() { ); }); - it(`should support updating a nested ${name}`, async function() { + it(`should support updating a nested ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -550,7 +548,7 @@ describe('cache', function() { ); }); - it(`should support deleting a nested ${name}`, async function() { + it(`should support deleting a nested ${name}`, async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -604,8 +602,8 @@ describe('cache', function() { }); } - describe('.babelignore', function() { - it('should support adding a .babelignore', async function() { + describe('.babelignore', function () { + it('should support adding a .babelignore', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -660,7 +658,7 @@ describe('cache', function() { ); }); - it('should support updating a .babelignore', async function() { + it('should support updating a .babelignore', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -715,7 +713,7 @@ describe('cache', function() { ); }); - it('should support deleting a .babelignore', async function() { + it('should support deleting a .babelignore', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -768,8 +766,8 @@ describe('cache', function() { }); }); - describe('plugins', function() { - it('should invalidate when plugins are updated', async function() { + describe('plugins', function () { + it('should invalidate when plugins are updated', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -842,7 +840,7 @@ describe('cache', function() { assert(contents.includes('replaced'), 'string should be replaced'); }); - it('should invalidate when there are relative plugins', async function() { + it('should invalidate when there are relative plugins', async function () { let b = await testCache({ // Babel's config loader only works with the node filesystem inputFS, @@ -899,7 +897,7 @@ describe('cache', function() { assert(contents.includes('replaced'), 'string should be replaced'); }); - it('should invalidate when there are symlinked plugins', async function() { + it('should invalidate when there are symlinked plugins', async function () { // Symlinks don't work consistently on windows. Skip this test. if (process.platform === 'win32') { this.skip(); @@ -982,8 +980,8 @@ describe('cache', function() { }); }); - describe('parcel config', function() { - it('should support adding a .parcelrc', async function() { + describe('parcel config', function () { + it('should support adding a .parcelrc', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); @@ -1011,7 +1009,7 @@ describe('cache', function() { assert(contents.includes('TRANSFORMED CODE')); }); - it('should support updating a .parcelrc', async function() { + it('should support updating a .parcelrc', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -1049,7 +1047,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support updating an extended .parcelrc', async function() { + it('should support updating an extended .parcelrc', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -1094,7 +1092,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should error when deleting an extended parcelrc', async function() { + it('should error when deleting an extended parcelrc', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -1132,7 +1130,7 @@ describe('cache', function() { ); }); - it('should support deleting a .parcelrc', async function() { + it('should support deleting a .parcelrc', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -1166,8 +1164,8 @@ describe('cache', function() { }); }); - describe('transformations', function() { - it('should invalidate when included files changes', async function() { + describe('transformations', function () { + it('should invalidate when included files changes', async function () { let b = await testCache({ // TODO: update when the fs transform supports the MemoryFS inputFS, @@ -1273,7 +1271,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), undefined); }); - it('should invalidate when environment variables change', async function() { + it('should invalidate when environment variables change', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile(path.join(inputDir, '.env'), 'TEST=hi'); @@ -1297,8 +1295,8 @@ describe('cache', function() { }); }); - describe('entries', function() { - it('should support adding an entry that matches a glob', async function() { + describe('entries', function () { + it('should support adding an entry that matches a glob', async function () { let b = await testCache({ entries: ['src/entries/*.js'], async update(b) { @@ -1336,7 +1334,7 @@ describe('cache', function() { ]); }); - it('should support deleting an entry that matches a glob', async function() { + it('should support deleting an entry that matches a glob', async function () { let b = await testCache({ entries: ['src/entries/*.js'], async update(b) { @@ -1363,7 +1361,7 @@ describe('cache', function() { ]); }); - it('should error when deleting a file entry', async function() { + it('should error when deleting a file entry', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -1380,7 +1378,7 @@ describe('cache', function() { ); }); - it('should recover from errors when adding a missing entry', async function() { + it('should recover from errors when adding a missing entry', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -1406,8 +1404,8 @@ describe('cache', function() { }); }); - describe('target config', function() { - it('should support adding a target config', async function() { + describe('target config', function () { + it('should support adding a target config', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -1443,7 +1441,7 @@ describe('cache', function() { assert(contents.includes('export '), 'should include export'); }); - it('should support adding a second target', async function() { + it('should support adding a second target', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1507,7 +1505,7 @@ describe('cache', function() { ]); }); - it('should support changing target output location', async function() { + it('should support changing target output location', async function () { let pkgFile = path.join(inputDir, 'package.json'); await testCache({ defaultTargetOptions: { @@ -1576,7 +1574,7 @@ describe('cache', function() { ); }); - it('should support updating target config options', async function() { + it('should support updating target config options', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1629,7 +1627,7 @@ describe('cache', function() { ); }); - it('should support deleting a target', async function() { + it('should support deleting a target', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1693,7 +1691,7 @@ describe('cache', function() { ]); }); - it('should support deleting all targets', async function() { + it('should support deleting all targets', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1773,7 +1771,7 @@ describe('cache', function() { ); }); - it('should update when sourcemap options change', async function() { + it('should update when sourcemap options change', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1830,7 +1828,7 @@ describe('cache', function() { ); }); - it('should update when publicUrl changes', async function() { + it('should update when publicUrl changes', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ entries: ['src/index.html'], @@ -1888,7 +1886,7 @@ describe('cache', function() { ); }); - it('should update when a package.json is created', async function() { + it('should update when a package.json is created', async function () { let pkgFile = path.join(inputDir, 'package.json'); let pkg; let b = await testCache({ @@ -1928,7 +1926,7 @@ describe('cache', function() { assert(contents.includes('export '), 'should include export'); }); - it('should update when a package.json is deleted', async function() { + it('should update when a package.json is deleted', async function () { let pkgFile = path.join(inputDir, 'package.json'); let b = await testCache({ defaultTargetOptions: { @@ -1966,8 +1964,8 @@ describe('cache', function() { assert(!contents.includes('export '), 'does not include export'); }); - describe('browserslist', function() { - it('should update when a browserslist file is added', async function() { + describe('browserslist', function () { + it('should update when a browserslist file is added', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -1998,7 +1996,7 @@ describe('cache', function() { ); }); - it('should update when a .browserslistrc file is added', async function() { + it('should update when a .browserslistrc file is added', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2029,7 +2027,7 @@ describe('cache', function() { ); }); - it('should update when a browserslist is updated', async function() { + it('should update when a browserslist is updated', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2066,7 +2064,7 @@ describe('cache', function() { ); }); - it('should update when a browserslist is deleted', async function() { + it('should update when a browserslist is deleted', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2100,7 +2098,7 @@ describe('cache', function() { ); }); - it('should update when BROWSERSLIST_ENV changes', async function() { + it('should update when BROWSERSLIST_ENV changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2146,7 +2144,7 @@ describe('cache', function() { delete process.env.BROWSERSLIST_ENV; }); - it('should update when NODE_ENV changes', async function() { + it('should update when NODE_ENV changes', async function () { let env = process.env.NODE_ENV; let b = await testCache({ defaultTargetOptions: { @@ -2195,8 +2193,8 @@ describe('cache', function() { }); }); - describe('options', function() { - it('should update when publicUrl changes', async function() { + describe('options', function () { + it('should update when publicUrl changes', async function () { let b = await testCache({ entries: ['src/index.html'], defaultTargetOptions: { @@ -2233,21 +2231,23 @@ describe('cache', function() { ); }); - it('should update when minify changes', async function() { + it('should update when minify changes', async function () { let b = await testCache({ + entries: ['src/index.html'], defaultTargetOptions: { shouldScopeHoist: true, shouldOptimize: false, }, async update(b) { let contents = await overlayFS.readFile( - b.bundleGraph.getBundles()[0].filePath, + b.bundleGraph.getBundles()[1].filePath, 'utf8', ); assert(contents.includes('Test'), 'should include Test'); return { defaultTargetOptions: { + shouldScopeHoist: true, shouldOptimize: true, }, }; @@ -2255,13 +2255,13 @@ describe('cache', function() { }); let contents = await overlayFS.readFile( - b.bundleGraph.getBundles()[0].filePath, + b.bundleGraph.getBundles()[1].filePath, 'utf8', ); assert(!contents.includes('Test'), 'should not include Test'); }); - it('should update when scopeHoist changes', async function() { + it('should update when scopeHoist changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: false, @@ -2291,7 +2291,7 @@ describe('cache', function() { assert(!contents.includes('parcelRequire'), 'should not include Test'); }); - it('should update when sourceMaps changes', async function() { + it('should update when sourceMaps changes', async function () { let b = await testCache({ defaultTargetOptions: { sourceMaps: false, @@ -2324,7 +2324,7 @@ describe('cache', function() { ); }); - it('should update when distDir changes', async function() { + it('should update when distDir changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2351,7 +2351,7 @@ describe('cache', function() { ); }); - it('should update when targets changes', async function() { + it('should update when targets changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2419,7 +2419,7 @@ describe('cache', function() { ); }); - it('should update when defaultEngines changes', async function() { + it('should update when defaultEngines changes', async function () { let b = await testCache({ defaultTargetOptions: { shouldScopeHoist: true, @@ -2458,7 +2458,7 @@ describe('cache', function() { ); }); - it('should update when shouldContentHash changes', async function() { + it('should update when shouldContentHash changes', async function () { let b = await testCache({ entries: ['src/index.html'], defaultTargetOptions: { @@ -2479,7 +2479,7 @@ describe('cache', function() { assert(bundle.filePath.includes(bundle.id.slice(-8))); }); - it('should update when hmr options change', async function() { + it('should update when hmr options change', async function () { let b = await testCache({ hmrOptions: { host: 'localhost', @@ -2534,7 +2534,7 @@ describe('cache', function() { ); }); - it('should invalidate react refresh hot options change', async function() { + it('should invalidate react refresh hot options change', async function () { let b = await testCache({ async setup() { let pkgFile = path.join(inputDir, 'package.json'); @@ -2587,7 +2587,7 @@ describe('cache', function() { ); }); - it('should update when the config option changes', async function() { + it('should update when the config option changes', async function () { let b = await testCache({ async update(b) { let contents = await overlayFS.readFile( @@ -2619,7 +2619,7 @@ describe('cache', function() { assert(contents.includes('TRANSFORMED CODE')); }); - it('should update when the defaultConfig option changes', async function() { + it('should update when the defaultConfig option changes', async function () { let b = await testCache({ async update(b) { let contents = await overlayFS.readFile( @@ -2651,7 +2651,7 @@ describe('cache', function() { assert(contents.includes('TRANSFORMED CODE')); }); - it('should update env browserslist in package.json when mode changes', async function() { + it('should update env browserslist in package.json when mode changes', async function () { let env = process.env.NODE_ENV; delete process.env.NODE_ENV; try { @@ -2701,8 +2701,8 @@ describe('cache', function() { }); }); - describe('resolver', function() { - it('should support updating a package.json#main field', async function() { + describe('resolver', function () { + it('should support updating a package.json#main field', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -2719,7 +2719,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 8); }); - it('should support adding an alias', async function() { + it('should support adding an alias', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -2741,7 +2741,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 8); }); - it('should support updating an alias', async function() { + it('should support updating an alias', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -2781,7 +2781,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 12); }); - it('should support deleting an alias', async function() { + it('should support deleting an alias', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -2811,7 +2811,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support adding an alias in a closer package.json', async function() { + it('should support adding an alias in a closer package.json', async function () { let b = await testCache(async b => { assert.equal(await run(b.bundleGraph), 4); await overlayFS.writeFile( @@ -2832,7 +2832,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - it('should support adding a file with a higher priority extension', async function() { + it('should support adding a file with a higher priority extension', async function () { let b = await testCache({ async setup() { // Start out pointing to a .ts file from a .js file @@ -2863,7 +2863,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support renaming a file to a different extension', async function() { + it('should support renaming a file to a different extension', async function () { let b = await testCache({ async setup() { // Start out pointing to a .js file @@ -2896,7 +2896,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should resolve to a file over a directory with an index.js', async function() { + it('should resolve to a file over a directory with an index.js', async function () { let b = await testCache({ async setup() { let contents = await overlayFS.readFile( @@ -2925,7 +2925,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should resolve to package.json#main over an index.js', async function() { + it('should resolve to package.json#main over an index.js', async function () { let b = await testCache({ async setup() { let contents = await overlayFS.readFile( @@ -2956,7 +2956,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should recover from errors when adding a missing dependency', async function() { + it('should recover from errors when adding a missing dependency', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -2981,7 +2981,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - it('should recover from a missing package.json#main', async function() { + it('should recover from a missing package.json#main', async function () { let b = await testCache({ async setup() { let contents = await overlayFS.readFile( @@ -3018,7 +3018,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 10); }); - it('should recover from an invalid package.json', async function() { + it('should recover from an invalid package.json', async function () { // $FlowFixMe await assert.rejects(async () => { await testCache({ @@ -3057,7 +3057,7 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 4); }); - it('should support adding a deeper node_modules folder', async function() { + it('should support adding a deeper node_modules folder', async function () { let b = await testCache({ async update(b) { assert.equal(await run(b.bundleGraph), 4); @@ -3076,8 +3076,8 @@ describe('cache', function() { assert.equal(await run(b.bundleGraph), 6); }); - describe('pnp', function() { - it('should invalidate when the .pnp.js file changes', async function() { + describe('pnp', function () { + it('should invalidate when the .pnp.js file changes', async function () { let Module = require('module'); let origPnpVersion = process.versions.pnp; // $FlowFixMe[prop-missing] @@ -3140,8 +3140,8 @@ describe('cache', function() { }); }); - describe('stylus', function() { - it('should support resolver inside stylus file', async function() { + describe('stylus', function () { + it('should support resolver inside stylus file', async function () { let b = await testCache( { entries: ['index.js'], @@ -3195,7 +3195,7 @@ describe('cache', function() { assert(css.includes('.c {')); }); - it('should support stylus default resolver', async function() { + it('should support stylus default resolver', async function () { let b = await testCache( { entries: ['index.js'], @@ -3236,7 +3236,7 @@ describe('cache', function() { assert(css.includes('.b {')); }); - it('should support glob imports in stylus files', async function() { + it('should support glob imports in stylus files', async function () { let b = await testCache( { entries: ['index.js'], @@ -3283,7 +3283,7 @@ describe('cache', function() { assert(css.includes('.foo-test')); }); - it('should support glob imports under stylus paths', async function() { + it('should support glob imports under stylus paths', async function () { let b = await testCache( { entries: ['index.js'], @@ -3349,8 +3349,8 @@ describe('cache', function() { }); }); - describe('less', function() { - it('should support adding higher priority less include paths', async function() { + describe('less', function () { + it('should support adding higher priority less include paths', async function () { let b = await testCache( { entries: ['index.js'], @@ -3399,7 +3399,7 @@ describe('cache', function() { assert(css.includes('.d')); }); - it('should recover from missing import errors', async function() { + it('should recover from missing import errors', async function () { // $FlowFixMe await assert.rejects( async () => { @@ -3450,8 +3450,8 @@ describe('cache', function() { }); }); - describe('sass', function() { - it('should support adding higher priority sass include paths', async function() { + describe('sass', function () { + it('should support adding higher priority sass include paths', async function () { let b = await testCache( { entries: ['index.sass'], @@ -3490,7 +3490,7 @@ describe('cache', function() { assert(css.includes('.test')); }); - it('should the SASS_PATH environment variable', async function() { + it('should the SASS_PATH environment variable', async function () { let b = await testCache( { entries: ['index.sass'], @@ -3532,7 +3532,7 @@ describe('cache', function() { assert(css.includes('.test')); }); - it('should recover from missing import errors', async function() { + it('should recover from missing import errors', async function () { // $FlowFixMe await assert.rejects(async () => { await testCache( @@ -3575,8 +3575,8 @@ describe('cache', function() { }); }); - describe('dev deps', function() { - it('should invalidate when updating a parcel transformer plugin', async function() { + describe('dev deps', function () { + it('should invalidate when updating a parcel transformer plugin', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -3615,7 +3615,7 @@ describe('cache', function() { assert(output.includes('UPDATED')); }); - it('should invalidate when updating a file required via options.packageManager.require', async function() { + it('should invalidate when updating a file required via options.packageManager.require', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -3668,7 +3668,7 @@ describe('cache', function() { assert(output.includes('FOO: 3')); }); - it('should resolve to package.json#main over an index.js', async function() { + it('should resolve to package.json#main over an index.js', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -3724,7 +3724,7 @@ describe('cache', function() { assert(output.includes('UPDATED')); }); - it('should resolve to a file over a directory with an index.js', async function() { + it('should resolve to a file over a directory with an index.js', async function () { let transformerDir = path.join( inputDir, 'node_modules', @@ -3770,9 +3770,9 @@ describe('cache', function() { assert(output.includes('UPDATED')); }); - it('should support adding a deeper node_modules folder', async function() {}); + it('should support adding a deeper node_modules folder', async function () {}); - it('should support yarn pnp', async function() { + it('should support yarn pnp', async function () { let Module = require('module'); // $FlowFixMe[incompatible-type] let origPnpVersion = process.versions.pnp; @@ -3925,8 +3925,8 @@ describe('cache', function() { } }); - describe('postcss', function() { - it('should invalidate when a postcss plugin changes', async function() { + describe('postcss', function () { + it('should invalidate when a postcss plugin changes', async function () { let b = await testCache( { entries: ['index.css'], @@ -3974,7 +3974,7 @@ describe('cache', function() { assert(output.includes('background: blue')); }); - it('should invalidate when a JS postcss config changes', async function() { + it('should invalidate when a JS postcss config changes', async function () { let b = await testCache( { entries: ['style.css'], @@ -4013,7 +4013,7 @@ describe('cache', function() { assert(output.includes('background-color: blue')); }); - it('should invalidate when a JSON postcss config changes', async function() { + it('should invalidate when a JSON postcss config changes', async function () { let b = await testCache( { entries: ['nested/index.css'], @@ -4044,7 +4044,7 @@ describe('cache', function() { assert(output.includes('background-color: blue')); }); - it('should invalidate when a closer postcss config is added', async function() { + it('should invalidate when a closer postcss config is added', async function () { let b = await testCache( { entries: ['nested/index.css'], @@ -4076,8 +4076,8 @@ describe('cache', function() { }); }); - describe('posthtml', function() { - it('should invalidate when a posthtml plugin changes', async function() { + describe('posthtml', function () { + it('should invalidate when a posthtml plugin changes', async function () { let b = await testCache( { entries: ['index.html'], @@ -4125,7 +4125,7 @@ describe('cache', function() { assert(output.includes('
Test
')); }); - it('should invalidate when a JS postcss config changes', async function() { + it('should invalidate when a JS postcss config changes', async function () { let b = await testCache( { entries: ['index.html'], @@ -4172,8 +4172,8 @@ describe('cache', function() { }); }); - describe('bundling', function() { - it('should invalidate when switching to a different bundler plugin', async function() { + describe('bundling', function () { + it('should invalidate when switching to a different bundler plugin', async function () { let b = await testCache({ async update(b) { assert.equal(b.bundleGraph.getBundles().length, 1); @@ -4191,7 +4191,7 @@ describe('cache', function() { assert.equal(b.bundleGraph.getBundles().length, 4); }); - it('should invalidate when a bundler plugin is updated', async function() { + it('should invalidate when a bundler plugin is updated', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -4214,10 +4214,9 @@ describe('cache', function() { ); await overlayFS.writeFile( bundler, - (await overlayFS.readFile(bundler, 'utf8')).replace( - 'Boolean(dependency.isEntry)', - 'false', - ), + ( + await overlayFS.readFile(bundler, 'utf8') + ).replace('Boolean(dependency.isEntry)', 'false'), ); }, }); @@ -4226,7 +4225,7 @@ describe('cache', function() { assert(b.bundleGraph.getBundles()[0].name.includes('HASH_REF')); }); - it('should invalidate when adding a namer plugin', async function() { + it('should invalidate when adding a namer plugin', async function () { let b = await testCache({ async update(b) { let bundles = b.bundleGraph.getBundles().map(b => b.name); @@ -4249,7 +4248,7 @@ describe('cache', function() { ); }); - it('should invalidate when a namer plugin is updated', async function() { + it('should invalidate when a namer plugin is updated', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -4275,10 +4274,9 @@ describe('cache', function() { ); await overlayFS.writeFile( namer, - (await overlayFS.readFile(namer, 'utf8')).replace( - 'bundle.id', - 'bundle.id.slice(-8)', - ), + ( + await overlayFS.readFile(namer, 'utf8') + ).replace('bundle.id', 'bundle.id.slice(-8)'), ); }, }); @@ -4290,7 +4288,7 @@ describe('cache', function() { ); }); - it('should invalidate when adding a runtime plugin', async function() { + it('should invalidate when adding a runtime plugin', async function () { let b = await testCache({ async update(b) { let res = await run(b.bundleGraph, null, {require: false}); @@ -4310,7 +4308,7 @@ describe('cache', function() { assert.equal(res.runtime_test, true); }); - it('should invalidate when a runtime is updated', async function() { + it('should invalidate when a runtime is updated', async function () { let b = await testCache({ async setup() { await overlayFS.writeFile( @@ -4334,10 +4332,9 @@ describe('cache', function() { ); await overlayFS.writeFile( namer, - (await overlayFS.readFile(namer, 'utf8')).replace( - 'runtime_test', - 'test_runtime', - ), + ( + await overlayFS.readFile(namer, 'utf8') + ).replace('runtime_test', 'test_runtime'), ); }, }); @@ -4347,8 +4344,8 @@ describe('cache', function() { assert.equal(res.test_runtime, true); }); - describe('bundler config', function() { - it('should support adding bundler config', async function() { + describe('bundler config', function () { + it('should support adding bundler config', async function () { let b = await testCache( { entries: ['*.html'], @@ -4395,7 +4392,7 @@ describe('cache', function() { assert.equal(html.match(/ diff --git a/packages/core/integration-tests/test/integration/vue-external-files/main.pug b/packages/core/integration-tests/test/integration/vue-external-files/main.pug new file mode 100644 index 00000000000..3f8aacc9ed0 --- /dev/null +++ b/packages/core/integration-tests/test/integration/vue-external-files/main.pug @@ -0,0 +1,5 @@ +div + h1 foo + h2 bar + div.box + p {{ msg }} diff --git a/packages/core/integration-tests/test/integration/vue-external-files/script.ts b/packages/core/integration-tests/test/integration/vue-external-files/script.ts new file mode 100644 index 00000000000..1c588c46c0c --- /dev/null +++ b/packages/core/integration-tests/test/integration/vue-external-files/script.ts @@ -0,0 +1,7 @@ +export default { + data () { + return { + msg: 'Hello World' + } + } +} diff --git a/packages/core/integration-tests/test/integration/vue-external-files/style.scss b/packages/core/integration-tests/test/integration/vue-external-files/style.scss new file mode 100644 index 00000000000..a2c0d32288b --- /dev/null +++ b/packages/core/integration-tests/test/integration/vue-external-files/style.scss @@ -0,0 +1,24 @@ +$cool-color: #c0ff33; + +div { + h1 { + color: red; + } +} + +h2 { + color: blue; + + &:hover { + color: $cool-color; + } +} + +.box { + border: 1px solid black; + + p { + color: $cool-color; + font-size: 10rem; + } +} diff --git a/packages/core/integration-tests/test/integration/webextension/manifest.json b/packages/core/integration-tests/test/integration/webextension/manifest.json index 27045ce8634..19367f29f58 100644 --- a/packages/core/integration-tests/test/integration/webextension/manifest.json +++ b/packages/core/integration-tests/test/integration/webextension/manifest.json @@ -22,7 +22,7 @@ "default_popup": "src/popup.html" }, "content_scripts": [{ - "matches": ["https://v2.parceljs.org/*"], + "matches": ["https://parceljs.org/*"], "js": ["src/content.js"], "css": ["src/content.css"] }], diff --git a/packages/core/integration-tests/test/integration/xml/100x100.png b/packages/core/integration-tests/test/integration/xml/100x100.png new file mode 100644 index 00000000000..8a1daa0121d Binary files /dev/null and b/packages/core/integration-tests/test/integration/xml/100x100.png differ diff --git a/packages/core/integration-tests/test/integration/xml/atom-namespace.xml b/packages/core/integration-tests/test/integration/xml/atom-namespace.xml new file mode 100644 index 00000000000..aaa16f9bbdd --- /dev/null +++ b/packages/core/integration-tests/test/integration/xml/atom-namespace.xml @@ -0,0 +1,27 @@ + + + Example Feed + A subtitle. + + + urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6 + 2003-12-13T18:30:02Z + + Atom-Powered Robots Run Amok + + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + +
+

This is the entry content.

+ +
+
+ + John Doe + johndoe@example.com + +
+
diff --git a/packages/core/integration-tests/test/integration/xml/atom.xml b/packages/core/integration-tests/test/integration/xml/atom.xml new file mode 100644 index 00000000000..46bcea93106 --- /dev/null +++ b/packages/core/integration-tests/test/integration/xml/atom.xml @@ -0,0 +1,27 @@ + + + Example Feed + A subtitle. + + + urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6 + 2003-12-13T18:30:02Z + + Atom-Powered Robots Run Amok + + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + +
+

This is the entry content.

+ +
+
+ + John Doe + johndoe@example.com + +
+
diff --git a/packages/core/integration-tests/test/integration/xml/post.html b/packages/core/integration-tests/test/integration/xml/post.html new file mode 100644 index 00000000000..3f3f8c32cac --- /dev/null +++ b/packages/core/integration-tests/test/integration/xml/post.html @@ -0,0 +1,2 @@ + +

This is the post

diff --git a/packages/core/integration-tests/test/integration/xml/rss.xml b/packages/core/integration-tests/test/integration/xml/rss.xml new file mode 100644 index 00000000000..17849925859 --- /dev/null +++ b/packages/core/integration-tests/test/integration/xml/rss.xml @@ -0,0 +1,20 @@ + + + + RSS Title + This is an example of an RSS feed + http://www.example.com/main.html + 2020 Example.com All rights reserved + Mon, 06 Sep 2010 00:01:00 +0000 + Sun, 06 Sep 2009 16:20:00 +0000 + 1800 + + + Example entry + Here is some text containing an interesting description. <img src="100x100.png" /> + post.html + 7bd204c6-1655-4c27-aeee-53f933c5395f + Sun, 06 Sep 2009 16:20:00 +0000 + + + diff --git a/packages/core/integration-tests/test/javascript.js b/packages/core/integration-tests/test/javascript.js index e5f3e25ede9..5ed13c7b3e1 100644 --- a/packages/core/integration-tests/test/javascript.js +++ b/packages/core/integration-tests/test/javascript.js @@ -19,12 +19,12 @@ import {makeDeferredWithPromise, normalizePath} from '@parcel/utils'; import vm from 'vm'; import Logger from '@parcel/logger'; -describe('javascript', function() { +describe('javascript', function () { beforeEach(async () => { await removeDistDirectory(); }); - it('should produce a basic JS bundle with CommonJS requires', async function() { + it('should produce a basic JS bundle with CommonJS requires', async function () { let b = await bundle( path.join(__dirname, '/integration/commonjs/index.js'), ); @@ -37,7 +37,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should support url: imports with CommonJS output', async function() { + it('should support url: imports with CommonJS output', async function () { let b = await bundle( path.join(__dirname, '/integration/commonjs-import-url/index.js'), ); @@ -59,7 +59,7 @@ describe('javascript', function() { assert.strictEqual(path.basename(output), path.basename(txtBundle)); }); - it('should support url: imports of another javascript file', async function() { + it('should support url: imports of another javascript file', async function () { let b = await bundle( path.join(__dirname, '/integration/worklet/pipeline.js'), { @@ -105,7 +105,7 @@ describe('javascript', function() { assert.equal(name, 'checkerboard'); }); - it('should support new URL() of another javascript file', async function() { + it('should support new URL() of another javascript file', async function () { let b = await bundle(path.join(__dirname, '/integration/worklet/url.js')); assertBundles(b, [ @@ -137,7 +137,7 @@ describe('javascript', function() { assert.equal(name, 'checkerboard'); }); - it('should support CSS paint worklets', async function() { + it('should support CSS paint worklets', async function () { let b = await bundle( path.join(__dirname, '/integration/worklet/url-worklet.js'), ); @@ -180,7 +180,7 @@ describe('javascript', function() { assert.equal(name, 'checkerboard'); }); - it('should error on dynamic import() inside worklets', async function() { + it('should error on dynamic import() inside worklets', async function () { let errored = false; try { await bundle( @@ -240,7 +240,7 @@ describe('javascript', function() { assert(errored); }); - it('should support audio worklets via a pipeline', async function() { + it('should support audio worklets via a pipeline', async function () { let b = await bundle( path.join(__dirname, '/integration/worklet/worklet-pipeline.js'), { @@ -277,7 +277,7 @@ describe('javascript', function() { assert.equal(name, 'checkerboard'); }); - it('should error on dynamic import() inside worklets imported via a pipeline', async function() { + it('should error on dynamic import() inside worklets imported via a pipeline', async function () { let errored = false; try { await bundle( @@ -318,7 +318,7 @@ describe('javascript', function() { assert(errored); }); - it('should produce a basic JS bundle with ES6 imports', async function() { + it('should produce a basic JS bundle with ES6 imports', async function () { let b = await bundle(path.join(__dirname, '/integration/es6/index.js')); // assert.equal(b.assets.size, 8); @@ -341,7 +341,7 @@ describe('javascript', function() { assert(!contents.includes('import')); }); - it('should produce a basic JS bundle with object rest spread support', async function() { + it('should produce a basic JS bundle with object rest spread support', async function () { let b = await bundle( path.join( __dirname, @@ -361,7 +361,7 @@ describe('javascript', function() { assert.deepEqual(res.ys, {b: 'b'}); }); - it('should bundle node_modules for a browser environment', async function() { + it('should bundle node_modules for a browser environment', async function () { let b = await bundle( path.join(__dirname, '/integration/node_require_browser/main.js'), ); @@ -378,7 +378,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should not bundle node_modules for a node environment', async function() { + it('should not bundle node_modules for a node environment', async function () { let b = await bundle( path.join(__dirname, '/integration/node_require/main.js'), ); @@ -401,7 +401,7 @@ describe('javascript', function() { assert.equal(output(), 7); }); - it.skip('should not bundle node_modules on --target=electron', async function() { + it.skip('should not bundle node_modules on --target=electron', async function () { let b = await bundle( path.join(__dirname, '/integration/node_require/main.js'), { @@ -467,7 +467,7 @@ describe('javascript', function() { await outputFS.rimraf(path.join(fixturePath, 'dist')); }); - it('should bundle node_modules for a node environment if includeNodeModules is specified', async function() { + it('should bundle node_modules for a node environment if includeNodeModules is specified', async function () { let b = await bundle( path.join(__dirname, '/integration/include_node_modules/main.js'), ); @@ -484,7 +484,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should bundle builtins for a browser environment', async function() { + it('should bundle builtins for a browser environment', async function () { let b = await bundle( path.join(__dirname, '/integration/include_builtins-browser/main.js'), ); @@ -510,7 +510,7 @@ describe('javascript', function() { assert.deepEqual(Object.keys(fs), Object.keys({})); }); - it('should not bundle builtins for a node environment if includeNodeModules is specified', async function() { + it('should not bundle builtins for a node environment if includeNodeModules is specified', async function () { let b = await bundle( path.join(__dirname, '/integration/include_builtins-node/main.js'), ); @@ -529,7 +529,7 @@ describe('javascript', function() { assert.equal(typeof fs.readFile, 'function'); }); - it.skip('should bundle node_modules on --target=electron and --bundle-node-modules', async function() { + it.skip('should bundle node_modules on --target=electron and --bundle-node-modules', async function () { let b = await bundle( path.join(__dirname, '/integration/node_require/main.js'), { @@ -548,7 +548,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should produce a JS bundle with default exports and no imports', async function() { + it('should produce a JS bundle with default exports and no imports', async function () { let b = await bundle( path.join(__dirname, '/integration/es6-default-only/index.js'), ); @@ -562,7 +562,7 @@ describe('javascript', function() { assert.equal(output.default(), 3); }); - it('should split bundles when a dynamic import is used a browser environment', async function() { + it('should split bundles when a dynamic import is used a browser environment', async function () { let b = await bundle(path.join(__dirname, '/integration/dynamic/index.js')); assertBundles(b, [ @@ -580,7 +580,7 @@ describe('javascript', function() { assert.equal(await output(), 3); }); - it('should prefetch bundles when declared as an import attribute statically', async function() { + it('should prefetch bundles when declared as an import attribute statically', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-static-prefetch/index.js'), ); @@ -604,7 +604,7 @@ describe('javascript', function() { assert(headChildren[2].href.match(/prefetched\..*\.css/)); }); - it('should load additional links that were prefetched', async function() { + it('should load additional links that were prefetched', async function () { let b = await bundle( path.join( __dirname, @@ -633,7 +633,7 @@ describe('javascript', function() { assert(cssBundles[1].href.match(/prefetched-loaded\..*\.css/)); }); - it('should preload bundles when declared as an import attribute statically', async function() { + it('should preload bundles when declared as an import attribute statically', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-static-preload/index.js'), ); @@ -675,7 +675,7 @@ describe('javascript', function() { assert(!mainBundleContent.includes('foo:')); }); - it('should split bundles when a dynamic import is used with a node environment', async function() { + it('should split bundles when a dynamic import is used with a node environment', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-node/index.js'), ); @@ -695,7 +695,7 @@ describe('javascript', function() { assert.equal(await output(), 3); }); - it('should split bundles when a dynamic import is used with an electron-main environment', async function() { + it('should split bundles when a dynamic import is used with an electron-main environment', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-electron-main/index.js'), ); @@ -715,7 +715,7 @@ describe('javascript', function() { assert.equal(await output(), 3); }); - it('should split bundles when a dynamic import is used with an electron-renderer environment', async function() { + it('should split bundles when a dynamic import is used with an electron-renderer environment', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-electron-renderer/index.js'), ); @@ -735,7 +735,7 @@ describe('javascript', function() { assert.equal(await output(), 3); }); - it.skip('should load dynamic bundle when entry is in a subdirectory', async function() { + it.skip('should load dynamic bundle when entry is in a subdirectory', async function () { let bu = await bundler( path.join( __dirname, @@ -757,7 +757,7 @@ describe('javascript', function() { }); // TODO: re-enable when this actually works - it.skip('Should not run parcel over external modules', async function() { + it.skip('Should not run parcel over external modules', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-external/index.js'), ); @@ -770,7 +770,7 @@ describe('javascript', function() { ]); }); - it('should support bundling workers', async function() { + it('should support bundling workers', async function () { let b = await bundle(path.join(__dirname, '/integration/workers/index.js')); assertBundles(b, [ @@ -797,7 +797,7 @@ describe('javascript', function() { ]); }); - it('should support bundling workers with dynamic import', async function() { + it('should support bundling workers with dynamic import', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-dynamic/index.js'), ); @@ -828,7 +828,7 @@ describe('javascript', function() { assert.deepEqual(res, {default: 42}); }); - it('should support bundling workers with dynamic import with legacy browser targets', async function() { + it('should support bundling workers with dynamic import with legacy browser targets', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-dynamic/index.js'), { @@ -868,7 +868,7 @@ describe('javascript', function() { assert.deepEqual(res, {default: 42}); }); - it('should support bundling workers with dynamic import in both page and worker', async function() { + it('should support bundling workers with dynamic import in both page and worker', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-dynamic/index-async.js'), ); @@ -908,7 +908,7 @@ describe('javascript', function() { assert.deepEqual(res, {default: 42}); }); - it('should support bundling workers with dynamic import in nested worker', async function() { + it('should support bundling workers with dynamic import in nested worker', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-dynamic/index-nested.js'), ); @@ -948,7 +948,7 @@ describe('javascript', function() { assert.deepEqual(res, {default: 42}); }); - it('should support workers pointing to themselves', async function() { + it('should support workers pointing to themselves', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-self/index.js'), ); @@ -977,7 +977,7 @@ describe('javascript', function() { await run(b); }); - it('should support workers pointing to themselves with import.meta.url', async function() { + it('should support workers pointing to themselves with import.meta.url', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-self/import-meta.js'), ); @@ -1004,7 +1004,7 @@ describe('javascript', function() { await run(b); }); - it('should support bundling workers of type module', async function() { + it('should support bundling workers of type module', async function () { let b = await bundle( path.join(__dirname, '/integration/workers-module/index.js'), { @@ -1054,7 +1054,7 @@ describe('javascript', function() { shouldScopeHoist ? 'browsers do not support it' : 'shouldScopeHoist = false' - }`, async function() { + }`, async function () { let b = await bundle( path.join(__dirname, '/integration/workers-module/index.js'), { @@ -1118,7 +1118,7 @@ describe('javascript', function() { supported ? '' : 'non ' }modules when browsers do ${ supported ? '' : 'not ' - }support it with esmodule parent script`, async function() { + }support it with esmodule parent script`, async function () { let b = await bundle( path.join(__dirname, '/integration/workers-module/index.js'), { @@ -1178,7 +1178,7 @@ describe('javascript', function() { }); } - it('should preserve the name option to workers', async function() { + it('should preserve the name option to workers', async function () { let b = await bundle( path.join(__dirname, '/integration/workers-module/named.js'), { @@ -1196,7 +1196,7 @@ describe('javascript', function() { assert(/new SharedWorker(.*?, {[\n\s]+name: 'shared'[\n\s]+})/.test(main)); }); - it('should error if importing in a worker without type: module', async function() { + it('should error if importing in a worker without type: module', async function () { let errored = false; try { await bundle( @@ -1262,7 +1262,7 @@ describe('javascript', function() { "Add {type: 'module'} as a second argument to the Worker constructor.", ], documentationURL: - 'https://v2.parceljs.org/languages/javascript/#classic-scripts', + 'https://parceljs.org/languages/javascript/#classic-scripts', }, ]); } @@ -1270,7 +1270,7 @@ describe('javascript', function() { assert(errored); }); - it('should support bundling workers with different order', async function() { + it('should support bundling workers with different order', async function () { let b = await bundle( path.join(__dirname, '/integration/workers/index-alternative.js'), ); @@ -1300,7 +1300,7 @@ describe('javascript', function() { }); for (let workerType of ['webworker', 'serviceworker']) { - it(`should error when ${workerType}s use importScripts`, async function() { + it(`should error when ${workerType}s use importScripts`, async function () { let filePath = path.join( __dirname, `/integration/worker-import-scripts/index-${workerType}.js`, @@ -1367,7 +1367,7 @@ describe('javascript', function() { : 'navigator.serviceWorker.register() call.'), ], documentationURL: - 'https://v2.parceljs.org/languages/javascript/#classic-script-workers', + 'https://parceljs.org/languages/javascript/#classic-script-workers', }, ]); } @@ -1376,7 +1376,7 @@ describe('javascript', function() { }); } - it('should ignore importScripts when not in a worker context', async function() { + it('should ignore importScripts when not in a worker context', async function () { let b = await bundle( path.join( __dirname, @@ -1395,7 +1395,7 @@ describe('javascript', function() { assert(res.includes("importScripts('imported.js')")); }); - it('should ignore importScripts in script workers when not passed a string literal', async function() { + it('should ignore importScripts in script workers when not passed a string literal', async function () { let b = await bundle( path.join( __dirname, @@ -1418,7 +1418,7 @@ describe('javascript', function() { assert(res.includes('importScripts(url)')); }); - it('should ignore importScripts in script workers a fully qualified URL is provided', async function() { + it('should ignore importScripts in script workers a fully qualified URL is provided', async function () { let b = await bundle( path.join( __dirname, @@ -1441,7 +1441,7 @@ describe('javascript', function() { assert(res.includes("importScripts('https://unpkg.com/parcel')")); }); - it('should support bundling service-workers', async function() { + it('should support bundling service-workers', async function () { let b = await bundle( path.join(__dirname, '/integration/service-worker/a/index.js'), ); @@ -1460,7 +1460,7 @@ describe('javascript', function() { ]); }); - it('should support bundling service-workers with type: module', async function() { + it('should support bundling service-workers with type: module', async function () { let b = await bundle( path.join(__dirname, '/integration/service-worker/module.js'), { @@ -1489,7 +1489,7 @@ describe('javascript', function() { assert(!/export /.test(workerContents)); }); - it('should preserve the scope option for service workers', async function() { + it('should preserve the scope option for service workers', async function () { let b = await bundle( path.join(__dirname, '/integration/service-worker/scope.js'), { @@ -1519,7 +1519,7 @@ describe('javascript', function() { ); }); - it('should error if importing in a service worker without type: module', async function() { + it('should error if importing in a service worker without type: module', async function () { let errored = false; try { await bundle( @@ -1585,7 +1585,7 @@ describe('javascript', function() { "Add {type: 'module'} as a second argument to the navigator.serviceWorker.register() call.", ], documentationURL: - 'https://v2.parceljs.org/languages/javascript/#classic-scripts', + 'https://parceljs.org/languages/javascript/#classic-scripts', }, ]); } @@ -1593,7 +1593,7 @@ describe('javascript', function() { assert(errored); }); - it('should expose a manifest to service workers', async function() { + it('should expose a manifest to service workers', async function () { let b = await bundle( path.join(__dirname, '/integration/service-worker/manifest.js'), { @@ -1626,7 +1626,7 @@ describe('javascript', function() { assert.equal(typeof version, 'string'); }); - it('should recognize serviceWorker.register with static URL and import.meta.url', async function() { + it('should recognize serviceWorker.register with static URL and import.meta.url', async function () { let b = await bundle( path.join( __dirname, @@ -1648,7 +1648,7 @@ describe('javascript', function() { assert(!contents.includes('import.meta.url')); }); - it('should throw a codeframe for a missing file in serviceWorker.register with URL and import.meta.url', async function() { + it('should throw a codeframe for a missing file in serviceWorker.register with URL and import.meta.url', async function () { let fixture = path.join( __dirname, 'integration/service-worker-import-meta-url/missing.js', @@ -1688,7 +1688,7 @@ describe('javascript', function() { }); }); - it('should error on dynamic import() inside service workers', async function() { + it('should error on dynamic import() inside service workers', async function () { let errored = false; try { await bundle( @@ -1751,7 +1751,7 @@ describe('javascript', function() { assert(errored); }); - it('should support bundling workers with circular dependencies', async function() { + it('should support bundling workers with circular dependencies', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-circular/index.js'), ); @@ -1767,7 +1767,7 @@ describe('javascript', function() { ]); }); - it('should recognize worker constructor with static URL and import.meta.url', async function() { + it('should recognize worker constructor with static URL and import.meta.url', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-import-meta-url/index.js'), ); @@ -1786,7 +1786,7 @@ describe('javascript', function() { assert(!contents.includes('import.meta.url')); }); - it('should ignore worker constructors with dynamic URL and import.meta.url', async function() { + it('should ignore worker constructors with dynamic URL and import.meta.url', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-import-meta-url/dynamic.js'), ); @@ -1802,7 +1802,7 @@ describe('javascript', function() { assert(contents.includes('import.meta.url')); }); - it('should ignore worker constructors with local URL binding and import.meta.url', async function() { + it('should ignore worker constructors with local URL binding and import.meta.url', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-import-meta-url/local-url.js'), ); @@ -1818,7 +1818,7 @@ describe('javascript', function() { assert(contents.includes('import.meta.url')); }); - it('should throw a codeframe for a missing file in worker constructor with URL and import.meta.url', async function() { + it('should throw a codeframe for a missing file in worker constructor with URL and import.meta.url', async function () { let fixture = path.join( __dirname, 'integration/worker-import-meta-url/missing.js', @@ -1861,7 +1861,7 @@ describe('javascript', function() { }); }); - it.skip('should support bundling in workers with other loaders', async function() { + it.skip('should support bundling in workers with other loaders', async function () { let b = await bundle( path.join(__dirname, '/integration/workers-with-other-loaders/index.js'), ); @@ -2108,7 +2108,7 @@ describe('javascript', function() { ]); }); - it('should support workers with shared assets between page and worker with async imports', async function() { + it('should support workers with shared assets between page and worker with async imports', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-shared-page/index.html'), { @@ -2167,7 +2167,7 @@ describe('javascript', function() { await run(b); }); - it('should dynamic import files which import raw files', async function() { + it('should dynamic import files which import raw files', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-references-raw/index.js'), ); @@ -2190,7 +2190,7 @@ describe('javascript', function() { assert.equal(await output(), 3); }); - it('should return all exports as an object when using ES modules', async function() { + it('should return all exports as an object when using ES modules', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-esm/index.js'), ); @@ -2216,7 +2216,7 @@ describe('javascript', function() { assert.equal(await output(), 3); }); - it('should duplicate small modules across multiple bundles', async function() { + it('should duplicate small modules across multiple bundles', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-common-small/index.js'), ); @@ -2239,7 +2239,7 @@ describe('javascript', function() { assert.equal(await output(), 7); }); - it('should create a separate bundle for large modules shared between bundles', async function() { + it('should create a separate bundle for large modules shared between bundles', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-common-large/index.js'), { @@ -2278,7 +2278,7 @@ describe('javascript', function() { assert.equal(await output(), 7); }); - it('should not duplicate a module which is already in a parent bundle', async function() { + it('should not duplicate a module which is already in a parent bundle', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-hoist-dup/index.js'), ); @@ -2304,7 +2304,7 @@ describe('javascript', function() { assert.equal(await output(), 5); }); - it('should duplicate an asset if it is not present in every parent bundle', async function() { + it('should duplicate an asset if it is not present in every parent bundle', async function () { let b = await bundle( ['a.js', 'b.js'].map(entry => path.join(__dirname, 'integration/dynamic-hoist-no-dedupe', entry), @@ -2369,7 +2369,7 @@ describe('javascript', function() { assert.equal(await promise, 42); }); - it('should support shared modules with async imports', async function() { + it('should support shared modules with async imports', async function () { let b = await bundle( path.join(__dirname, '/integration/dynamic-hoist-deep/index.js'), ); @@ -2400,7 +2400,7 @@ describe('javascript', function() { assert.ok(await promise); }); - it('should support requiring JSON files', async function() { + it('should support requiring JSON files', async function () { let b = await bundle(path.join(__dirname, '/integration/json/index.js')); assertBundles(b, [ @@ -2415,7 +2415,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should support requiring JSON5 files', async function() { + it('should support requiring JSON5 files', async function () { let b = await bundle(path.join(__dirname, '/integration/json5/index.js')); assertBundles(b, [ @@ -2430,7 +2430,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should support importing a URL to a raw asset', async function() { + it('should support importing a URL to a raw asset', async function () { let b = await bundle( path.join(__dirname, '/integration/import-raw/index.js'), ); @@ -2455,7 +2455,7 @@ describe('javascript', function() { assert.equal(stats.size, 9); }); - it('should support referencing a raw asset with static URL and import.meta.url', async function() { + it('should support referencing a raw asset with static URL and import.meta.url', async function () { let b = await bundle( path.join(__dirname, '/integration/import-raw-import-meta-url/index.js'), ); @@ -2482,7 +2482,7 @@ describe('javascript', function() { assert.equal(stats.size, 9); }); - it('should support referencing a raw asset with static URL and CJS __filename', async function() { + it('should support referencing a raw asset with static URL and CJS __filename', async function () { let b = await bundle( path.join(__dirname, '/integration/import-raw-import-meta-url/cjs.js'), ); @@ -2509,7 +2509,7 @@ describe('javascript', function() { assert.equal(stats.size, 9); }); - it('should ignore new URL and import.meta.url with local binding', async function() { + it('should ignore new URL and import.meta.url with local binding', async function () { let b = await bundle( path.join( __dirname, @@ -2528,7 +2528,7 @@ describe('javascript', function() { assert(contents.includes('"file:///local-url.js"')); }); - it('should throw a codeframe for a missing raw asset with static URL and import.meta.url', async function() { + it('should throw a codeframe for a missing raw asset with static URL and import.meta.url', async function () { let fixture = path.join( __dirname, 'integration/import-raw-import-meta-url/missing.js', @@ -2568,7 +2568,7 @@ describe('javascript', function() { }); }); - it('should support importing a URL to a large raw asset', async function() { + it('should support importing a URL to a large raw asset', async function () { // 6 megabytes, which exceeds the threshold in summarizeRequest for buffering // entire contents into memory and should stream content instead let assetSizeBytes = 6000000; @@ -2609,7 +2609,7 @@ describe('javascript', function() { assert.equal(stats.size, assetSizeBytes); }); - it('should minify JS in production mode', async function() { + it('should minify JS in production mode', async function () { let b = await bundle(path.join(__dirname, '/integration/uglify/index.js'), { defaultTargetOptions: { shouldOptimize: true, @@ -2625,7 +2625,7 @@ describe('javascript', function() { assert(!js.includes('local.a')); }); - it('should use terser config', async function() { + it('should use terser config', async function () { await bundle(path.join(__dirname, '/integration/terser-config/index.js'), { defaultTargetOptions: { shouldOptimize: true, @@ -2638,7 +2638,7 @@ describe('javascript', function() { assert(!js.includes('// This is a comment')); }); - it('should insert global variables when needed', async function() { + it('should insert global variables when needed', async function () { let b = await bundle(path.join(__dirname, '/integration/globals/index.js')); let output = await run(b); @@ -2650,7 +2650,7 @@ describe('javascript', function() { }); }); - it('should work when multiple files use globals with scope hoisting', async function() { + it('should work when multiple files use globals with scope hoisting', async function () { let b = await bundle( path.join(__dirname, '/integration/globals/multiple.js'), { @@ -2669,7 +2669,7 @@ describe('javascript', function() { }); }); - it('should not insert global variables when used in a module specifier', async function() { + it('should not insert global variables when used in a module specifier', async function () { let b = await bundle( path.join(__dirname, '/integration/globals-module-specifier/a.js'), ); @@ -2684,7 +2684,7 @@ describe('javascript', function() { assert.deepEqual(output, 1234); }); - it('should not insert global variables in dead branches', async function() { + it('should not insert global variables in dead branches', async function () { let b = await bundle( path.join(__dirname, '/integration/globals-unused/a.js'), ); @@ -2699,7 +2699,7 @@ describe('javascript', function() { assert.deepEqual(output, 'foo'); }); - it('should handle re-declaration of the global constant', async function() { + it('should handle re-declaration of the global constant', async function () { let b = await bundle( path.join(__dirname, '/integration/global-redeclare/index.js'), ); @@ -2720,7 +2720,7 @@ describe('javascript', function() { assert.equal(await run(b), 'test'); }); - it('should not insert environment variables in node environment', async function() { + it('should not insert environment variables in node environment', async function () { let b = await bundle( path.join(__dirname, '/integration/env-node/index.js'), ); @@ -2730,7 +2730,7 @@ describe('javascript', function() { assert.equal(output(), 'test:test'); }); - it('should not replace process.env.hasOwnProperty with undefined', async function() { + it('should not replace process.env.hasOwnProperty with undefined', async function () { let b = await bundle( path.join(__dirname, '/integration/env-hasOwnProperty/index.js'), ); @@ -2739,7 +2739,7 @@ describe('javascript', function() { assert.strictEqual(output, false); }); - it('should not insert environment variables in electron-main environment', async function() { + it('should not insert environment variables in electron-main environment', async function () { let b = await bundle(path.join(__dirname, '/integration/env/index.js'), { targets: { main: { @@ -2754,7 +2754,7 @@ describe('javascript', function() { assert.equal(output(), 'test:test'); }); - it('should not insert environment variables in electron-renderer environment', async function() { + it('should not insert environment variables in electron-renderer environment', async function () { let b = await bundle(path.join(__dirname, '/integration/env/index.js'), { targets: { main: { @@ -2769,7 +2769,7 @@ describe('javascript', function() { assert.equal(output(), 'test:test'); }); - it('should inline NODE_ENV environment variable in browser environment even if disabled', async function() { + it('should inline NODE_ENV environment variable in browser environment even if disabled', async function () { let b = await bundle( path.join(__dirname, '/integration/env-nodeenv/index.js'), { @@ -2784,7 +2784,7 @@ describe('javascript', function() { assert.equal(output(), 'test:undefined'); }); - it('should not insert environment variables in browser environment if disabled', async function() { + it('should not insert environment variables in browser environment if disabled', async function () { let b = await bundle( path.join(__dirname, '/integration/env-disabled/index.js'), { @@ -2797,7 +2797,7 @@ describe('javascript', function() { assert.equal(output(), 'undefined:undefined:undefined'); }); - it('should only insert environment variables in browser environment matching the glob', async function() { + it('should only insert environment variables in browser environment matching the glob', async function () { let b = await bundle( path.join(__dirname, '/integration/env-disabled-glob/index.js'), { @@ -2810,7 +2810,7 @@ describe('javascript', function() { assert.equal(output(), 'undefined:def:ghi'); }); - it('should be able to inline environment variables in browser environment', async function() { + it('should be able to inline environment variables in browser environment', async function () { let b = await bundle(path.join(__dirname, '/integration/env/index.js'), { env: {NODE_ENV: 'abc'}, }); @@ -2820,7 +2820,7 @@ describe('javascript', function() { assert.equal(output(), 'abc:abc'); }); - it("should insert the user's NODE_ENV as process.env.NODE_ENV if passed", async function() { + it("should insert the user's NODE_ENV as process.env.NODE_ENV if passed", async function () { let b = await bundle(path.join(__dirname, '/integration/env/index.js'), { env: { NODE_ENV: 'production', @@ -2832,7 +2832,7 @@ describe('javascript', function() { assert.equal(output(), 'production:production'); }); - it('should not inline computed accesses to process.env', async function() { + it('should not inline computed accesses to process.env', async function () { let b = await bundle( path.join(__dirname, '/integration/env-computed/index.js'), { @@ -2847,7 +2847,7 @@ describe('javascript', function() { assert.strictEqual(output, undefined); }); - it('should inline computed accesses with string literals to process.env', async function() { + it('should inline computed accesses with string literals to process.env', async function () { let b = await bundle( path.join(__dirname, '/integration/env-computed-string/index.js'), { @@ -2862,7 +2862,7 @@ describe('javascript', function() { assert.strictEqual(output, 'XYZ'); }); - it('should inline environment variables when destructured in a variable declaration', async function() { + it('should inline environment variables when destructured in a variable declaration', async function () { let b = await bundle( path.join(__dirname, '/integration/env-destructuring/index.js'), { @@ -2890,7 +2890,7 @@ describe('javascript', function() { }); }); - it('should inline environment variables when destructured in an assignment', async function() { + it('should inline environment variables when destructured in an assignment', async function () { let b = await bundle( path.join(__dirname, '/integration/env-destructuring/assign.js'), { @@ -2918,7 +2918,7 @@ describe('javascript', function() { }); }); - it('should insert environment variables from a file', async function() { + it('should insert environment variables from a file', async function () { let b = await bundle( path.join(__dirname, '/integration/env-file/index.js'), ); @@ -2930,7 +2930,7 @@ describe('javascript', function() { assert.equal(output, 'bartest'); }); - it("should insert environment variables matching the user's NODE_ENV if passed", async function() { + it("should insert environment variables matching the user's NODE_ENV if passed", async function () { let b = await bundle( path.join(__dirname, '/integration/env-file/index.js'), {env: {NODE_ENV: 'production'}}, @@ -2940,7 +2940,7 @@ describe('javascript', function() { assert.equal(output, 'productiontest'); }); - it('should overwrite environment variables from a file if passed', async function() { + it('should overwrite environment variables from a file if passed', async function () { let b = await bundle( path.join(__dirname, '/integration/env-file/index.js'), {env: {BAR: 'baz'}}, @@ -2950,7 +2950,7 @@ describe('javascript', function() { assert.equal(output, 'barbaz'); }); - it('should error on process.env mutations', async function() { + it('should error on process.env mutations', async function () { let filePath = path.join(__dirname, '/integration/env-mutate/index.js'); await assert.rejects(bundle(filePath), { diagnostics: [ @@ -3050,7 +3050,7 @@ describe('javascript', function() { }); }); - it('should warn on process.env mutations in node_modules', async function() { + it('should warn on process.env mutations in node_modules', async function () { let logs = []; let disposable = Logger.onLog(d => logs.push(d)); let b = await bundle( @@ -3154,7 +3154,7 @@ describe('javascript', function() { assert.deepEqual(output, ['foo', true, undefined]); }); - it('should replace process.browser for target browser', async function() { + it('should replace process.browser for target browser', async function () { let b = await bundle( path.join(__dirname, '/integration/process/index.js'), { @@ -3172,7 +3172,7 @@ describe('javascript', function() { assert.equal(output(), true); }); - it('should not touch process.browser for target node', async function() { + it('should not touch process.browser for target node', async function () { let b = await bundle( path.join(__dirname, '/integration/process/index.js'), { @@ -3190,7 +3190,7 @@ describe('javascript', function() { assert.equal(output(), false); }); - it('should not touch process.browser for target electron-main', async function() { + it('should not touch process.browser for target electron-main', async function () { let b = await bundle( path.join(__dirname, '/integration/process/index.js'), { @@ -3208,7 +3208,7 @@ describe('javascript', function() { assert.equal(output(), false); }); - it('should replace process.browser for target electron-renderer', async function() { + it('should replace process.browser for target electron-renderer', async function () { let b = await bundle( path.join(__dirname, '/integration/process/index.js'), { @@ -3229,7 +3229,7 @@ describe('javascript', function() { process.browser = undefined; }); - it.skip('should support adding implicit dependencies', async function() { + it.skip('should support adding implicit dependencies', async function () { let b = await bundle(path.join(__dirname, '/integration/json/index.js'), { delegate: { getImplicitDependencies(asset) { @@ -3259,7 +3259,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should support requiring YAML files', async function() { + it('should support requiring YAML files', async function () { let b = await bundle(path.join(__dirname, '/integration/yaml/index.js')); assertBundles(b, [ @@ -3279,7 +3279,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should support requiring TOML files', async function() { + it('should support requiring TOML files', async function () { let b = await bundle(path.join(__dirname, '/integration/toml/index.js')); assertBundles(b, [ @@ -3299,7 +3299,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should support requiring CoffeeScript files', async function() { + it('should support requiring CoffeeScript files', async function () { let b = await bundle(path.join(__dirname, '/integration/coffee/index.js')); assertBundles(b, [ @@ -3314,7 +3314,7 @@ describe('javascript', function() { assert.equal(output(), 3); }); - it('should resolve the browser field before main', async function() { + it('should resolve the browser field before main', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-entries/browser.js'), ); @@ -3360,7 +3360,7 @@ describe('javascript', function() { assert.equal(await run(b), 'this should only exist in non-browser builds'); }); - it.skip('should not resolve the browser field for --target=node', async function() { + it.skip('should not resolve the browser field for --target=node', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-entries/browser.js'), { @@ -3384,7 +3384,7 @@ describe('javascript', function() { assert.equal(output.test(), 'pkg-main'); }); - it.skip('should resolve advanced browser resolution', async function() { + it.skip('should resolve advanced browser resolution', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-entries/browser-multiple.js'), ); @@ -3411,7 +3411,7 @@ describe('javascript', function() { assert.equal(output.entry.test(), 'pkg-browser-multiple browser-entry'); }); - it.skip('should not resolve advanced browser resolution with --target=node', async function() { + it.skip('should not resolve advanced browser resolution with --target=node', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-entries/browser-multiple.js'), { @@ -3437,7 +3437,7 @@ describe('javascript', function() { assert.equal(output.entry.test(), 'pkg-browser-multiple main-entry'); }); - it.skip('should resolve the module field before main if scope-hoisting is enabled', async function() { + it.skip('should resolve the module field before main if scope-hoisting is enabled', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-entries/module-field.js'), { @@ -3460,7 +3460,7 @@ describe('javascript', function() { assert.equal(output.test(), 'pkg-es6-module'); }); - it.skip('should resolve the module field before main if scope-hoisting is enabled', async function() { + it.skip('should resolve the module field before main if scope-hoisting is enabled', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-entries/both-fields.js'), { @@ -3483,7 +3483,7 @@ describe('javascript', function() { assert.equal(output.test(), 'pkg-es6-module'); }); - it('should resolve the main field', async function() { + it('should resolve the main field', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-entries/main-field.js'), ); @@ -3501,7 +3501,7 @@ describe('javascript', function() { assert.equal(output.test(), 'pkg-main-module'); }); - it('should minify JSON files', async function() { + it('should minify JSON files', async function () { let b = await bundle( path.join(__dirname, '/integration/uglify-json/index.json'), { @@ -3519,7 +3519,7 @@ describe('javascript', function() { assert.deepEqual(output, {test: 'test'}); }); - it('should minify JSON5 files', async function() { + it('should minify JSON5 files', async function () { let b = await bundle( path.join(__dirname, '/integration/uglify-json5/index.json5'), { @@ -3537,7 +3537,7 @@ describe('javascript', function() { assert.deepEqual(output, {test: 'test'}); }); - it.skip('should minify YAML for production', async function() { + it.skip('should minify YAML for production', async function () { let b = await bundle(path.join(__dirname, '/integration/yaml/index.js'), { defaultTargetOptions: { shouldOptimize: true, @@ -3553,7 +3553,7 @@ describe('javascript', function() { assert(json.includes('{a:1,b:{c:2}}')); }); - it('should minify TOML for production', async function() { + it('should minify TOML for production', async function () { let b = await bundle(path.join(__dirname, '/integration/toml/index.js'), { defaultTargetOptions: { shouldOptimize: true, @@ -3569,7 +3569,7 @@ describe('javascript', function() { assert(json.includes('{a:1,b:{c:2}}')); }); - it('should support optional dependencies in try...catch blocks', async function() { + it('should support optional dependencies in try...catch blocks', async function () { let b = await bundle( path.join(__dirname, '/integration/optional-dep/index.js'), ); @@ -3591,7 +3591,7 @@ describe('javascript', function() { assert.equal(output.code, 'MODULE_NOT_FOUND'); }); - it('should support excluding dependencies in falsy branches', async function() { + it('should support excluding dependencies in falsy branches', async function () { let b = await bundle( path.join(__dirname, '/integration/falsy-dep/index.js'), ); @@ -3607,7 +3607,7 @@ describe('javascript', function() { assert.equal(output, 2); }); - it.skip('should not autoinstall if resolve failed on installed module', async function() { + it.skip('should not autoinstall if resolve failed on installed module', async function () { let error; try { await bundle( @@ -3626,7 +3626,7 @@ describe('javascript', function() { assert.equal(error.code, 'MODULE_NOT_FOUND'); }); - it.skip('should not autoinstall if resolve failed on aliased module', async function() { + it.skip('should not autoinstall if resolve failed on aliased module', async function () { let error; try { await bundle( @@ -3645,7 +3645,7 @@ describe('javascript', function() { assert.equal(error.code, 'MODULE_NOT_FOUND'); }); - it('should ignore require if it is defined in the scope', async function() { + it('should ignore require if it is defined in the scope', async function () { let b = await bundle( path.join(__dirname, '/integration/require-scope/index.js'), ); @@ -3668,7 +3668,7 @@ describe('javascript', function() { assert.equal(failed, false); }); - it('should expose to CommonJS entry point', async function() { + it('should expose to CommonJS entry point', async function () { let b = await bundle( path.join(__dirname, '/integration/entry-point/index.js'), ); @@ -3678,12 +3678,12 @@ describe('javascript', function() { assert.equal(module.exports(), 'Test!'); }); - it('should expose to RequireJS entry point', async function() { + it('should expose to RequireJS entry point', async function () { let b = await bundle( path.join(__dirname, '/integration/entry-point/index.js'), ); let test; - const mockDefine = function(f) { + const mockDefine = function (f) { test = f(); }; mockDefine.amd = true; @@ -3692,7 +3692,7 @@ describe('javascript', function() { assert.equal(test(), 'Test!'); }); - it.skip('should expose variable with --browser-global', async function() { + it.skip('should expose variable with --browser-global', async function () { let b = await bundle( path.join(__dirname, '/integration/entry-point/index.js'), { @@ -3704,12 +3704,12 @@ describe('javascript', function() { assert.equal(ctx.window.testing(), 'Test!'); }); - it.skip('should set `define` to undefined so AMD checks in UMD modules do not pass', async function() { + it.skip('should set `define` to undefined so AMD checks in UMD modules do not pass', async function () { let b = await bundle( path.join(__dirname, '/integration/define-amd/index.js'), ); let test; - const mockDefine = function(f) { + const mockDefine = function (f) { test = f(); }; mockDefine.amd = true; @@ -3718,7 +3718,7 @@ describe('javascript', function() { assert.equal(test, 2); }); - it('should package successfully with comments on last line', async function() { + it('should package successfully with comments on last line', async function () { let b = await bundle( path.join(__dirname, `/integration/js-comment/index.js`), ); @@ -3727,7 +3727,7 @@ describe('javascript', function() { assert.equal(output, 'Hello World!'); }); - it('should package successfully with comments on last line and minification', async function() { + it('should package successfully with comments on last line and minification', async function () { let b = await bundle( path.join(__dirname, `/integration/js-comment/index.js`), ); @@ -3736,7 +3736,7 @@ describe('javascript', function() { assert.equal(output, 'Hello World!'); }); - it('should package successfully with comments on last line and scope hoisting', async function() { + it('should package successfully with comments on last line and scope hoisting', async function () { let b = await bundle( path.join(__dirname, `/integration/js-comment/index.js`), { @@ -3750,7 +3750,7 @@ describe('javascript', function() { assert.equal(output, 'Hello World!'); }); - it('should package successfully with comments on last line, scope hoisting and minification', async function() { + it('should package successfully with comments on last line, scope hoisting and minification', async function () { let b = await bundle( path.join(__dirname, `/integration/js-comment/index.js`), { @@ -3765,7 +3765,7 @@ describe('javascript', function() { assert.equal(output, 'Hello World!'); }); - it('should not replace toplevel this with undefined in CommonJS without scope-hoisting', async function() { + it('should not replace toplevel this with undefined in CommonJS without scope-hoisting', async function () { let b = await bundle( path.join(__dirname, '/integration/js-this-commonjs/a.js'), ); @@ -3778,7 +3778,7 @@ describe('javascript', function() { assert.deepEqual(output, [{foo: 2}, 1234]); }); - it('should not replace toplevel this with undefined in CommonJS when scope-hoisting', async function() { + it('should not replace toplevel this with undefined in CommonJS when scope-hoisting', async function () { let b = await bundle( path.join(__dirname, '/integration/js-this-commonjs/a.js'), { @@ -3796,7 +3796,7 @@ describe('javascript', function() { assert.deepEqual(output, [{foo: 2}, 1234]); }); - it('should replace toplevel this with undefined in ESM without scope-hoisting', async function() { + it('should replace toplevel this with undefined in ESM without scope-hoisting', async function () { let b = await bundle(path.join(__dirname, '/integration/js-this-es6/a.js')); let output; @@ -3807,7 +3807,7 @@ describe('javascript', function() { assert.deepEqual(output, [undefined, 1234]); }); - it('should replace toplevel this with undefined in ESM when scope-hoisting', async function() { + it('should replace toplevel this with undefined in ESM when scope-hoisting', async function () { let b = await bundle( path.join(__dirname, '/integration/js-this-es6/a.js'), { @@ -3825,7 +3825,7 @@ describe('javascript', function() { assert.deepEqual(output, [undefined, 1234]); }); - it.skip('should not dedupe imports with different contents', async function() { + it.skip('should not dedupe imports with different contents', async function () { let b = await bundle( path.join(__dirname, `/integration/js-different-contents/index.js`), { @@ -3837,7 +3837,7 @@ describe('javascript', function() { assert.equal(module.default, 'Hello World!'); }); - it.skip('should not dedupe imports with same content but different absolute dependency paths', async function() { + it.skip('should not dedupe imports with same content but different absolute dependency paths', async function () { let b = await bundle( path.join( __dirname, @@ -3852,7 +3852,7 @@ describe('javascript', function() { assert.equal(module.default, 'Hello World!'); }); - it.skip('should dedupe imports with same content and same dependency paths', async function() { + it.skip('should dedupe imports with same content and same dependency paths', async function () { let b = await bundle( path.join( __dirname, @@ -3881,7 +3881,7 @@ describe('javascript', function() { assert.equal(module.default, 'Hello Hello!'); }); - it.skip('should not dedupe assets that exist in more than one bundle', async function() { + it.skip('should not dedupe assets that exist in more than one bundle', async function () { let b = await bundle( path.join(__dirname, `/integration/js-dedup-hoist/index.js`), { @@ -3899,7 +3899,7 @@ describe('javascript', function() { assert.equal(await module.default(), 'Hello Hello! Hello'); }); - it.skip('should support importing HTML from JS async', async function() { + it.skip('should support importing HTML from JS async', async function () { let b = await bundle( path.join(__dirname, '/integration/import-html-async/index.js'), { @@ -3937,7 +3937,7 @@ describe('javascript', function() { assert(output.includes('Other page')); }); - it.skip('should support importing HTML from JS async with --target=node', async function() { + it.skip('should support importing HTML from JS async with --target=node', async function () { let b = await bundle( path.join(__dirname, '/integration/import-html-async/index.js'), { @@ -3976,7 +3976,7 @@ describe('javascript', function() { assert(output.includes('Other page')); }); - it.skip('should support importing HTML from JS sync', async function() { + it.skip('should support importing HTML from JS sync', async function () { let b = await bundle( path.join(__dirname, '/integration/import-html-sync/index.js'), { @@ -4016,7 +4016,7 @@ describe('javascript', function() { assert(output.includes('Other page')); }); - it.skip('should stub require.cache', async function() { + it.skip('should stub require.cache', async function () { let b = await bundle( path.join(__dirname, '/integration/node_require_cache/main.js'), { @@ -4563,11 +4563,12 @@ describe('javascript', function() { let sameBundle = bundles.find(b => b.name === 'same-bundle.js'); let getDep = bundles.find(b => b.name === 'get-dep.js'); - assert.deepEqual(await (await runBundle(b, sameBundle)).default, [ - 42, - 42, - 42, - ]); + assert.deepEqual( + await ( + await runBundle(b, sameBundle) + ).default, + [42, 42, 42], + ); assert.deepEqual(await (await runBundle(b, getDep)).default, 42); }); @@ -4769,7 +4770,7 @@ describe('javascript', function() { } }); - it('should throw a diagnostic for unkown pipelines', async function() { + it('should throw a diagnostic for unkown pipelines', async function () { let fixture = path.join(__dirname, 'integration/pipeline-unknown/a.js'); let code = await inputFS.readFileSync(fixture, 'utf8'); await assert.rejects(() => bundle(fixture), { @@ -4805,7 +4806,7 @@ describe('javascript', function() { }); }); - it('can create a bundle starting with a dot', async function() { + it('can create a bundle starting with a dot', async function () { let b = await bundle( path.join(__dirname, '/integration/dotfile-bundle/index.js'), ); @@ -4818,7 +4819,7 @@ describe('javascript', function() { ]); }); - it('should not automatically name bundle files starting with a dot', async function() { + it('should not automatically name bundle files starting with a dot', async function () { await bundle( path.join(__dirname, '/integration/bundle-naming/.invisible/index.js'), ); @@ -4833,7 +4834,7 @@ describe('javascript', function() { assert.equal(namedWithDot, false); }); - it('should support duplicate re-exports without scope hoisting', async function() { + it('should support duplicate re-exports without scope hoisting', async function () { let b = await bundle( path.join(__dirname, 'integration/js-duplicate-re-exports/index.js'), ); @@ -4843,7 +4844,31 @@ describe('javascript', function() { assert.equal(typeof res.c, 'function'); }); - it('should exclude default from export all declaration', async function() { + it('should prioritize named exports before re-exports withput scope hoisting (before)', async () => { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-priority/entry-a.mjs', + ), + ); + + let res = await run(b, null, {require: false}); + assert.equal(res.output, 2); + }); + + it('should prioritize named exports before re-exports without scope hoisting (after)', async () => { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-priority/entry-b.mjs', + ), + ); + + let res = await run(b, null, {require: false}); + assert.equal(res.output, 2); + }); + + it('should exclude default from export all declaration', async function () { let b = await bundle( path.join(__dirname, 'integration/js-export-all/index.js'), ); @@ -4851,7 +4876,7 @@ describe('javascript', function() { assert.deepEqual(res, {a: 4}); }); - it('should support import namespace declarations of other ES modules', async function() { + 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'), ); @@ -4859,7 +4884,7 @@ describe('javascript', function() { assert.deepEqual(res, {a: 4, default: 1}); }); - it('should support import namespace declarations of class from CJS', async function() { + it('should support import namespace declarations of class from CJS', async function () { let b = await bundle( path.join(__dirname, 'integration/js-import-namespace/b.js'), ); @@ -4867,7 +4892,7 @@ describe('javascript', function() { assert.equal(typeof res, 'function'); }); - it('should support import namespace declarations of object from CJS', async function() { + it('should support import namespace declarations of object from CJS', async function () { let b = await bundle( path.join(__dirname, 'integration/js-import-namespace/c.js'), ); @@ -4875,7 +4900,7 @@ describe('javascript', function() { assert.deepEqual(res, {foo: 2, default: 3}); }); - it('should support export namespace declarations', async function() { + it('should support export namespace declarations', async function () { let b = await bundle( path.join(__dirname, 'integration/js-export-namespace/index.js'), ); @@ -4883,7 +4908,7 @@ describe('javascript', function() { assert.deepEqual(res, {ns: {a: 4, default: 1}}); }); - it('should support export default declarations', async function() { + it('should support export default declarations', async function () { let b = await bundle( path.join(__dirname, 'integration/js-export-default/index.js'), ); @@ -4891,7 +4916,7 @@ describe('javascript', function() { assert.deepEqual(res, {other: 1}); }); - it('should work with many different types of exports', async function() { + it('should work with many different types of exports', async function () { let b = await bundle( path.join(__dirname, 'integration/js-export-many/index.js'), ); @@ -4907,7 +4932,7 @@ describe('javascript', function() { }); }); - it('should correctly export functions', async function() { + it('should correctly export functions', async function () { let b = await bundle( path.join(__dirname, 'integration/js-export-functions/index.js'), ); @@ -4917,7 +4942,7 @@ describe('javascript', function() { assert.strictEqual(res.bar('test'), 'bar:test'); }); - it('should handle exports of imports', async function() { + it('should handle exports of imports', async function () { let b = await bundle( path.join(__dirname, 'integration/js-export-import/index.js'), ); @@ -4925,7 +4950,7 @@ describe('javascript', function() { assert.deepEqual(res, {other: 2}); }); - it('should handle simultaneous import and reexports of the same identifier', async function() { + it('should handle simultaneous import and reexports of the same identifier', async function () { let b = await bundle( path.join(__dirname, 'integration/js-export-import-same/index.js'), ); @@ -4933,7 +4958,7 @@ describe('javascript', function() { assert.deepEqual(res, {foo: '123', bar: '1234'}); }); - it('should generate a unique variable name for imports', async function() { + it('should generate a unique variable name for imports', async function () { let b = await bundle( path.join(__dirname, 'integration/js-import-shadow/index.js'), ); @@ -4941,7 +4966,7 @@ describe('javascript', function() { assert.strictEqual(res.baz(), 'foo'); }); - it('should not replace identifier with a var declaration inside a for loop', async function() { + it('should not replace identifier with a var declaration inside a for loop', async function () { let b = await bundle( path.join(__dirname, 'integration/js-import-shadow-for-var/index.js'), ); @@ -4949,7 +4974,7 @@ describe('javascript', function() { assert.deepEqual(res.baz(), [0, 1, 2, 3]); }); - it('should replace an imported identifier with function locals of the same name', async function() { + it('should replace an imported identifier with function locals of the same name', async function () { let b = await bundle( path.join(__dirname, 'integration/js-import-shadow-func-var/index.js'), ); @@ -4957,7 +4982,15 @@ describe('javascript', function() { assert.deepEqual(res.default, 123); }); - it('should not freeze live default imports', async function() { + it('should replace imported values in member expressions', async function () { + let b = await bundle( + path.join(__dirname, 'integration/js-import-member/index.js'), + ); + let res = await run(b); + assert.deepEqual(res.default, ['a', 'b', 'bar']); + }); + + it('should not freeze live default imports', async function () { let b = await bundle( path.join(__dirname, 'integration/js-import-default-live/index.js'), ); @@ -4965,7 +4998,7 @@ describe('javascript', function() { assert.deepEqual(res.default, [123, 789]); }); - it('should not rewrite this in arrow function class properties', async function() { + it('should not rewrite this in arrow function class properties', async function () { let b = await bundle( path.join(__dirname, 'integration/js-class-this-esm/a.js'), ); @@ -5002,7 +5035,7 @@ describe('javascript', function() { assert.strictEqual(output, 'a'); }); - it('should support runtime module deduplication', async function() { + it('should support runtime module deduplication', async function () { let b = await bundle( path.join(__dirname, 'integration/js-runtime-dedup/index.js'), ); @@ -5024,7 +5057,7 @@ describe('javascript', function() { assert.equal(await res, true); }); - it('should support runtime module deduplication with scope hoisting', async function() { + it('should support runtime module deduplication with scope hoisting', async function () { let b = await bundle( path.join(__dirname, 'integration/js-runtime-dedup/index.js'), { @@ -5098,7 +5131,7 @@ describe('javascript', function() { ); }); - it('should create a shared bundle from a minimum of 2 source bundles', async function() { + it('should create a shared bundle from a minimum of 2 source bundles', async function () { let b = await bundle( path.join(__dirname, 'integration/shared-bundle-single-source/index.js'), { @@ -5137,7 +5170,7 @@ describe('javascript', function() { ]); }); - it('should error on undeclared external dependencies for libraries', async function() { + it('should error on undeclared external dependencies for libraries', async function () { let fixture = path.join( __dirname, 'integration/undeclared-external/index.js', @@ -5210,7 +5243,7 @@ describe('javascript', function() { ); }); - it('should error on undeclared helpers dependency for libraries', async function() { + it('should error on undeclared helpers dependency for libraries', async function () { let fixture = path.join( __dirname, 'integration/undeclared-external/helpers.js', @@ -5285,8 +5318,8 @@ describe('javascript', function() { ); }); - describe('multiple import types', function() { - it('supports both static and dynamic imports to the same specifier in the same file', async function() { + describe('multiple import types', function () { + it('supports both static and dynamic imports to the same specifier in the same file', async function () { let b = await bundle( path.join( __dirname, @@ -5307,7 +5340,7 @@ describe('javascript', function() { assert.equal(res.Foo, await res.LazyFoo); }); - it('supports both static and dynamic imports to the same specifier in the same file with scope hoisting', async function() { + it('supports both static and dynamic imports to the same specifier in the same file with scope hoisting', async function () { let b = await bundle( path.join( __dirname, @@ -5335,7 +5368,7 @@ describe('javascript', function() { assert.equal(res.Foo, await res.LazyFoo); }); - it('supports static, dynamic, and url to the same specifier in the same file', async function() { + it('supports static, dynamic, and url to the same specifier in the same file', async function () { let b = await bundle( path.join( __dirname, @@ -5369,7 +5402,7 @@ describe('javascript', function() { ); }); - it('supports static, dynamic, and url to the same specifier in the same file with scope hoisting', async function() { + it('supports static, dynamic, and url to the same specifier in the same file with scope hoisting', async function () { let b = await bundle( path.join( __dirname, @@ -5405,7 +5438,7 @@ describe('javascript', function() { ); }); - it('supports dynamic import and url to the same specifier in the same file', async function() { + it('supports dynamic import and url to the same specifier in the same file', async function () { let b = await bundle( path.join( __dirname, @@ -5443,7 +5476,7 @@ describe('javascript', function() { ); }); - it('supports dynamic import and url to the same specifier in the same file with scope hoisting', async function() { + it('supports dynamic import and url to the same specifier in the same file with scope hoisting', async function () { let b = await bundle( path.join( __dirname, @@ -5482,7 +5515,7 @@ describe('javascript', function() { ); }); - it('supports static import and inline bundle for the same asset', async function() { + it('supports static import and inline bundle for the same asset', async function () { let b = await bundle( path.join( __dirname, @@ -5506,7 +5539,7 @@ describe('javascript', function() { assert.equal(typeof res.text, 'string'); }); - it('supports static import and inline bundle for the same asset with scope hoisting', async function() { + it('supports static import and inline bundle for the same asset with scope hoisting', async function () { let b = await bundle( path.join( __dirname, @@ -5537,7 +5570,7 @@ describe('javascript', function() { assert.equal(typeof res.text, 'string'); }); - it('supports dynamic import and inline bundle for the same asset', async function() { + it('supports dynamic import and inline bundle for the same asset', async function () { let b = await bundle( path.join( __dirname, @@ -5572,7 +5605,7 @@ describe('javascript', function() { assert.equal(typeof res.text, 'string'); }); - it('supports dynamic import and inline bundle for the same asset with scope hoisting', async function() { + it('supports dynamic import and inline bundle for the same asset with scope hoisting', async function () { let b = await bundle( path.join( __dirname, @@ -5609,7 +5642,7 @@ describe('javascript', function() { }); }); - it('should avoid creating a bundle for lazy dependencies already available in a shared bundle', async function() { + it('should avoid creating a bundle for lazy dependencies already available in a shared bundle', async function () { let b = await bundle( path.join( __dirname, @@ -5626,7 +5659,7 @@ describe('javascript', function() { assert.deepEqual(await (await run(b)).default, [42, 42]); }); - it('should support standalone import.meta', async function() { + it('should support standalone import.meta', async function () { let b = await bundle( path.join(__dirname, 'integration/import-meta/index.js'), ); @@ -5649,7 +5682,7 @@ describe('javascript', function() { }); }); - it('should support importing async bundles from bundles with different dist paths', async function() { + it('should support importing async bundles from bundles with different dist paths', async function () { let bundleGraph = await bundle( ['bar/entry/entry-a.js', 'foo/entry-b.js'].map(f => path.join(__dirname, 'integration/differing-bundle-urls', f), diff --git a/packages/core/integration-tests/test/kotlin.js b/packages/core/integration-tests/test/kotlin.js index fc2056ae32d..50cda460710 100644 --- a/packages/core/integration-tests/test/kotlin.js +++ b/packages/core/integration-tests/test/kotlin.js @@ -2,7 +2,7 @@ import assert from 'assert'; import {bundle, assertBundleTree, run} from '@parcel/test-utils'; import commandExists from 'command-exists'; -describe.skip('kotlin', function() { +describe.skip('kotlin', function () { if (!commandExists.sync('java')) { // eslint-disable-next-line no-console console.log( @@ -11,7 +11,7 @@ describe.skip('kotlin', function() { return; } - it('should produce a basic kotlin bundle', async function() { + it('should produce a basic kotlin bundle', async function () { let b = await bundle(__dirname + '/integration/kotlin/index.js'); await assertBundleTree(b, { diff --git a/packages/core/integration-tests/test/less.js b/packages/core/integration-tests/test/less.js index 6087b919395..4f501b04aee 100644 --- a/packages/core/integration-tests/test/less.js +++ b/packages/core/integration-tests/test/less.js @@ -9,8 +9,8 @@ import { } from '@parcel/test-utils'; import {md} from '@parcel/diagnostic'; -describe('less', function() { - it('should support requiring less files', async function() { +describe('less', function () { + it('should support requiring less files', async function () { let b = await bundle(path.join(__dirname, '/integration/less/index.js')); assertBundles(b, [ @@ -32,7 +32,7 @@ describe('less', function() { assert(css.includes('.index')); }); - it('should support less imports', async function() { + it('should support less imports', async function () { let b = await bundle( path.join(__dirname, '/integration/less-import/index.js'), ); @@ -59,7 +59,7 @@ describe('less', function() { assert(css.includes('.d')); }); - it('should support advanced less imports', async function() { + it('should support advanced less imports', async function () { let b = await bundle( path.join(__dirname, '/integration/less-advanced-import/index.js'), ); @@ -88,7 +88,7 @@ describe('less', function() { assert(css.includes('.explicit-external-a')); }); - it('should support requiring empty less files', async function() { + it('should support requiring empty less files', async function () { let b = await bundle( path.join(__dirname, '/integration/less-empty/index.js'), ); @@ -112,7 +112,7 @@ describe('less', function() { assert.equal(css.trim(), '/*# sourceMappingURL=index.css.map */'); }); - it('should support linking to assets with url() from less', async function() { + it('should support linking to assets with url() from less', async function () { let b = await bundle( path.join(__dirname, '/integration/less-url/index.js'), ); @@ -148,7 +148,7 @@ describe('less', function() { ); }); - it('should support less url rewrites', async function() { + it('should support less url rewrites', async function () { let b = await bundle( path.join(__dirname, '/integration/less-url-rewrite/index.js'), ); @@ -181,7 +181,7 @@ describe('less', function() { assert(css.includes('.b')); }); - it('should support transforming less with postcss', async function() { + it('should support transforming less with postcss', async function () { let b = await bundle( path.join(__dirname, '/integration/less-postcss/index.js'), ); @@ -208,7 +208,7 @@ describe('less', function() { assert(css.includes('._index_')); }); - it('should throw an exception when using webpack syntax', async function() { + it('should throw an exception when using webpack syntax', async function () { await assert.rejects( () => bundle( @@ -223,7 +223,7 @@ describe('less', function() { ); }); - it('should support configuring less include paths', async function() { + it('should support configuring less include paths', async function () { let b = await bundle( path.join(__dirname, '/integration/less-include-paths/index.js'), ); @@ -248,7 +248,7 @@ describe('less', function() { assert(css.includes('.b')); }); - it('should ignore url() with IE behavior specifiers', async function() { + it('should ignore url() with IE behavior specifiers', async function () { let b = await bundle( path.join(__dirname, '/integration/less-url-behavior/index.less'), ); diff --git a/packages/core/integration-tests/test/markdown.js b/packages/core/integration-tests/test/markdown.js index e32055e1ba2..6e9c2cecf18 100644 --- a/packages/core/integration-tests/test/markdown.js +++ b/packages/core/integration-tests/test/markdown.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, assertBundleTree, outputFS} from '@parcel/test-utils'; -describe.skip('markdown', function() { - it('should support bundling Markdown', async function() { +describe.skip('markdown', function () { + it('should support bundling Markdown', async function () { let b = await bundle( path.join(__dirname, '/integration/markdown/index.md'), ); diff --git a/packages/core/integration-tests/test/mdx.js b/packages/core/integration-tests/test/mdx.js index 476cad7d484..585581d7770 100644 --- a/packages/core/integration-tests/test/mdx.js +++ b/packages/core/integration-tests/test/mdx.js @@ -2,8 +2,8 @@ const assert = require('assert'); const path = require('path'); const {bundle, run} = require('@parcel/test-utils'); -describe('mdx', function() { - it('should support bundling MDX', async function() { +describe('mdx', function () { + it('should support bundling MDX', async function () { let b = await bundle(path.join(__dirname, '/integration/mdx/index.mdx')); let output = await run(b); @@ -11,7 +11,7 @@ describe('mdx', function() { assert(output.default.isMDXComponent); }); - it('should support bundling MDX with React 17', async function() { + it('should support bundling MDX with React 17', async function () { let b = await bundle( path.join(__dirname, '/integration/mdx-react-17/index.mdx'), ); diff --git a/packages/core/integration-tests/test/monorepos.js b/packages/core/integration-tests/test/monorepos.js index a62670acbfb..f687fd24cde 100644 --- a/packages/core/integration-tests/test/monorepos.js +++ b/packages/core/integration-tests/test/monorepos.js @@ -14,7 +14,7 @@ import { const distDir = path.join(__dirname, '/integration/monorepo/dist/default'); -describe('monorepos', function() { +describe('monorepos', function () { beforeEach(async () => { await outputFS.rimraf(path.join(__dirname, '/monorepo')); }); @@ -27,7 +27,7 @@ describe('monorepos', function() { } }); - it('should compile packages with target source overrides', async function() { + it('should compile packages with target source overrides', async function () { let fixture = path.join(__dirname, '/integration/target-source'); let oldcwd = inputFS.cwd(); inputFS.chdir(fixture); @@ -91,7 +91,7 @@ describe('monorepos', function() { } }); - it('should compile packages with target source overrides and --target option', async function() { + it('should compile packages with target source overrides and --target option', async function () { let fixture = path.join(__dirname, '/integration/target-source'); let oldcwd = inputFS.cwd(); inputFS.chdir(fixture); @@ -142,7 +142,29 @@ describe('monorepos', function() { } }); - it('should build using root targets with entry files inside packages and cwd at project root', async function() { + it('should compile packages with target source overrides and --target option in serve mode', async function () { + let fixture = path.join(__dirname, '/integration/target-source'); + let oldcwd = inputFS.cwd(); + inputFS.chdir(fixture); + + try { + let b = await bundle(path.join(fixture, 'packages/package-b'), { + targets: ['alternate'], + serveOptions: {port: 1234}, + }); + + assertBundles(b, [ + { + name: 'indexAlternate.js', + assets: ['bar.js', 'esmodule-helpers.js', 'indexAlternate.js'], + }, + ]); + } finally { + inputFS.chdir(oldcwd); + } + }); + + it('should build using root targets with entry files inside packages and cwd at project root', async function () { let fixture = path.join(__dirname, '/integration/monorepo'); let oldcwd = inputFS.cwd(); inputFS.chdir(fixture); @@ -198,7 +220,7 @@ describe('monorepos', function() { } }); - it('should build multiple packages in a monorepo at once, pointing at directories with "source" field in package.json', async function() { + it('should build multiple packages in a monorepo at once, pointing at directories with "source" field in package.json', async function () { let b = await bundle( [ path.join(__dirname, '/integration/monorepo/packages/pkg-a'), @@ -280,7 +302,7 @@ describe('monorepos', function() { assert(contents.includes('import "./pkg-b.cjs.css"')); }); - it('should build using root targets with a glob pointing at files inside packages and cwd at project root', async function() { + it('should build using root targets with a glob pointing at files inside packages and cwd at project root', async function () { let fixture = path.join(__dirname, '/integration/monorepo'); let oldcwd = inputFS.cwd(); inputFS.chdir(fixture); @@ -330,7 +352,7 @@ describe('monorepos', function() { } }); - it('should build using root targets with a glob pointing at files inside packages and cwd outside project root', async function() { + it('should build using root targets with a glob pointing at files inside packages and cwd outside project root', async function () { let oldcwd = inputFS.cwd(); inputFS.chdir(path.join(__dirname, '/integration')); @@ -382,7 +404,7 @@ describe('monorepos', function() { } }); - it('should build a single package with an entry file and cwd at a package', async function() { + it('should build a single package with an entry file and cwd at a package', async function () { let fixture = path.join(__dirname, '/integration/monorepo/packages/pkg-a'); let oldcwd = inputFS.cwd(); inputFS.chdir(fixture); @@ -428,7 +450,7 @@ describe('monorepos', function() { } }); - it('should build a single package with an entry file and cwd inside a package', async function() { + it('should build a single package with an entry file and cwd inside a package', async function () { let fixture = path.join( __dirname, '/integration/monorepo/packages/pkg-a/src', @@ -477,7 +499,7 @@ describe('monorepos', function() { } }); - it('should build multiple packages in a monorepo at once, pointing at a glob of directories', async function() { + it('should build multiple packages in a monorepo at once, pointing at a glob of directories', async function () { let b = await bundle( path.join(__dirname, '/integration/monorepo/packages/*'), { @@ -556,7 +578,7 @@ describe('monorepos', function() { assert(contents.includes('import "./pkg-b.cjs.css"')); }); - it('should watch glob entries and build new packages that are added', async function() { + it('should watch glob entries and build new packages that are added', async function () { // copy into memory fs await ncp( path.join(__dirname, '/integration/monorepo/packages/pkg-a'), @@ -614,7 +636,7 @@ describe('monorepos', function() { ]); }); - it('should watch package.json containing "source" field for changes', async function() { + it('should watch package.json containing "source" field for changes', async function () { // copy into memory fs await ncp( path.join(__dirname, '/integration/monorepo/packages/pkg-a'), @@ -675,7 +697,7 @@ describe('monorepos', function() { assert(contents.includes('return 3')); }); - it('should watch package.json containing targets for changes', async function() { + it('should watch package.json containing targets for changes', async function () { // copy into memory fs await ncp( path.join(__dirname, '/integration/monorepo/packages/pkg-a'), @@ -739,7 +761,7 @@ describe('monorepos', function() { assert(contents.includes('return 2')); }); - it('should not share bundles between targets', async function() { + it('should not share bundles between targets', async function () { let b = await bundle( [ path.join(__dirname, '/integration/monorepo-shared/packages/pkg-a'), diff --git a/packages/core/integration-tests/test/namer.js b/packages/core/integration-tests/test/namer.js index e31cc51a19d..3baf808b474 100644 --- a/packages/core/integration-tests/test/namer.js +++ b/packages/core/integration-tests/test/namer.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, outputFS, distDir} from '@parcel/test-utils'; -describe('namer', function() { - it('should determine correct entry root when building a directory', async function() { +describe('namer', function () { + it('should determine correct entry root when building a directory', async function () { await bundle(path.join(__dirname, 'integration/namer-dir')); assert(await outputFS.exists(path.join(distDir, 'index.html'))); diff --git a/packages/core/integration-tests/test/output-formats.js b/packages/core/integration-tests/test/output-formats.js index ad4c5d8cf51..834dc7a56f0 100644 --- a/packages/core/integration-tests/test/output-formats.js +++ b/packages/core/integration-tests/test/output-formats.js @@ -29,9 +29,9 @@ const bundle = (name, opts = {}) => { ); }; -describe('output formats', function() { - describe('commonjs', function() { - it('should support commonjs output (exports)', async function() { +describe('output formats', function () { + describe('commonjs', function () { + it('should support commonjs output (exports)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs/exports.js'), ); @@ -39,7 +39,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 5); }); - it('should support commonjs output (module.exports)', async function() { + it('should support commonjs output (module.exports)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs/module-exports.js'), ); @@ -49,7 +49,7 @@ describe('output formats', function() { assert.equal(await run(b), 5); }); - it('should support commonjs output from esmodule input', async function() { + it('should support commonjs output from esmodule input', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-commonjs/a.js'), ); @@ -57,7 +57,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 5); }); - it('should support commonjs output from esmodule input (re-export rename)', async function() { + it('should support commonjs output from esmodule input (re-export rename)', async function () { let b = await bundle( path.join( __dirname, @@ -68,7 +68,7 @@ describe('output formats', function() { assert.equal((await run(b)).default, 2); }); - it.skip('should support commonjs output from esmodule input (re-export namespace as)', async function() { + it.skip('should support commonjs output from esmodule input (re-export namespace as)', async function () { let b = await bundle( path.join( __dirname, @@ -83,7 +83,7 @@ describe('output formats', function() { assert.equal(output.ns.bar, 5); }); - it('should support commonjs output from esmodule input (same binding multiple exports)', async function() { + it('should support commonjs output from esmodule input (same binding multiple exports)', async function () { let b = await bundle( path.join( __dirname, @@ -99,7 +99,7 @@ describe('output formats', function() { }); }); - it('should support commonjs output from esmodule input (skipped exports)', async function() { + it('should support commonjs output from esmodule input (skipped exports)', async function () { let b = await bundle( path.join( __dirname, @@ -110,7 +110,7 @@ describe('output formats', function() { assert.deepEqual(await run(b), {}); }); - it('should support commonjs output with external modules (require)', async function() { + it('should support commonjs output with external modules (require)', async function () { let b = await bundle( path.join( __dirname, @@ -123,7 +123,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 3); }); - it('should support commonjs output with external modules (named import)', async function() { + it('should support commonjs output with external modules (named import)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-external/named.js'), ); @@ -131,7 +131,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 3); }); - it('should support commonjs output with external modules (named import with same name)', async function() { + it('should support commonjs output with external modules (named import with same name)', async function () { let b = await bundle( path.join( __dirname, @@ -142,7 +142,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, true); }); - it('should support commonjs output with external modules (namespace import)', async function() { + it('should support commonjs output with external modules (namespace import)', async function () { let b = await bundle( path.join( __dirname, @@ -155,7 +155,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 3); }); - it('should support commonjs output with external modules (default import)', async function() { + it('should support commonjs output with external modules (default import)', async function () { let b = await bundle( path.join( __dirname, @@ -168,7 +168,20 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 3); }); - it('should support commonjs output with external modules (multiple specifiers)', async function() { + it('should support commonjs output with external modules (default import new call)', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/formats/commonjs-external/default-new.js', + ), + ); + + let dist = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert(dist.includes('$parcel$interopDefault')); + await run(b); + }); + + it('should support commonjs output with external modules (multiple specifiers)', async function () { let b = await bundle( path.join( __dirname, @@ -178,12 +191,12 @@ describe('output formats', function() { let dist = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); assert(dist.includes('= require("lodash")')); - assert(dist.includes('= $parcel$interopDefault(')); + assert(dist.includes('= ($parcel$interopDefault(')); assert(/var {add: \s*\$.+?\$add\s*} = lodash/); assert.equal((await run(b)).bar, 6); }); - it('should support commonjs output with old node without destructuring (single)', async function() { + it('should support commonjs output with old node without destructuring (single)', async function () { let b = await bundle( path.join( __dirname, @@ -194,7 +207,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 3); }); - it('should support commonjs output with old node without destructuring (multiple single with same name)', async function() { + it('should support commonjs output with old node without destructuring (multiple single with same name)', async function () { let b = await bundle( path.join( __dirname, @@ -205,7 +218,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, true); }); - it('should support commonjs output with old node without destructuring (multiple)', async function() { + it('should support commonjs output with old node without destructuring (multiple)', async function () { let b = await bundle( path.join( __dirname, @@ -216,7 +229,7 @@ describe('output formats', function() { assert.equal((await run(b)).bar, 2); }); - it('should support commonjs output with old browsers without destructuring (single)', async function() { + it('should support commonjs output with old browsers without destructuring (single)', async function () { let b = await bundle( path.join( __dirname, @@ -227,7 +240,7 @@ describe('output formats', function() { assert.equal((await run(b, {require})).bar, 3); }); - it('should support commonjs output with old node without destructuring (multiple)', async function() { + it('should support commonjs output with old node without destructuring (multiple)', async function () { let b = await bundle( path.join( __dirname, @@ -238,7 +251,7 @@ describe('output formats', function() { assert.equal((await run(b, {require})).bar, 2); }); - it('should support importing sibling bundles in library mode', async function() { + it('should support importing sibling bundles in library mode', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-siblings/a.js'), ); @@ -250,7 +263,7 @@ describe('output formats', function() { assert(dist.includes('require("./index.css")')); }); - it('should support async imports', async function() { + it('should support async imports', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-async/index.js'), ); @@ -264,7 +277,7 @@ describe('output formats', function() { assert.equal(await run(b), 4); }); - it('should support async split bundles', async function() { + it('should support async split bundles', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-split/index.js'), { @@ -287,7 +300,7 @@ describe('output formats', function() { ); }); - it('should support async split bundles (reexport default)', async function() { + it('should support async split bundles (reexport default)', async function () { let b = await bundle( path.join( __dirname, @@ -318,7 +331,7 @@ describe('output formats', function() { assert.strictEqual(await run(b), 20579 * 2); }); - it('should call init for wrapped modules when codesplitting to to commonjs', async function() { + it('should call init for wrapped modules when codesplitting to to commonjs', async function () { let b = await bundle( path.join( __dirname, @@ -329,7 +342,7 @@ describe('output formats', function() { assert.equal(await run(b), 2); }); - it('should support sideEffects: false', async function() { + it('should support sideEffects: false', async function () { let b = await bundle( path.join( __dirname, @@ -341,7 +354,7 @@ describe('output formats', function() { assert.equal(typeof ns.test, 'function'); }); - it('should throw an error on missing export with esmodule input and sideEffects: false', async function() { + it('should throw an error on missing export with esmodule input and sideEffects: false', async function () { let message = "other.js does not export 'a'"; let source = path.join( __dirname, @@ -388,7 +401,7 @@ describe('output formats', function() { ); }); - it('should support commonjs input', async function() { + it('should support commonjs input', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-dynamic/index.js'), ); @@ -403,7 +416,7 @@ describe('output formats', function() { assert.equal(typeof ns.test, 'function'); }); - it('should support commonjs requires without interop', async function() { + it('should support commonjs requires without interop', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-require/index.js'), ); @@ -418,7 +431,7 @@ describe('output formats', function() { assert.equal(add(2, 3), 5); }); - it('should support generating commonjs output with re-exports in entry', async function() { + it('should support generating commonjs output with re-exports in entry', async function () { let b = await bundle( path.join( __dirname, @@ -428,7 +441,7 @@ describe('output formats', function() { assert.deepEqual(await run(b), {foo: 'foo'}); }); - it('should compile workers to statically analyzable URL expressions', async function() { + it('should compile workers to statically analyzable URL expressions', async function () { let b = await bundle( path.join(__dirname, '/integration/workers-module/index.js'), { @@ -468,7 +481,7 @@ describe('output formats', function() { ); }); - it('should compile url: pipeline dependencies to statically analyzable URL expressions for libraries', async function() { + it('should compile url: pipeline dependencies to statically analyzable URL expressions for libraries', async function () { let b = await bundle( path.join(__dirname, '/integration/worklet/pipeline.js'), { @@ -495,7 +508,7 @@ describe('output formats', function() { ); }); - it('should URL dependencies to statically analyzable URL expressions for libraries', async function() { + it('should URL dependencies to statically analyzable URL expressions for libraries', async function () { let b = await bundle( path.join(__dirname, '/integration/worklet/url.js'), { @@ -522,7 +535,7 @@ describe('output formats', function() { ); }); - it('should support live binding of external modules', async function() { + it('should support live binding of external modules', async function () { let b = await bundle( path.join( __dirname, @@ -549,8 +562,8 @@ describe('output formats', function() { }); }); - describe('esmodule', function() { - it('should support esmodule output (named export)', async function() { + describe('esmodule', function () { + it('should support esmodule output (named export)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm/named.js'), ); @@ -558,7 +571,7 @@ describe('output formats', function() { await assertESMExports(b, {bar: 5, foo: 2}); }); - it('should support esmodule output (default identifier)', async function() { + it('should support esmodule output (default identifier)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm/default-value.js'), ); @@ -568,7 +581,7 @@ describe('output formats', function() { await assertESMExports(b, {default: 4}); }); - it('should support esmodule output (default function)', async function() { + it('should support esmodule output (default function)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm/default-function.js'), ); @@ -576,7 +589,7 @@ describe('output formats', function() { assert.strictEqual((await run(b)).default(), 2); }); - it('should support esmodule output (multiple)', async function() { + it('should support esmodule output (multiple)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm/multiple.js'), ); @@ -584,7 +597,7 @@ describe('output formats', function() { await assertESMExports(b, {a: 2, c: 5, default: 3}); }); - it('should support esmodule output (exporting symbol multiple times)', async function() { + it('should support esmodule output (exporting symbol multiple times)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm/multiple-times.js'), ); @@ -592,7 +605,7 @@ describe('output formats', function() { await assertESMExports(b, {default: 1, foo: 2, other: 1, test: 1}); }); - it('should support esmodule output (re-export)', async function() { + it('should support esmodule output (re-export)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm/re-export.js'), ); @@ -600,7 +613,7 @@ describe('output formats', function() { await assertESMExports(b, {a: 2, c: 5}); }); - it.skip('should support esmodule output (re-export namespace as)', async function() { + it.skip('should support esmodule output (re-export namespace as)', async function () { let b = await bundle( path.join( __dirname, @@ -611,7 +624,7 @@ describe('output formats', function() { await assertESMExports(b, {ns: {a: 2, c: 5}}); }); - it('should support esmodule output (renaming re-export)', async function() { + it('should support esmodule output (renaming re-export)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm/re-export-rename.js'), ); @@ -619,7 +632,7 @@ describe('output formats', function() { await assertESMExports(b, {foo: 4}); }); - it('should support esmodule output with external modules (named import)', async function() { + it('should support esmodule output with external modules (named import)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-external/named.js'), ); @@ -631,7 +644,7 @@ describe('output formats', function() { ); }); - it('should support esmodule output with external modules (named import with same name)', async function() { + it('should support esmodule output with external modules (named import with same name)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-external/named-same.js'), ); @@ -646,7 +659,7 @@ describe('output formats', function() { ); }); - it('should support esmodule output with external modules (namespace import)', async function() { + it('should support esmodule output with external modules (namespace import)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-external/namespace.js'), ); @@ -654,7 +667,7 @@ describe('output formats', function() { await assertESMExports(b, {bar: 3}, {lodash: () => lodash}); }); - it('should support esmodule output with external modules (default import)', async function() { + it('should support esmodule output with external modules (default import)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-external/default.js'), ); @@ -668,7 +681,7 @@ describe('output formats', function() { ); }); - it('should support esmodule output with external modules (multiple specifiers)', async function() { + it('should support esmodule output with external modules (multiple specifiers)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-external/multiple.js'), ); @@ -682,7 +695,7 @@ describe('output formats', function() { ); }); - it('should support esmodule output with external modules (export)', async function() { + it('should support esmodule output with external modules (export)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-external/export.js'), ); @@ -697,7 +710,7 @@ describe('output formats', function() { ); }); - it('should support esmodule output with external modules (re-export)', async function() { + it('should support esmodule output with external modules (re-export)', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-external/re-export.js'), ); @@ -712,7 +725,7 @@ describe('output formats', function() { ); }); - it('should support importing sibling bundles in library mode', async function() { + it('should support importing sibling bundles in library mode', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-siblings/a.js'), ); @@ -724,7 +737,7 @@ describe('output formats', function() { assert(dist.includes('import "./index.css"')); }); - it('should support esmodule output (skipped exports)', async function() { + it('should support esmodule output (skipped exports)', async function () { let b = await bundle( path.join( __dirname, @@ -739,7 +752,7 @@ describe('output formats', function() { assert(!dist.includes('foo')); }); - it('should support interop imports from other bundles', async function() { + it('should support interop imports from other bundles', async function () { let b = await bundle( path.join( __dirname, @@ -767,7 +780,7 @@ describe('output formats', function() { assert.deepEqual(await ns.default, [123, 123]); }); - it('should rename imports that conflict with exports', async function() { + it('should rename imports that conflict with exports', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-conflict/a.js'), ); @@ -775,7 +788,7 @@ describe('output formats', function() { await assertESMExports(b, {foo: 13}, {foo: () => ({foo: 10})}); }); - it('should support async imports', async function() { + it('should support async imports', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-async/index.js'), ); @@ -791,7 +804,7 @@ describe('output formats', function() { // This is currently not possible, it would have to do something like this: // export { $id$init().foo as foo }; - it.skip('should support dynamic imports with chained reexports', async function() { + it.skip('should support dynamic imports with chained reexports', async function () { let b = await bundle( path.join( __dirname, @@ -806,7 +819,7 @@ describe('output formats', function() { assert(!/\$export\$default\s+=/.test(async)); }); - it('should support dynamic imports with chained reexports II', async function() { + it('should support dynamic imports with chained reexports II', async function () { let b = await bundle( path.join( __dirname, @@ -822,7 +835,7 @@ describe('output formats', function() { await assertESMExports(b, ['index', 'a', 1], {}, ns => ns.default); }); - it('should throw an error on missing export with esmodule output and sideEffects: false', async function() { + it('should throw an error on missing export with esmodule output and sideEffects: false', async function () { let message = "b.js does not export 'a'"; let source = path.join( __dirname, @@ -868,7 +881,7 @@ describe('output formats', function() { ); }); - it('should support async split bundles', async function() { + it('should support async split bundles', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-split/index.js'), { @@ -894,7 +907,7 @@ describe('output formats', function() { ); }); - it('should call init for wrapped modules when codesplitting to esmodules', async function() { + it('should call init for wrapped modules when codesplitting to esmodules', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-wrap-codesplit/a.js'), ); @@ -904,7 +917,7 @@ describe('output formats', function() { assert.deepStrictEqual(await ns.default, 2); }); - it('should support async split bundles for workers', async function() { + it('should support async split bundles for workers', async function () { let b = await bundle( path.join( __dirname, @@ -942,7 +955,7 @@ describe('output formats', function() { ); }); - it('should support building esmodules for browser targets', async function() { + it('should support building esmodules for browser targets', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-browser/index.html'), ); @@ -974,7 +987,7 @@ describe('output formats', function() { assert.equal(await res.output, 4); }); - it('should support use an import polyfill for older browsers', async function() { + it('should support use an import polyfill for older browsers', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-browser/index.html'), { @@ -1018,7 +1031,7 @@ describe('output formats', function() { ); }); - it('should support building esmodules with css imports', async function() { + it('should support building esmodules with css imports', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-browser-css/index.html'), ); @@ -1065,7 +1078,7 @@ describe('output formats', function() { assert(!async.includes('.css"')); }); - it('should support building esmodules with split bundles', async function() { + it('should support building esmodules with split bundles', async function () { let b = await bundle( path.join( __dirname, @@ -1110,7 +1123,7 @@ describe('output formats', function() { } }); - it('should create correct bundle import for reexports', async function() { + it('should create correct bundle import for reexports', async function () { let b = await bundle( path.join( __dirname, @@ -1126,7 +1139,7 @@ describe('output formats', function() { ); }); - it('should support generating ESM from CommonJS', async function() { + it('should support generating ESM from CommonJS', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-esm/index.js'), ); @@ -1135,7 +1148,7 @@ describe('output formats', function() { assert.strictEqual(ns.default(1, 2), 3); }); - it('should support re-assigning to module.exports', async function() { + it('should support re-assigning to module.exports', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/commonjs-esm/re-assign.js'), ); @@ -1144,7 +1157,7 @@ describe('output formats', function() { assert.deepStrictEqual({...ns}, {default: 'xyz'}); }); - it.skip("doesn't support require.resolve calls for excluded assets without commonjs", async function() { + it.skip("doesn't support require.resolve calls for excluded assets without commonjs", async function () { let message = "'require.resolve' calls for excluded assets are only supported with outputFormat: 'commonjs'"; let source = path.join( @@ -1181,7 +1194,7 @@ describe('output formats', function() { }); }); - it('should support generating commonjs output with re-exports in entry', async function() { + it('should support generating commonjs output with re-exports in entry', async function () { let b = await bundle( path.join( __dirname, @@ -1193,7 +1206,7 @@ describe('output formats', function() { assert.deepEqual({...ns}, {default: {default: 'default'}}); }); - it('should rename shadowed imported specifiers to something unique', async function() { + it('should rename shadowed imported specifiers to something unique', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-import-shadow/a.mjs'), ); @@ -1211,7 +1224,7 @@ describe('output formats', function() { assert.strictEqual(useContext(), 'Hello World'); }); - it('should rename shadowed exports to something unique', async function() { + it('should rename shadowed exports to something unique', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-export-shadow/a.mjs'), ); @@ -1220,7 +1233,7 @@ describe('output formats', function() { assert.strictEqual(ns.fib(5), 8); }); - it('should support ESM output from CJS input', async function() { + it('should support ESM output from CJS input', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-cjs/a.js'), ); @@ -1230,7 +1243,7 @@ describe('output formats', function() { assert.deepEqual(ns.default, {test: true}); }); - it('should support outputting .mjs files', async function() { + it('should support outputting .mjs files', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-mjs/index.js'), ); @@ -1241,7 +1254,7 @@ describe('output formats', function() { assert(output.includes('import ')); }); - it('should support outputting ESM in .js files with "type": "module"', async function() { + it('should support outputting ESM in .js files with "type": "module"', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/esm-type-module/index.js'), ); @@ -1252,7 +1265,7 @@ describe('output formats', function() { assert(output.includes('import ')); }); - it('.cjs extension should override "type": "module"', async function() { + it('.cjs extension should override "type": "module"', async function () { let b = await bundle( path.join(__dirname, '/integration/formats/cjs-type-module/index.js'), ); @@ -1264,7 +1277,7 @@ describe('output formats', function() { assert(output.includes('require(')); }); - it('should compile workers to statically analyzable URL expressions', async function() { + it('should compile workers to statically analyzable URL expressions', async function () { let b = await bundle( path.join(__dirname, '/integration/workers-module/index.js'), { @@ -1304,7 +1317,7 @@ describe('output formats', function() { ); }); - it('should compile url: pipeline dependencies to statically analyzable URL expressions for libraries', async function() { + it('should compile url: pipeline dependencies to statically analyzable URL expressions for libraries', async function () { let b = await bundle( path.join(__dirname, '/integration/worklet/pipeline.js'), { @@ -1331,7 +1344,7 @@ describe('output formats', function() { ); }); - it('should URL dependencies to statically analyzable URL expressions for libraries', async function() { + it('should URL dependencies to statically analyzable URL expressions for libraries', async function () { let b = await bundle( path.join(__dirname, '/integration/worklet/url.js'), { @@ -1359,7 +1372,7 @@ describe('output formats', function() { }); }); - it('should support generating ESM from universal module wrappers', async function() { + it('should support generating ESM from universal module wrappers', async function () { let b = await bundle( path.join( __dirname, @@ -1371,7 +1384,7 @@ describe('output formats', function() { assert.deepEqual({...ns}, {default: {a: 2}}); }); - it("doesn't overwrite used global variables", async function() { + it("doesn't overwrite used global variables", async function () { let b = await bundle( path.join(__dirname, '/integration/formats/conflict-global/index.js'), ); @@ -1403,8 +1416,8 @@ describe('output formats', function() { assert.deepEqual(calls, [[['a', 10]]]); }); - describe('global', function() { - it.skip('should support split bundles between main script and workers', async function() { + describe('global', function () { + it.skip('should support split bundles between main script and workers', async function () { let b = await bundle( path.join( __dirname, @@ -1452,7 +1465,7 @@ describe('output formats', function() { assert.strictEqual(res.output, 30); }); - it('should support async split bundles for workers', async function() { + it('should support async split bundles for workers', async function () { await bundle( path.join( __dirname, @@ -1467,7 +1480,7 @@ describe('output formats', function() { ); }); - it('should throw with external modules', async function() { + it('should throw with external modules', async function () { let message = 'External modules are not supported when building for browser'; let source = path.join( diff --git a/packages/core/integration-tests/test/parser.js b/packages/core/integration-tests/test/parser.js index f517a6cd35b..c65019bc6cf 100644 --- a/packages/core/integration-tests/test/parser.js +++ b/packages/core/integration-tests/test/parser.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, assertBundleTree, inputFS as fs} from '@parcel/test-utils'; -describe.skip('parser', function() { - it('should support case-insensitive file extension', async function() { +describe.skip('parser', function () { + it('should support case-insensitive file extension', async function () { let b = await bundle( path.join( __dirname, diff --git a/packages/core/integration-tests/test/plugin.js b/packages/core/integration-tests/test/plugin.js index 0ecad0d2764..26256535e64 100644 --- a/packages/core/integration-tests/test/plugin.js +++ b/packages/core/integration-tests/test/plugin.js @@ -14,8 +14,8 @@ import { run, } from '@parcel/test-utils'; -describe('plugin', function() { - it("continue transformer pipeline on type change that doesn't change the pipeline", async function() { +describe('plugin', function () { + it("continue transformer pipeline on type change that doesn't change the pipeline", async function () { await bundle( path.join(__dirname, '/integration/pipeline-type-change/index.ini'), ); @@ -29,7 +29,7 @@ parcel-transformer-b`, ); }); - it('should allow optimizer plugins to change the output file type', async function() { + it('should allow optimizer plugins to change the output file type', async function () { await bundle( path.join(__dirname, '/integration/optimizer-changing-type/index.js'), ); @@ -37,7 +37,7 @@ parcel-transformer-b`, assert.deepEqual(fs.readdirSync(distDir), ['index.test']); }); - it('should allow resolver plugins to disable deferring', async function() { + it('should allow resolver plugins to disable deferring', async function () { let b = await bundle( path.join(__dirname, '/integration/resolver-canDefer/index.js'), {mode: 'production'}, @@ -51,7 +51,7 @@ parcel-transformer-b`, ]); }); - it('should allow resolvers to return changes for dependency.meta', async function() { + it('should allow resolvers to return changes for dependency.meta', async function () { let b = await bundle( path.join(__dirname, '/integration/resolver-dependency-meta/a.js'), {shouldDisableCache: false, shouldContentHash: false, inputFS: overlayFS}, @@ -87,7 +87,7 @@ parcel-transformer-b`, assert.deepEqual(calls, [1234]); }); - it('invalidate the cache based on loadConfig in a packager', async function() { + it('invalidate the cache based on loadConfig in a packager', async function () { let fixture = path.join(__dirname, '/integration/packager-loadConfig'); let entry = path.join(fixture, 'index.txt'); let config = path.join(fixture, 'foo.config.json'); @@ -113,7 +113,7 @@ parcel-transformer-b`, ); }); - it('merges symbol information when applying runtime assets', async function() { + it('merges symbol information when applying runtime assets', async function () { let b = await bundle( path.join(__dirname, '/integration/runtime-symbol-merging/entry.js'), { @@ -153,7 +153,7 @@ parcel-transformer-b`, assert.deepStrictEqual(calls, [789, 123]); }); - it('properly excludes assets that are excluded and deferred by both app code and runtimes', async function() { + it('properly excludes assets that are excluded and deferred by both app code and runtimes', async function () { let b = await bundle( path.join(__dirname, '/integration/runtime-deferred-excluded/index.js'), { @@ -178,7 +178,7 @@ parcel-transformer-b`, assert.deepStrictEqual(calls, ['used']); }); - it('handles multiple assets returned by a transformer', async function() { + it('handles multiple assets returned by a transformer', async function () { let b = await bundle( path.join(__dirname, '/integration/multi-asset-transformer/index.js'), { diff --git a/packages/core/integration-tests/test/pnp.js b/packages/core/integration-tests/test/pnp.js index 6beda9ea8dc..af4288a268b 100644 --- a/packages/core/integration-tests/test/pnp.js +++ b/packages/core/integration-tests/test/pnp.js @@ -3,8 +3,8 @@ import Module from 'module'; import path from 'path'; import {bundle, run, assertBundles} from '@parcel/test-utils'; -describe('pnp', function() { - it('should defer to the pnp resolution when needed', async function() { +describe('pnp', function () { + it('should defer to the pnp resolution when needed', async function () { let dir = path.join(__dirname, 'integration/pnp-require'); let origPnpVersion = process.versions.pnp; @@ -35,7 +35,7 @@ describe('pnp', function() { } }); - it('should support importing Node builtin modules from npm when requested', async function() { + it('should support importing Node builtin modules from npm when requested', async function () { let dir = path.join(__dirname, 'integration/pnp-builtin'); let origPnpVersion = process.versions.pnp; diff --git a/packages/core/integration-tests/test/postcss.js b/packages/core/integration-tests/test/postcss.js index 45c185b7d64..07ebf71e3c4 100644 --- a/packages/core/integration-tests/test/postcss.js +++ b/packages/core/integration-tests/test/postcss.js @@ -153,6 +153,47 @@ describe('postcss', () => { ); }); + it('should produce correct css without symbol propagation for css modules classes with a namespace import', async () => { + let b = await bundle( + path.join( + __dirname, + '/integration/postcss-modules-import-namespace/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); + + assertBundles(b, [ + { + name: 'index.js', + assets: ['index.js', 'style.module.css'], + }, + { + name: 'index.css', + assets: ['global.css', 'style.module.css'], + }, + ]); + + let {output} = await run(b, null, {require: false}); + assert(/_b-2_[0-9a-z]/.test(output)); + + let css = await outputFS.readFile( + b.getBundles().find(b => b.type === 'css').filePath, + 'utf8', + ); + let includedRules = new Set(); + postcss.parse(css).walkRules(rule => { + includedRules.add(rule.selector); + }); + assert(includedRules.has('body')); + assert(includedRules.has(`.${output}`)); + assert(includedRules.has('.page')); + }); + it('should support importing css modules with a non-static namespace import', async () => { let b = await bundle( path.join( @@ -210,6 +251,16 @@ describe('postcss', () => { assert.equal(run1(), run2()); }); + it('should support transforming declarations with missing source', async () => { + await bundle( + path.join(__dirname, '/integration/postcss-plugins-decl/index.css'), + ); + + let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8'); + + assert(css.includes('url("data:image/gif;base64,quotes")')); + }); + it('should support postcss composes imports', async () => { let b = await bundle( path.join(__dirname, '/integration/postcss-composes/index.js'), @@ -442,7 +493,7 @@ describe('postcss', () => { // https://stackoverflow.com/questions/15971167/how-to-increase-timeout-for-a-single-test-case-in-mocha }); - it('should support using postcss for importing', async function() { + it('should support using postcss for importing', async function () { let b = await bundle( path.join(__dirname, '/integration/postcss-import/style.css'), ); @@ -458,7 +509,7 @@ describe('postcss', () => { assert.equal(css.split('red').length - 1, 1); }); - it('should support using a postcss config in package.json', async function() { + it('should support using a postcss config in package.json', async function () { let b = await bundle( path.join(__dirname, '/integration/postcss-config-package/style.css'), ); @@ -475,7 +526,7 @@ describe('postcss', () => { assert(/background-color:\s*red/.test(css)); }); - it('Should support postcss.config.js config file with PostCSS 7 plugin', async function() { + it('Should support postcss.config.js config file with PostCSS 7 plugin', async function () { let b = await bundle( path.join(__dirname, '/integration/postcss-js-config-7/style.css'), ); @@ -491,7 +542,7 @@ describe('postcss', () => { assert(css.includes('background-color: red;')); }); - it('Should support postcss.config.js config file with PostCSS 8 plugin', async function() { + it('Should support postcss.config.js config file with PostCSS 8 plugin', async function () { let b = await bundle( path.join(__dirname, '/integration/postcss-js-config-8/style.css'), ); @@ -504,13 +555,11 @@ describe('postcss', () => { ]); }); - it('should support dir-dependency messages from plugins', async function() { + it('should support dir-dependency messages from plugins', async function () { let inputDir = path.join( __dirname, '/input', - Math.random() - .toString(36) - .slice(2), + Math.random().toString(36).slice(2), ); await inputFS.mkdirp(inputDir); await inputFS.ncp( @@ -574,4 +623,53 @@ describe('postcss', () => { await subscription.unsubscribe(); }); + + it('should throw an error when importing a missing class', async function () { + await assert.rejects( + () => + bundle( + path.join( + __dirname, + '/integration/no-export-error-with-correct-filetype/src/App.jsx', + ), + { + shouldDisableCache: true, + defaultTargetOptions: { + shouldScopeHoist: true, + }, + }, + ), + { + name: 'BuildError', + diagnostics: [ + { + codeFrames: [ + { + filePath: path.join( + __dirname, + '/integration/no-export-error-with-correct-filetype/src/App.jsx', + ), + language: 'js', + codeHighlights: [ + { + end: { + column: 45, + line: 7, + }, + start: { + column: 28, + line: 7, + }, + }, + ], + }, + ], + message: + "integration/no-export-error-with-correct-filetype/src/app.module.css does not export 'notExisting'", + origin: '@parcel/core', + }, + ], + }, + ); + }); }); diff --git a/packages/core/integration-tests/test/posthtml.js b/packages/core/integration-tests/test/posthtml.js index 14e4ff73293..030b858dfec 100644 --- a/packages/core/integration-tests/test/posthtml.js +++ b/packages/core/integration-tests/test/posthtml.js @@ -15,12 +15,12 @@ import { MockPackageInstaller, } from '@parcel/package-manager'; -describe('posthtml', function() { +describe('posthtml', function () { afterEach(async () => { await removeDistDirectory(); }); - it('should support transforming HTML with posthtml', async function() { + it('should support transforming HTML with posthtml', async function () { let b = await bundle( path.join(__dirname, '/integration/posthtml/index.html'), ); @@ -36,7 +36,7 @@ describe('posthtml', function() { assert(html.includes('

Other page

')); }); - it('should find assets inside posthtml', async function() { + it('should find assets inside posthtml', async function () { let b = await bundle( path.join(__dirname, '/integration/posthtml-assets/index.html'), ); @@ -53,7 +53,7 @@ describe('posthtml', function() { ]); }); - it('Should be able to process an html file with plugins without any params for plugin', async function() { + it('Should be able to process an html file with plugins without any params for plugin', async function () { let b = await bundle( path.join(__dirname, '/integration/posthtml-plugins/index.html'), ); diff --git a/packages/core/integration-tests/test/proxy.js b/packages/core/integration-tests/test/proxy.js index 48b3c271011..34e53dd7fa7 100644 --- a/packages/core/integration-tests/test/proxy.js +++ b/packages/core/integration-tests/test/proxy.js @@ -47,11 +47,11 @@ function get(file, port, client = http) { }); } -describe('proxy', function() { +describe('proxy', function () { let subscription; let cwd; let server; - beforeEach(function() { + beforeEach(function () { cwd = inputFS.cwd(); }); @@ -67,7 +67,7 @@ describe('proxy', function() { server = null; }); - it('should handle proxy table written in .proxyrc', async function() { + it('should handle proxy table written in .proxyrc', async function () { let dir = path.join(__dirname, 'integration/proxyrc'); inputFS.chdir(dir); @@ -93,7 +93,7 @@ describe('proxy', function() { assert.equal(data, 'Request URL: /api/get'); }); - it('should handle proxy table written in .proxyrc.json', async function() { + it('should handle proxy table written in .proxyrc.json', async function () { let dir = path.join(__dirname, 'integration/proxyrc-json'); inputFS.chdir(dir); @@ -119,7 +119,7 @@ describe('proxy', function() { assert.equal(data, 'Request URL: /api/get'); }); - it('should handle proxy table written in .proxyrc.js', async function() { + it('should handle proxy table written in .proxyrc.js', async function () { let dir = path.join(__dirname, 'integration/proxyrc-js'); inputFS.chdir(dir); diff --git a/packages/core/integration-tests/test/pug.js b/packages/core/integration-tests/test/pug.js index 6b2bfdd618a..ca54d65ffed 100644 --- a/packages/core/integration-tests/test/pug.js +++ b/packages/core/integration-tests/test/pug.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, assertBundles, outputFS, distDir} from '@parcel/test-utils'; -describe('pug', function() { - it('should support bundling HTML', async function() { +describe('pug', function () { + it('should support bundling HTML', async function () { const b = await bundle(path.join(__dirname, '/integration/pug/index.pug')); assertBundles(b, [ @@ -40,7 +40,7 @@ describe('pug', function() { } }); - it('should support include and extends files, connect files', async function() { + it('should support include and extends files, connect files', async function () { const b = await bundle( path.join(__dirname, '/integration/pug-include-extends/index.pug'), ); @@ -60,7 +60,7 @@ describe('pug', function() { assert(html.includes('

And for nested.

')); }); - it('should support variables', async function() { + it('should support variables', async function () { const b = await bundle( path.join(__dirname, '/integration/pug-var/index.pug'), ); @@ -81,7 +81,7 @@ describe('pug', function() { assert(/src="\/?100x100.*.png"/.test(html)); }); - it('should support mixins', async function() { + it('should support mixins', async function () { const b = await bundle( path.join(__dirname, '/integration/pug-mixins/index.pug'), ); @@ -98,7 +98,7 @@ describe('pug', function() { assert(html.includes('Greetings, Parcel')); }); - it('should support filters', async function() { + it('should support filters', async function () { const b = await bundle( path.join(__dirname, '/integration/pug-filters/index.pug'), ); @@ -115,7 +115,7 @@ describe('pug', function() { assert(html.includes('FILTERED: Hello!')); }); - it('should support locals with config file', async function() { + it('should support locals with config file', async function () { const b = await bundle( path.join(__dirname, '/integration/pug-locals/index.pug'), ); @@ -132,7 +132,7 @@ describe('pug', function() { assert(html.includes("It's a great!")); }); - it('should minify HTML in production mode', async function() { + it('should minify HTML in production mode', async function () { const b = await bundle( path.join(__dirname, '/integration/pug-minify/index.pug'), ); diff --git a/packages/core/integration-tests/test/react-refresh.js b/packages/core/integration-tests/test/react-refresh.js index af1c88021fe..2a75b6156de 100644 --- a/packages/core/integration-tests/test/react-refresh.js +++ b/packages/core/integration-tests/test/react-refresh.js @@ -27,7 +27,7 @@ try { } if (MessageChannel) { - describe('react-refresh', function() { + describe('react-refresh', function () { describe('synchronous', () => { const testDir = path.join(__dirname, '/integration/react-refresh'); @@ -43,7 +43,7 @@ if (MessageChannel) { )); }); - it('retains state in functional components', async function() { + it('retains state in functional components', async function () { await fs.mkdirp(testDir); await fs.copyFile( path.join(testDir, 'Foo.1.js'), @@ -63,7 +63,7 @@ if (MessageChannel) { assert.equal(fooText, 'OtherFunctional'); }); - it('supports changing hooks in functional components', async function() { + it('supports changing hooks in functional components', async function () { await fs.mkdirp(testDir); await fs.copyFile( path.join(testDir, 'Foo.2-hooks.js'), @@ -74,16 +74,10 @@ if (MessageChannel) { // Wait for the hmr-runtime to process the event await sleep(100); - let [ - , - indexNum, - appNum, - fooText, - fooNum, - fooNum2, - ] = root.textContent.match( - /^([\d.]+) ([\d.]+) ([\w]+):([\d.]+):([\d.]+)$/, - ); + let [, indexNum, appNum, fooText, fooNum, fooNum2] = + root.textContent.match( + /^([\d.]+) ([\d.]+) ([\w]+):([\d.]+):([\d.]+)$/, + ); assert.equal(randoms.indexNum, indexNum); assert.equal(randoms.appNum, appNum); assert.notEqual(randoms.fooNum, fooNum); @@ -91,7 +85,7 @@ if (MessageChannel) { assert.equal(fooText, 'Hooks'); }); - it('retains state in parent components when swapping function and class component', async function() { + it('retains state in parent components when swapping function and class component', async function () { await fs.mkdirp(testDir); await fs.copyFile( path.join(testDir, 'Foo.3-class.js'), @@ -134,7 +128,7 @@ if (MessageChannel) { )); }); - it('retains state in async components on change', async function() { + it('retains state in async components on change', async function () { assert.equal(randoms.fooText, 'Async'); await fs.mkdirp(testDir); diff --git a/packages/core/integration-tests/test/reason.js b/packages/core/integration-tests/test/reason.js index 75c9a9129e2..e39ad1a1f0d 100644 --- a/packages/core/integration-tests/test/reason.js +++ b/packages/core/integration-tests/test/reason.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, run} from '@parcel/test-utils'; -describe.skip('reason', function() { - it('should produce a bundle', async function() { +describe.skip('reason', function () { + it('should produce a bundle', async function () { let b = await bundle(path.join(__dirname, '/integration/reason/index.js')); assert.equal(b.assets.size, 2); diff --git a/packages/core/integration-tests/test/resolver.js b/packages/core/integration-tests/test/resolver.js index a9cce188d35..d99b93c9c41 100644 --- a/packages/core/integration-tests/test/resolver.js +++ b/packages/core/integration-tests/test/resolver.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, run, ncp, overlayFS, outputFS} from '@parcel/test-utils'; -describe('resolver', function() { - it('should support resolving tilde in monorepo packages', async function() { +describe('resolver', function () { + it('should support resolving tilde in monorepo packages', async function () { let b = await bundle( path.join( __dirname, @@ -15,7 +15,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 1234); }); - it('should support node: prefix for node_modules', async function() { + it('should support node: prefix for node_modules', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-node-prefix/src/index.js'), ); @@ -27,7 +27,7 @@ describe('resolver', function() { ); }); - it('should correctly resolve tilde in node_modules', async function() { + it('should correctly resolve tilde in node_modules', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-tilde-nodemodules/index.js'), ); @@ -36,7 +36,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 1234); }); - it('should fall back to index.js if the resolved `main` file does not exist', async function() { + it('should fall back to index.js if the resolved `main` file does not exist', async function () { let b = await bundle( path.join( __dirname, @@ -48,7 +48,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 42); }); - it('should fall back to index.js if there is no `main` field at all', async function() { + it('should fall back to index.js if there is no `main` field at all', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-index-fallback/no-entry.js'), ); @@ -57,7 +57,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 42); }); - it('should print a diagnostic when a configured target field will overwrite an entry', async function() { + it('should print a diagnostic when a configured target field will overwrite an entry', async function () { let errorThrows = 0; const overwriteDirs = ['browser', 'app', 'main', 'module']; for (const currDir of overwriteDirs) { @@ -89,7 +89,7 @@ describe('resolver', function() { assert.deepEqual(errorThrows, overwriteDirs.length); }); - it('should throw an error on Webpack loader imports', async function() { + it('should throw an error on Webpack loader imports', async function () { let didThrow = false; try { await bundle( @@ -109,7 +109,7 @@ describe('resolver', function() { assert(didThrow); }); - it('should throw an error with codeframe on invalid js import', async function() { + it('should throw an error with codeframe on invalid js import', async function () { let didThrow = false; try { await bundle( @@ -133,7 +133,7 @@ describe('resolver', function() { assert(didThrow); }); - it('should throw an error with codeframe on invalid css import', async function() { + it('should throw an error with codeframe on invalid css import', async function () { let didThrow = false; try { await bundle( @@ -157,7 +157,7 @@ describe('resolver', function() { assert(didThrow); }); - it('Should return codeframe with hints when package.json is invalid', async function() { + it('Should return codeframe with hints when package.json is invalid', async function () { let didThrow = false; try { await bundle( @@ -187,7 +187,7 @@ describe('resolver', function() { assert(didThrow); }); - it('Should suggest alternative filenames for relative imports', async function() { + it('Should suggest alternative filenames for relative imports', async function () { let threw = 0; try { @@ -244,7 +244,7 @@ describe('resolver', function() { assert.equal(threw, 3); }); - it('Should suggest alternative modules for module imports', async function() { + it('Should suggest alternative modules for module imports', async function () { let threw = false; try { @@ -268,7 +268,7 @@ describe('resolver', function() { assert(threw); }); - it('should resolve packages to packages through the alias field', async function() { + it('should resolve packages to packages through the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/package-to-package.js'), ); @@ -277,7 +277,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 3); }); - it('should resolve packages to local files through the alias field', async function() { + it('should resolve packages to local files through the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/package-to-local.js'), ); @@ -286,7 +286,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 'bar'); }); - it('should exclude local files using the alias field', async function() { + it('should exclude local files using the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/exclude-local.js'), ); @@ -295,7 +295,7 @@ describe('resolver', function() { assert.deepEqual(output.default, {}); }); - it('should exclude packages using the alias field', async function() { + it('should exclude packages using the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/exclude-package.js'), ); @@ -304,7 +304,7 @@ describe('resolver', function() { assert.deepEqual(output.default, {}); }); - it('should support symlinked node_modules structure', async function() { + it('should support symlinked node_modules structure', async function () { const rootDir = path.join( __dirname, 'integration/resolve-symlinked-node_modules-structure', @@ -346,7 +346,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 42); }); - it('should support symlinked monorepos structure', async function() { + it('should support symlinked monorepos structure', async function () { const rootDir = path.join( __dirname, 'integration/resolve-symlinked-monorepos', @@ -382,4 +382,20 @@ describe('resolver', function() { let output = await run(b); assert.strictEqual(output.default, 2); }); + + it('should support very long dependency specifiers', async function () { + this.timeout(8000); + + let inputDir = path.join(__dirname, 'input'); + + await outputFS.mkdirp(inputDir); + await outputFS.writeFile( + path.join(inputDir, 'index.html'), + ``, + ); + + await bundle(path.join(inputDir, 'index.html'), { + inputFS: overlayFS, + }); + }); }); diff --git a/packages/core/integration-tests/test/rust.js b/packages/core/integration-tests/test/rust.js index a84e90033d8..d3c8acd7cb7 100644 --- a/packages/core/integration-tests/test/rust.js +++ b/packages/core/integration-tests/test/rust.js @@ -9,7 +9,7 @@ import { } from '@parcel/test-utils'; import commandExists from 'command-exists'; -describe.skip('rust', function() { +describe.skip('rust', function () { if (typeof WebAssembly === 'undefined' || !commandExists.sync('rustup')) { // eslint-disable-next-line no-console console.log( @@ -18,7 +18,7 @@ describe.skip('rust', function() { return; } - it('should generate a wasm file from a rust file with rustc with --target=browser', async function() { + it('should generate a wasm file from a rust file with rustc with --target=browser', async function () { this.timeout(500000); let b = await bundle(path.join(__dirname, '/integration/rust/index.js')); @@ -51,7 +51,7 @@ describe.skip('rust', function() { ); }); - it('should generate a wasm file from a rust file with rustc with --target=node', async function() { + it('should generate a wasm file from a rust file with rustc with --target=node', async function () { this.timeout(500000); let b = await bundle(path.join(__dirname, '/integration/rust/index.js'), { target: 'node', @@ -86,7 +86,7 @@ describe.skip('rust', function() { ); }); - it('should support rust files with dependencies via rustc', async function() { + it('should support rust files with dependencies via rustc', async function () { this.timeout(500000); let b = bundler(path.join(__dirname, '/integration/rust-deps/index.js')); let bundle = await b.bundle(); @@ -115,7 +115,7 @@ describe.skip('rust', function() { assert.equal(res, 10); }); - it('should generate a wasm file from a rust file with cargo', async function() { + it('should generate a wasm file from a rust file with cargo', async function () { this.timeout(500000); let b = await bundle( path.join(__dirname, '/integration/rust-cargo/src/index.js'), @@ -145,7 +145,7 @@ describe.skip('rust', function() { assert.equal(res, 5); }); - it('should generate a wasm file from a rust file in cargo workspace', async function() { + it('should generate a wasm file from a rust file in cargo workspace', async function () { this.timeout(500000); let b = await bundle( path.join( diff --git a/packages/core/integration-tests/test/sass.js b/packages/core/integration-tests/test/sass.js index e8ec2f6d084..43916215d83 100644 --- a/packages/core/integration-tests/test/sass.js +++ b/packages/core/integration-tests/test/sass.js @@ -8,8 +8,8 @@ import { outputFS, } from '@parcel/test-utils'; -describe('sass', function() { - it('should support requiring sass files', async function() { +describe('sass', function () { + it('should support requiring sass files', async function () { let b = await bundle(path.join(__dirname, '/integration/sass/index.js')); assertBundles(b, [ @@ -31,7 +31,7 @@ describe('sass', function() { assert(css.includes('.index')); }); - it('should support requiring scss files', async function() { + it('should support requiring scss files', async function () { let b = await bundle(path.join(__dirname, '/integration/scss/index.js')); assertBundles(b, [ @@ -53,7 +53,7 @@ describe('sass', function() { assert(css.includes('.index')); }); - it('should support scss imports', async function() { + it('should support scss imports', async function () { let b = await bundle( path.join(__dirname, '/integration/scss-import/index.js'), ); @@ -79,7 +79,7 @@ describe('sass', function() { assert(css.includes('.bar')); }); - it('should support requiring empty scss files', async function() { + it('should support requiring empty scss files', async function () { let b = await bundle( path.join(__dirname, '/integration/scss-empty/index.js'), ); @@ -103,7 +103,7 @@ describe('sass', function() { assert.equal(css.trim(), '/*# sourceMappingURL=index.css.map */'); }); - it('should support linking to assets with url() from scss', async function() { + it('should support linking to assets with url() from scss', async function () { let b = await bundle( path.join(__dirname, '/integration/scss-url/index.js'), ); @@ -143,7 +143,7 @@ describe('sass', function() { ); }); - it('should support transforming scss with postcss', async function() { + it('should support transforming scss with postcss', async function () { let b = await bundle( path.join(__dirname, '/integration/scss-postcss/index.js'), ); @@ -168,7 +168,7 @@ describe('sass', function() { assert(css.includes(`.${className}`)); }); - it('should support advanced import syntax', async function() { + it('should support advanced import syntax', async function () { let b = await bundle( path.join(__dirname, '/integration/sass-advanced-import/index.sass'), ); @@ -187,7 +187,7 @@ describe('sass', function() { assert(css.includes('.bar { color: green;')); }); - it('should support absolute imports', async function() { + it('should support absolute imports', async function () { let b = await bundle( path.join(__dirname, '/integration/scss-absolute-imports/style.scss'), ); @@ -204,7 +204,7 @@ describe('sass', function() { assert(css.includes('.b')); }); - it('should merge global data property from .sassrc.js', async function() { + it('should merge global data property from .sassrc.js', async function () { let b = await bundle( path.join(__dirname, '/integration/scss-global-data/index.scss'), ); @@ -222,7 +222,7 @@ describe('sass', function() { assert(css.includes('.a { color: red;')); }); - it('should support using the custom webpack/sass node_modules syntax', async function() { + it('should support using the custom webpack/sass node_modules syntax', async function () { let b = await bundle( path.join(__dirname, '/integration/sass-webpack-import-error/index.sass'), ); @@ -238,7 +238,7 @@ describe('sass', function() { assert(css.includes('.external')); }); - it('should support node_modules imports', async function() { + it('should support node_modules imports', async function () { let b = await bundle( path.join(__dirname, '/integration/sass-node-modules-import/index.sass'), ); @@ -254,7 +254,7 @@ describe('sass', function() { assert(css.includes('.external')); }); - it('should support imports from includePaths', async function() { + it('should support imports from includePaths', async function () { let b = await bundle( path.join(__dirname, '/integration/sass-include-paths-import/index.sass'), ); diff --git a/packages/core/integration-tests/test/schema-jsonld.js b/packages/core/integration-tests/test/schema-jsonld.js index 663f18ac8c9..dd56330d082 100644 --- a/packages/core/integration-tests/test/schema-jsonld.js +++ b/packages/core/integration-tests/test/schema-jsonld.js @@ -2,8 +2,8 @@ import {bundle, assertBundles, distDir, outputFS} from '@parcel/test-utils'; import path from 'path'; import assert from 'assert'; -describe('jsonld', function() { - it('Should parse a LD+JSON schema and collect dependencies', async function() { +describe('jsonld', function () { + it('Should parse a LD+JSON schema and collect dependencies', async function () { let b = await bundle( path.join(__dirname, '/integration/schema-jsonld/index.html'), { diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index 39c215b3ae4..b871856e0f1 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -49,9 +49,9 @@ const bundler = (name, opts = {}) => { ); }; -describe('scope hoisting', function() { - describe('es6', function() { - it('supports default imports and exports of expressions', async function() { +describe('scope hoisting', function () { + describe('es6', function () { + it('supports default imports and exports of expressions', async function () { let b = await bundle( path.join( __dirname, @@ -63,7 +63,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports default imports and exports of declarations', async function() { + it('supports default imports and exports of declarations', async function () { let b = await bundle( path.join( __dirname, @@ -75,7 +75,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports default imports and exports of anonymous declarations', async function() { + it('supports default imports and exports of anonymous declarations', async function () { let b = await bundle( path.join( __dirname, @@ -87,7 +87,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports default imports and exports of variables', async function() { + it('supports default imports and exports of variables', async function () { let b = await bundle( path.join( __dirname, @@ -99,7 +99,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports named imports and exports of declarations', async function() { + it('supports named imports and exports of declarations', async function () { let b = await bundle( path.join( __dirname, @@ -111,7 +111,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports named imports and exports of variables', async function() { + it('supports named imports and exports of variables', async function () { let b = await bundle( path.join( __dirname, @@ -123,7 +123,30 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports renaming non-ASCII identifiers', async function() { + it('supports named exports of variables with a different name', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/named-export-variable-rename/a.js', + ), + ); + + let output = await run(b); + assert.equal(output, 2); + }); + it('supports named exports of variables with a different name when wrapped', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/named-export-variable-rename-wrapped/a.js', + ), + ); + + let output = await run(b); + assert.equal(output, 2); + }); + + it('supports renaming non-ASCII identifiers', async function () { let b = await bundle( path.join( __dirname, @@ -135,7 +158,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [1, 2, 3, 4]); }); - it('supports renaming superclass identifiers', async function() { + it('supports renaming superclass identifiers', async function () { let b = await bundle( path.join( __dirname, @@ -146,7 +169,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports renaming imports', async function() { + it('supports renaming imports', async function () { let b = await bundle( path.join( __dirname, @@ -158,7 +181,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports renaming exports', async function() { + it('supports renaming exports', async function () { let b = await bundle( path.join( __dirname, @@ -170,7 +193,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports importing from a reexporting asset in an anchestor (1)', async function() { + it('supports importing from a reexporting asset in an anchestor (1)', async function () { let b = await bundle( path.join( __dirname, @@ -182,7 +205,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['index', 'async']); }); - it('supports importing from a reexporting asset in an anchestor (2)', async function() { + it('supports importing from a reexporting asset in an anchestor (2)', async function () { let b = await bundle( path.join( __dirname, @@ -194,7 +217,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [123, 123]); }); - it('supports importing from a reexporting asset in an anchestor (3)', async function() { + it('supports importing from a reexporting asset in an anchestor (3)', async function () { let b = await bundle( path.join( __dirname, @@ -206,7 +229,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [123, 123]); }); - it('supports async import of internalized asset with unused return value', async function() { + it('supports async import of internalized asset with unused return value', async function () { let b = await bundle( path.join( __dirname, @@ -218,7 +241,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 'bc'); }); - it('supports importing a namespace of exported values', async function() { + it('supports importing a namespace of exported values', async function () { let b = await bundle( path.join( __dirname, @@ -230,7 +253,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports namespace imports of excluded assets (node_modules)', async function() { + it('supports namespace imports of excluded assets (node_modules)', async function () { let b = await bundle( path.join( __dirname, @@ -249,7 +272,7 @@ describe('scope hoisting', function() { assert.deepEqual(output.default, 12); }); - it('supports re-exporting all exports from another module', async function() { + it('supports re-exporting all exports from another module', async function () { let b = await bundle( path.join( __dirname, @@ -261,7 +284,54 @@ describe('scope hoisting', function() { assert.equal(output, 6); }); - it('supports re-exporting all exports from an external module', async function() { + it('supports re-exporting all when falling back to namespace at runtime 1', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/re-export-all-fallback-1/index.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output, 2); + }); + + it('supports re-exporting all when falling back to namespace at runtime 2', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/re-export-all-fallback-2/index.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output, 2); + }); + + it('supports re-exporting all when falling back to namespace at runtime 3', async function () { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-all-fallback-3/entry.js', + ), + ); + let output = await run(b); + assert.strictEqual(output, 'FOOBAR!'); + }); + + it('supports nested re-exporting all when falling back to namespace at runtime', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/re-export-all-fallback-nested/index.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output, '2 4'); + }); + + it('supports re-exporting all exports from an external module', async function () { let b = await bundle( path.join( __dirname, @@ -286,7 +356,7 @@ describe('scope hoisting', function() { // assert.equal(output, 3); }); - it('supports re-exporting all exports from multiple modules', async function() { + it('supports re-exporting all exports from multiple modules', async function () { let b = await bundle( path.join( __dirname, @@ -298,7 +368,7 @@ describe('scope hoisting', function() { assert.equal(output, 15); }); - it('can import from a different bundle via a re-export (1)', async function() { + it('can import from a different bundle via a re-export (1)', async function () { let b = await bundle( path.join( __dirname, @@ -310,7 +380,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['operational', 'ui']); }); - it('can import from a different bundle via a re-export (2)', async function() { + it('can import from a different bundle via a re-export (2)', async function () { let b = await bundle( path.join( __dirname, @@ -322,7 +392,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['foo', 'foo']); }); - it('can import from its own bundle with a split package', async function() { + it('can import from its own bundle with a split package', async function () { let b = await bundle( path.join( __dirname, @@ -334,7 +404,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [['a', 'b'], 'themed']); }); - it('supports importing all exports re-exported from multiple modules deep', async function() { + it('supports importing all exports re-exported from multiple modules deep', async function () { let b = await bundle( path.join( __dirname, @@ -346,7 +416,7 @@ describe('scope hoisting', function() { assert.equal(foo + bar + baz + a + bb, 15); }); - it('supports re-exporting all exports from multiple modules deep', async function() { + it('supports re-exporting all exports from multiple modules deep', async function () { let b = await bundle( path.join( __dirname, @@ -358,7 +428,7 @@ describe('scope hoisting', function() { assert.equal(output, 7); }); - it('supports re-exporting individual named exports from another module', async function() { + it('supports re-exporting individual named exports from another module', async function () { let b = await bundle( path.join( __dirname, @@ -370,7 +440,7 @@ describe('scope hoisting', function() { assert.equal(output, 3); }); - it('supports re-exporting default exports from another module', async function() { + it('supports re-exporting default exports from another module', async function () { let b = await bundle( path.join( __dirname, @@ -382,7 +452,7 @@ describe('scope hoisting', function() { assert.equal(output, 3); }); - it('supports re-exporting a namespace from another module', async function() { + it('supports re-exporting a namespace from another module', async function () { let b = await bundle( path.join( __dirname, @@ -394,7 +464,7 @@ describe('scope hoisting', function() { assert.equal(output, 6); }); - it('supports re-exporting a namespace from another module (chained)', async function() { + it('supports re-exporting a namespace from another module (chained)', async function () { let b = await bundle( path.join( __dirname, @@ -415,7 +485,7 @@ describe('scope hoisting', function() { }); }); - it('has the correct order with namespace re-exports', async function() { + it('has the correct order with namespace re-exports', async function () { let b = await bundle( path.join( __dirname, @@ -427,7 +497,7 @@ describe('scope hoisting', function() { assert.equal(output, Symbol.for('abc')); }); - it('excludes default when re-exporting a module', async function() { + it('excludes default when re-exporting a module', async function () { let source = path.normalize( 'integration/scope-hoisting/es6/re-export-exclude-default/a.js', ); @@ -465,7 +535,7 @@ describe('scope hoisting', function() { }); }); - it('throws when reexporting a missing symbol', async function() { + it('throws when reexporting a missing symbol', async function () { let source = path.normalize( 'integration/scope-hoisting/es6/re-export-missing/a.js', ); @@ -506,7 +576,7 @@ describe('scope hoisting', function() { }); }); - it('supports multiple exports of the same variable', async function() { + it('supports multiple exports of the same variable', async function () { let b = await bundle( path.join( __dirname, @@ -518,7 +588,7 @@ describe('scope hoisting', function() { assert.equal(output, 6); }); - it('supports live bindings of named exports', async function() { + it('supports live bindings of named exports', async function () { let b = await bundle( path.join( __dirname, @@ -530,7 +600,7 @@ describe('scope hoisting', function() { assert.equal(output, 8); }); - it('supports live bindings in namespaces of reexporting assets', async function() { + it('supports live bindings in namespaces of reexporting assets', async function () { let b = await bundle( path.join( __dirname, @@ -542,7 +612,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [1, 2]); }); - it('supports live bindings across bundles', async function() { + it('supports live bindings across bundles', async function () { let b = await bundle( ['a.html', 'b.html'].map(f => path.join( @@ -563,7 +633,7 @@ describe('scope hoisting', function() { assert.deepEqual(ctx.output, 'aaa'); }); - it('supports live bindings of default exports', async function() { + it('supports live bindings of default exports', async function () { // https://github.com/parcel-bundler/parcel/issues/5658 let b = await bundle( path.join( @@ -581,7 +651,7 @@ describe('scope hoisting', function() { assert.deepEqual(out, [5, 10]); }); - it('supports dynamic import syntax for code splitting', async function() { + it('supports dynamic import syntax for code splitting', async function () { let b = await bundle( path.join( __dirname, @@ -592,7 +662,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 5); }); - it('supports nested dynamic imports', async function() { + it('supports nested dynamic imports', async function () { let b = await bundle( path.join( __dirname, @@ -603,7 +673,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 123); }); - it('supports named exports before the variable declaration', async function() { + it('supports named exports before the variable declaration', async function () { let b = await bundle( path.join( __dirname, @@ -614,7 +684,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), {x: 2}); }); - it('should not export function arguments', async function() { + it('should not export function arguments', async function () { let b = await bundle( path.join( __dirname, @@ -626,7 +696,31 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['test']); }); - it('should default export globals', async function() { + it('should default export classes when wrapped', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/export-default-class-wrapped/a.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output.VERSION, 1234); + }); + + it('should default export functions when wrapped', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/export-default-function-wrapped/a.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output.VERSION, 1234); + }); + + it('should default export globals', async function () { let b = await bundle( path.join( __dirname, @@ -640,7 +734,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, Test); }); - it('should default export JS globals', async function() { + it('should default export JS globals', async function () { let b = await bundle( path.join( __dirname, @@ -652,7 +746,7 @@ describe('scope hoisting', function() { assert(new output([1, 2, 3]).has(1)); }); - it('should remove export named declaration without specifiers', async function() { + it('should remove export named declaration without specifiers', async function () { let b = await bundle( path.join( __dirname, @@ -667,7 +761,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 2); }); - it.skip('throws a meaningful error on undefined exports', async function() { + it.skip('throws a meaningful error on undefined exports', async function () { let threw = false; try { await bundle( @@ -688,7 +782,7 @@ describe('scope hoisting', function() { assert(threw); }); - it('supports importing named CommonJS (export individual)', async function() { + it('supports importing named CommonJS (export individual)', async function () { let b = await bundle( path.join( __dirname, @@ -705,7 +799,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'name:1.2.3'); }); - it('supports importing named CommonJS (export namespace)', async function() { + it('supports importing named CommonJS (export namespace)', async function () { let b = await bundle( path.join( __dirname, @@ -722,7 +816,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'name:1.2.3'); }); - it('supports default importing CommonJS (export namespace)', async function() { + it('supports default importing CommonJS (export namespace)', async function () { let b = await bundle( path.join( __dirname, @@ -747,7 +841,7 @@ describe('scope hoisting', function() { }); }); - it('supports import default CommonJS interop (export value)', async function() { + it('supports import default CommonJS interop (export value)', async function () { let b = await bundle( path.join( __dirname, @@ -762,7 +856,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foobar:foo:bar'); }); - it('supports import default CommonJS interop (individual exports)', async function() { + it('supports import default CommonJS interop (individual exports)', async function () { let b = await bundle( path.join( __dirname, @@ -793,7 +887,7 @@ describe('scope hoisting', function() { }); }); - it('falls back when importing missing symbols from CJS', async function() { + it('falls back when importing missing symbols from CJS', async function () { let b = await bundle( path.join( __dirname, @@ -805,7 +899,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, undefined); }); - it('does not export reassigned CommonJS exports references', async function() { + it('does not export reassigned CommonJS exports references', async function () { let b = await bundle( path.join( __dirname, @@ -818,7 +912,7 @@ describe('scope hoisting', function() { assert.equal(typeof bExports, 'object'); }); - it('supports import default CommonJS interop with dynamic imports', async function() { + it('supports import default CommonJS interop with dynamic imports', async function () { let b = await bundle( path.join( __dirname, @@ -829,7 +923,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), 6); }); - it('supports exporting an import', async function() { + it('supports exporting an import', async function () { let b = await bundle( path.join( __dirname, @@ -841,7 +935,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foobar'); }); - it('supports importing from a wrapped asset', async function() { + it('supports importing from a wrapped asset', async function () { let b = await bundle( path.join( __dirname, @@ -853,7 +947,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['a', true]); }); - it('supports importing from a wrapped asset with multiple bailouts', async function() { + it('supports importing from a wrapped asset with multiple bailouts', async function () { let b = await bundle( path.join( __dirname, @@ -865,7 +959,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['b', true]); }); - it("unused and missing pseudo re-exports doen't fail the build", async function() { + it("unused and missing pseudo re-exports doen't fail the build", async function () { let b = await bundle( path.join( __dirname, @@ -877,7 +971,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foo'); }); - it('supports requiring a re-exported and renamed ES6 import', async function() { + it('supports requiring a re-exported and renamed ES6 import', async function () { let b = await bundle( path.join( __dirname, @@ -889,7 +983,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foobar'); }); - it('supports requiring a re-exported and renamed ES6 namespace import', async function() { + it('supports requiring a re-exported and renamed ES6 namespace import', async function () { let b = await bundle( path.join( __dirname, @@ -906,7 +1000,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [123, 123]); }); - it('supports reexporting an asset from a shared bundle inside a shared bundle', async function() { + it('supports reexporting an asset from a shared bundle inside a shared bundle', async function () { let b = await bundle( path.join( __dirname, @@ -962,7 +1056,7 @@ describe('scope hoisting', function() { } }); - it('supports simultaneous import and re-export of a symbol', async function() { + it('supports simultaneous import and re-export of a symbol', async function () { let b = await bundle( path.join( __dirname, @@ -983,7 +1077,7 @@ describe('scope hoisting', function() { ); }); - it('supports importing a namespace from a commonjs module when code split', async function() { + it('supports importing a namespace from a commonjs module when code split', async function () { let b = await bundle( path.join( __dirname, @@ -994,7 +1088,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), 4); }); - it('supports resolving a static member access on a namespace', async function() { + it('supports resolving a static member access on a namespace', async function () { let b = await bundle( path.join( __dirname, @@ -1019,7 +1113,7 @@ describe('scope hoisting', function() { assert.deepEqual(calls, ['c1', 'c3']); }); - it('should bailout with a non-static member access on a namespace', async function() { + it('should bailout with a non-static member access on a namespace', async function () { let b = await bundle( path.join( __dirname, @@ -1044,7 +1138,7 @@ describe('scope hoisting', function() { assert.deepEqual(calls, ['c1', 'c2', 'c3']); }); - it('supports importing a namespace from a wrapped module', async function() { + it('supports importing a namespace from a wrapped module', async function () { let b = await bundle( path.join( __dirname, @@ -1062,7 +1156,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 1); }); - it('supports importing a namespace from a transpiled CommonJS module', async function() { + it('supports importing a namespace from a transpiled CommonJS module', async function () { let b = await bundle( path.join( __dirname, @@ -1077,7 +1171,7 @@ describe('scope hoisting', function() { }); }); - it('removes unused exports', async function() { + it('removes unused exports', async function () { let b = await bundle( path.join( __dirname, @@ -1097,7 +1191,7 @@ describe('scope hoisting', function() { assert(!contents.includes('bar')); }); - it('removes unused function exports when minified', async function() { + it('removes unused function exports when minified', async function () { let b = await bundle( path.join( __dirname, @@ -1121,7 +1215,7 @@ describe('scope hoisting', function() { assert(!/.-./.test(contents)); }); - it('removes unused transpiled classes using terser when minified', async function() { + it('removes unused transpiled classes using terser when minified', async function () { let b = await bundle( path.join( __dirname, @@ -1236,8 +1330,8 @@ describe('scope hoisting', function() { }); }); - describe('tree shaking dynamic imports', function() { - it.skip('supports tree shaking statically analyzable dynamic import: destructued await assignment', async function() { + describe('tree shaking dynamic imports', function () { + it.skip('supports tree shaking statically analyzable dynamic import: destructued await assignment', async function () { let b = await bundle( path.join( __dirname, @@ -1268,7 +1362,7 @@ describe('scope hoisting', function() { assert(!contents.includes('stuff')); }); - it('supports tree shaking statically analyzable dynamic import: destructured await declaration', async function() { + it('supports tree shaking statically analyzable dynamic import: destructured await declaration', async function () { let b = await bundle( path.join( __dirname, @@ -1300,7 +1394,7 @@ describe('scope hoisting', function() { assert(!contents.includes('stuff')); }); - it('supports tree shaking statically analyzable dynamic import: namespace await declaration', async function() { + it('supports tree shaking statically analyzable dynamic import: namespace await declaration', async function () { let b = await bundle( path.join( __dirname, @@ -1332,7 +1426,7 @@ describe('scope hoisting', function() { assert(!contents.includes('stuff')); }); - it('supports tree shaking statically analyzable dynamic import: namespace await declaration bailout', async function() { + it('supports tree shaking statically analyzable dynamic import: namespace await declaration bailout', async function () { let b = await bundle( path.join( __dirname, @@ -1363,7 +1457,7 @@ describe('scope hoisting', function() { ); }); - it('supports tree shaking statically analyzable dynamic import: namespace await declaration eval bailout', async function() { + it('supports tree shaking statically analyzable dynamic import: namespace await declaration eval bailout', async function () { let b = await bundle( path.join( __dirname, @@ -1388,7 +1482,7 @@ describe('scope hoisting', function() { ); }); - it('supports tree shaking statically analyzable dynamic import: destructured then', async function() { + it('supports tree shaking statically analyzable dynamic import: destructured then', async function () { let b = await bundle( path.join( __dirname, @@ -1416,7 +1510,7 @@ describe('scope hoisting', function() { assert(!contents.includes('stuff')); }); - it('supports tree shaking statically analyzable dynamic import: namespace then', async function() { + it('supports tree shaking statically analyzable dynamic import: namespace then', async function () { let b = await bundle( path.join( __dirname, @@ -1448,7 +1542,7 @@ describe('scope hoisting', function() { assert(!contents.includes('stuff')); }); - it('supports tree shaking statically analyzable dynamic import: namespace then bailout', async function() { + it('supports tree shaking statically analyzable dynamic import: namespace then bailout', async function () { let b = await bundle( path.join( __dirname, @@ -1475,7 +1569,7 @@ describe('scope hoisting', function() { ); }); - it('supports tree shaking statically analyzable dynamic import: esmodule output', async function() { + it('supports tree shaking statically analyzable dynamic import: esmodule output', async function () { let b = await bundle( path.join( __dirname, @@ -1511,7 +1605,7 @@ describe('scope hoisting', function() { assert(!contents.includes('stuff')); }); - it.skip('throws an error for missing exports for dynamic import: destructured await assignment', async function() { + it.skip('throws an error for missing exports for dynamic import: destructured await assignment', async function () { let source = 'await-assignment-error.js'; let message = `async.js does not export 'missing'`; await assert.rejects( @@ -1554,7 +1648,7 @@ describe('scope hoisting', function() { ); }); - it('throws an error for missing exports for dynamic import: destructured await declaration', async function() { + it('throws an error for missing exports for dynamic import: destructured await declaration', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/tree-shaking-dynamic-import', @@ -1601,7 +1695,7 @@ describe('scope hoisting', function() { ); }); - it('throws an error for missing exports for dynamic import: namespace await declaration', async function() { + it('throws an error for missing exports for dynamic import: namespace await declaration', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/tree-shaking-dynamic-import', @@ -1648,7 +1742,7 @@ describe('scope hoisting', function() { ); }); - it('throws an error for missing exports for dynamic import: destructured then', async function() { + it('throws an error for missing exports for dynamic import: destructured then', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/tree-shaking-dynamic-import', @@ -1695,7 +1789,7 @@ describe('scope hoisting', function() { ); }); - it('throws an error for missing exports for dynamic import: namespace then', async function() { + it('throws an error for missing exports for dynamic import: namespace then', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/tree-shaking-dynamic-import', @@ -1743,7 +1837,7 @@ describe('scope hoisting', function() { }); }); - it('keeps member expression with computed properties that are variables', async function() { + it('keeps member expression with computed properties that are variables', async function () { let b = await bundle( path.join( __dirname, @@ -1763,7 +1857,7 @@ describe('scope hoisting', function() { assert.strictEqual(typeof output[3], 'undefined'); }); - it('support exporting a ES6 module exported as CommonJS', async function() { + it('support exporting a ES6 module exported as CommonJS', async function () { let b = await bundle( path.join( __dirname, @@ -1775,7 +1869,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foo'); }); - it('concatenates in the correct order when re-exporting assets were excluded', async function() { + it('concatenates in the correct order when re-exporting assets were excluded', async function () { let b = await bundle( path.join( __dirname, @@ -1802,7 +1896,7 @@ describe('scope hoisting', function() { assert(new output[3]() instanceof output[2]); }); - it('support chained namespace reexports of CommonJS', async function() { + it('support chained namespace reexports of CommonJS', async function () { let b = await bundle( path.join( __dirname, @@ -1814,7 +1908,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foo'); }); - it('should support assets importing themselves', async function() { + it('should support assets importing themselves', async function () { let b = await bundle( path.join( __dirname, @@ -1826,7 +1920,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 4); }); - it('should support named imports on wrapped modules', async function() { + it('should support named imports on wrapped modules', async function () { let b = await bundle( path.join( __dirname, @@ -1838,7 +1932,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'bar'); }); - it('should support unused imports of wrapped modules in different bundles', async function() { + it('should support unused imports of wrapped modules in different bundles', async function () { let b = await bundle( path.join( __dirname, @@ -1855,7 +1949,7 @@ describe('scope hoisting', function() { assert(called); }); - it('should insert esModule flag for interop for async (or shared) bundles', async function() { + it('should insert esModule flag for interop for async (or shared) bundles', async function () { let b = await bundle( path.join( __dirname, @@ -1873,7 +1967,7 @@ describe('scope hoisting', function() { assert.deepEqual(await res.output, ['client', 'client', 'viewer']); }); - it('should enable minifier to remove unused modules despite of interopDefault', async function() { + it('should enable minifier to remove unused modules despite of interopDefault', async function () { let b = await bundle( path.join( __dirname, @@ -1895,7 +1989,7 @@ describe('scope hoisting', function() { assert.strictEqual(contents.trim().length, 0); }); - it('should support the jsx pragma', async function() { + it('should support the jsx pragma', async function () { let b = await bundle( path.join(__dirname, '/integration/scope-hoisting/es6/jsx-pragma/a.js'), ); @@ -1908,7 +2002,7 @@ describe('scope hoisting', function() { }); }); - it('should not nameclash with internal variables', async function() { + it('should not nameclash with internal variables', async function () { let b = await bundle( path.join(__dirname, '/integration/scope-hoisting/es6/name-clash/a.js'), ); @@ -1917,7 +2011,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'bar'); }); - it('should shake pure property assignments', async function() { + it('should shake pure property assignments', async function () { let b = await bundle( path.join( __dirname, @@ -1935,7 +2029,7 @@ describe('scope hoisting', function() { assert(!contents.includes('exports.bar =')); }); - it('should correctly rename references to default exported classes', async function() { + it('should correctly rename references to default exported classes', async function () { let b = await bundle( path.join( __dirname, @@ -1947,7 +2041,7 @@ describe('scope hoisting', function() { assert.deepEqual(output.foo, 'bar'); }); - it('should correctly rename references to a class in the class body', async function() { + it('should correctly rename references to a class in the class body', async function () { let b = await bundle( path.join( __dirname, @@ -1958,7 +2052,7 @@ describe('scope hoisting', function() { assert.deepEqual(output.foo, 'bar'); }); - it('should correctly handle circular dependencies', async function() { + it('should correctly handle circular dependencies', async function () { let b = await bundle( path.join(__dirname, '/integration/scope-hoisting/es6/circular/a.mjs'), ); @@ -1984,7 +2078,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 'c:foo'); }); - it('should correctly handle circular dependencies (2)', async function() { + it('should correctly handle circular dependencies (2)', async function () { let b = await bundle( path.join(__dirname, '/integration/scope-hoisting/es6/circular2/a.mjs'), ); @@ -2011,7 +2105,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 'b:foo:foo'); }); - it('should correctly handle circular dependencies (3)', async function() { + it('should correctly handle circular dependencies (3)', async function () { let b = await bundle( path.join(__dirname, '/integration/scope-hoisting/es6/circular3/a.mjs'), ); @@ -2078,7 +2172,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 42); }); - it('can conditionally reference an imported symbol and unconditionally reference it', async function() { + it('can conditionally reference an imported symbol and unconditionally reference it', async function () { let b = await bundle( path.join( __dirname, @@ -2103,7 +2197,7 @@ describe('scope hoisting', function() { }); describe('correctly updates used symbols on changes', () => { - it('dependency symbols change', async function() { + it('dependency symbols change', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/update-used-symbols-dependency-symbols', @@ -2169,7 +2263,7 @@ describe('scope hoisting', function() { } }); - it('add and remove dependency', async function() { + it('add and remove dependency', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/update-used-symbols-dependency-add', @@ -2250,7 +2344,7 @@ describe('scope hoisting', function() { } }); - it('add and remove dependency with inline asset', async function() { + it('add and remove dependency with inline asset', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/update-used-symbols-dependency-add-inline', @@ -2324,7 +2418,7 @@ describe('scope hoisting', function() { } }); - it('add and remove dependency with namespace', async function() { + it('add and remove dependency with namespace', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/update-used-symbols-dependency-add-namespace', @@ -2453,8 +2547,8 @@ describe('scope hoisting', function() { }); }); - describe('sideEffects: false', function() { - it('supports excluding unused CSS imports', async function() { + describe('sideEffects: false', function () { + it('supports excluding unused CSS imports', async function () { let b = await bundle( path.join( __dirname, @@ -2498,7 +2592,7 @@ describe('scope hoisting', function() { assert(!css.includes('.b2')); }); - it("doesn't create new bundles for dynamic imports in excluded assets", async function() { + it("doesn't create new bundles for dynamic imports in excluded assets", async function () { let b = await bundle( path.join( __dirname, @@ -2532,7 +2626,7 @@ describe('scope hoisting', function() { assert.deepEqual(res.output, 2); }); - it('supports deferring an unused ES6 re-exports (namespace used)', async function() { + it('supports deferring an unused ES6 re-exports (namespace used)', async function () { let b = await bundle( path.join( __dirname, @@ -2554,7 +2648,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'Message 1'); }); - it('supports deferring an unused ES6 re-export (wildcard, empty, unused)', async function() { + it('supports deferring an unused ES6 re-export (wildcard, empty, unused)', async function () { let b = await bundle( path.join( __dirname, @@ -2567,7 +2661,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), 123); }); - it('supports deferring an unused ES6 re-exports (reexport named used)', async function() { + it('supports deferring an unused ES6 re-exports (reexport named used)', async function () { let b = await bundle( path.join( __dirname, @@ -2589,7 +2683,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'Message 2'); }); - it('supports deferring an unused ES6 re-exports (namespace rename used)', async function() { + it('supports deferring an unused ES6 re-exports (namespace rename used)', async function () { let b = await bundle( path.join( __dirname, @@ -2611,7 +2705,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {default: 'Message 3'}); }); - it('supports deferring an unused ES6 re-exports (direct export used)', async function() { + it('supports deferring an unused ES6 re-exports (direct export used)', async function () { let b = await bundle( path.join( __dirname, @@ -2634,7 +2728,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'Message 4'); }); - it('supports chained ES6 re-exports', async function() { + it('supports chained ES6 re-exports', async function () { let b = await bundle( path.join( __dirname, @@ -2655,7 +2749,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['key', 'foo']); }); - it('should not optimize away an unused ES6 re-export and an used import', async function() { + it('should not optimize away an unused ES6 re-export and an used import', async function () { let b = await bundle( path.join( __dirname, @@ -2667,7 +2761,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 123); }); - it('should not optimize away an unused ES6 re-export and an used import (different symbols)', async function() { + it('should not optimize away an unused ES6 re-export and an used import (different symbols)', async function () { let b = await bundle( path.join( __dirname, @@ -2679,7 +2773,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 123); }); - it('correctly handles ES6 re-exports in library mode entries', async function() { + it('correctly handles ES6 re-exports in library mode entries', async function () { let b = await bundle( path.join( __dirname, @@ -2700,7 +2794,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {c1: 'foo'}); }); - it('correctly updates deferred assets that are reexported', async function() { + it('correctly updates deferred assets that are reexported', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/side-effects-update-deferred-reexported', @@ -2732,7 +2826,7 @@ describe('scope hoisting', function() { await subscription.unsubscribe(); }); - it('correctly updates deferred assets that are reexported and imported directly', async function() { + it('correctly updates deferred assets that are reexported and imported directly', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/side-effects-update-deferred-direct', @@ -2764,7 +2858,7 @@ describe('scope hoisting', function() { await subscription.unsubscribe(); }); - it('removes deferred reexports when imported from multiple asssets', async function() { + it('removes deferred reexports when imported from multiple asssets', async function () { let b = await bundle( path.join( __dirname, @@ -2785,7 +2879,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [1234, {default: 1234}]); }); - it('keeps side effects by default', async function() { + it('keeps side effects by default', async function () { let b = await bundle( path.join( __dirname, @@ -2804,7 +2898,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 4); }); - it('supports the package.json sideEffects: false flag', async function() { + it('supports the package.json sideEffects: false flag', async function () { let b = await bundle( path.join( __dirname, @@ -2823,7 +2917,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 4); }); - it('supports removing a deferred dependency', async function() { + it('supports removing a deferred dependency', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/side-effects-false', @@ -2874,7 +2968,7 @@ describe('scope hoisting', function() { } }); - it('supports wildcards', async function() { + it('supports wildcards', async function () { let b = await bundle( path.join( __dirname, @@ -2892,7 +2986,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'bar'); }); - it('correctly handles excluded and wrapped reexport assets', async function() { + it('correctly handles excluded and wrapped reexport assets', async function () { let b = await bundle( path.join( __dirname, @@ -2904,7 +2998,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 4); }); - it('supports the package.json sideEffects flag with an array', async function() { + it('supports the package.json sideEffects flag with an array', async function () { let b = await bundle( path.join( __dirname, @@ -2923,7 +3017,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 4); }); - it('supports the package.json sideEffects: false flag with shared dependencies', async function() { + it('supports the package.json sideEffects: false flag with shared dependencies', async function () { let b = await bundle( path.join( __dirname, @@ -2942,7 +3036,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 6); }); - it('supports the package.json sideEffects: false flag with shared dependencies and code splitting', async function() { + it('supports the package.json sideEffects: false flag with shared dependencies and code splitting', async function () { let b = await bundle( path.join( __dirname, @@ -2953,7 +3047,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), 581); }); - it('supports the package.json sideEffects: false flag with shared dependencies and code splitting II', async function() { + it('supports the package.json sideEffects: false flag with shared dependencies and code splitting II', async function () { let b = await bundle( path.join( __dirname, @@ -2964,7 +3058,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), [{default: 123, foo: 2}, 581]); }); - it('missing exports should be replaced with an empty object', async function() { + it('missing exports should be replaced with an empty object', async function () { let b = await bundle( path.join( __dirname, @@ -2976,7 +3070,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {b: {}}); }); - it('supports namespace imports of theoretically excluded reexporting assets', async function() { + it('supports namespace imports of theoretically excluded reexporting assets', async function () { let b = await bundle( path.join( __dirname, @@ -2988,7 +3082,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {Main: 'main', a: 'foo', b: 'bar'}); }); - it('can import from a different bundle via a re-export', async function() { + it('can import from a different bundle via a re-export', async function () { let b = await bundle( path.join( __dirname, @@ -2999,7 +3093,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['operational', 'ui']); }); - it('supports excluding multiple chained namespace reexports', async function() { + it('supports excluding multiple chained namespace reexports', async function () { let b = await bundle( path.join( __dirname, @@ -3020,7 +3114,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'Message 1'); }); - it('supports excluding when doing both exports and reexports', async function() { + it('supports excluding when doing both exports and reexports', async function () { let b = await bundle( path.join( __dirname, @@ -3041,7 +3135,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'Message 1'); }); - it('supports deferring with chained renaming reexports', async function() { + it('supports deferring with chained renaming reexports', async function () { let b = await bundle( path.join( __dirname, @@ -3062,7 +3156,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'Message 1'); }); - it('supports named and renamed reexports of the same asset (default used)', async function() { + it('supports named and renamed reexports of the same asset (default used)', async function () { let b = await bundle( path.join( __dirname, @@ -3086,7 +3180,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'bar'); }); - it('supports named and renamed reexports of the same asset (named used)', async function() { + it('supports named and renamed reexports of the same asset (named used)', async function () { let b = await bundle( path.join( __dirname, @@ -3110,7 +3204,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'bar'); }); - it('removes functions that increment variables in object properties', async function() { + it('removes functions that increment variables in object properties', async function () { let b = await bundle( path.join( __dirname, @@ -3132,7 +3226,7 @@ describe('scope hoisting', function() { await run(b); }); - it('supports named and namespace exports of the same asset (named used)', async function() { + it('supports named and namespace exports of the same asset (named used)', async function () { let b = await bundle( path.join( __dirname, @@ -3160,7 +3254,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['foo']); }); - it('supports named and namespace exports of the same asset (namespace used)', async function() { + it('supports named and namespace exports of the same asset (namespace used)', async function () { let b = await bundle( path.join( __dirname, @@ -3188,7 +3282,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['bar']); }); - it('supports named and namespace exports of the same asset (both used)', async function() { + it('supports named and namespace exports of the same asset (both used)', async function () { let b = await bundle( path.join( __dirname, @@ -3216,7 +3310,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, ['foo', 'bar']); }); - it('supports deferring non-weak dependencies that are not used', async function() { + it('supports deferring non-weak dependencies that are not used', async function () { let b = await bundle( path.join( __dirname, @@ -3237,7 +3331,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'Message 1'); }); - it('supports excluding CommonJS (CommonJS unused)', async function() { + it('supports excluding CommonJS (CommonJS unused)', async function () { let b = await bundle( path.join( __dirname, @@ -3269,11 +3363,11 @@ describe('scope hoisting', function() { }, }); - assert.deepEqual(calls, ['esm', 'commonjs']); + assert.deepEqual(calls, ['esm', 'commonjs', 'index']); assert.deepEqual(output, 'Message 1'); }); - it('supports excluding CommonJS (CommonJS used)', async function() { + it('supports excluding CommonJS (CommonJS used)', async function () { let b = await bundle( path.join( __dirname, @@ -3306,7 +3400,7 @@ describe('scope hoisting', function() { }); }); - it('ignores missing import specifiers in source assets', async function() { + it('ignores missing import specifiers in source assets', async function () { let b = await bundle( path.join( __dirname, @@ -3317,7 +3411,7 @@ describe('scope hoisting', function() { assert.equal(output, 123); }); - it('ignores unused import specifiers in node-modules', async function() { + it('ignores unused import specifiers in node-modules', async function () { let b = await bundle( path.join( __dirname, @@ -3377,7 +3471,7 @@ describe('scope hoisting', function() { assert(/foo\.[a-f0-9]+\.png$/.test(output)); }); - it('should wrap modules in shared bundles', async function() { + it('should wrap modules in shared bundles', async function () { // https://github.com/parcel-bundler/parcel/issues/5659 let b = await bundle( path.join( @@ -3397,7 +3491,7 @@ describe('scope hoisting', function() { assert.deepEqual(sideEffects, ['shared1', 'run1 1', 'shared2', 'run2 2']); }); - it('should ensure that modules are only executed once in shared bundles', async function() { + it('should ensure that modules are only executed once in shared bundles', async function () { // https://github.com/parcel-bundler/parcel/issues/5659 let b = await bundle( path.join( @@ -3417,7 +3511,7 @@ describe('scope hoisting', function() { assert.deepEqual(sideEffects, ['v']); }); - it('should error when assigning to a named import', async function() { + it('should error when assigning to a named import', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/import-local-assign/named.js', @@ -3465,7 +3559,7 @@ describe('scope hoisting', function() { }); }); - it('should error when assigning to a default import', async function() { + it('should error when assigning to a default import', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/import-local-assign/default.js', @@ -3513,7 +3607,7 @@ describe('scope hoisting', function() { }); }); - it('should error when assigning to a namespace import', async function() { + it('should error when assigning to a namespace import', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/import-local-assign/namespace.js', @@ -3561,7 +3655,7 @@ describe('scope hoisting', function() { }); }); - it('should error with a destructuring assignment to a namespace import', async function() { + it('should error with a destructuring assignment to a namespace import', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/import-local-assign/destructure-assign.js', @@ -3609,7 +3703,7 @@ describe('scope hoisting', function() { }); }); - it('should error with multiple assignments to an import', async function() { + it('should error with multiple assignments to an import', async function () { let source = path.join( __dirname, 'integration/scope-hoisting/es6/import-local-assign/multiple.js', @@ -3668,7 +3762,7 @@ describe('scope hoisting', function() { }); }); - it('should allow re-declaring __esModule interop flag', async function() { + it('should allow re-declaring __esModule interop flag', async function () { let b = await bundle( path.join( __dirname, @@ -3736,10 +3830,72 @@ describe('scope hoisting', function() { assert.equal(await run(b), undefined); }); + + it('should handle interop with a re-export namespace', async () => { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-interop/a.js', + ), + ); + + let res = await run(b); + assert.deepEqual(res['en_US'], { + test: 'foo', + }); + }); + + it('should prioritize named exports before re-exports (before)', async () => { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-priority/entry-a.mjs', + ), + ); + + let res = await run(b); + assert.equal(res, 2); + }); + + it('should prioritize named exports before re-exports (after)', async () => { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-priority/entry-b.mjs', + ), + ); + + let res = await run(b); + assert.equal(res, 2); + }); + + it('should prioritize named exports before re-exports in namespace (before)', async () => { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-priority/namespace-a.mjs', + ), + ); + + let res = await run(b); + assert.deepEqual(res, {foo: 2}); + }); + + it('should prioritize named exports before re-exports in namespace (after)', async () => { + let b = await bundle( + path.join( + __dirname, + 'integration/scope-hoisting/es6/re-export-priority/namespace-b.mjs', + ), + ); + + let res = await run(b); + assert.deepEqual(res, {foo: 2}); + }); }); - describe('commonjs', function() { - it('supports require of commonjs modules', async function() { + describe('commonjs', function () { + it('supports require of commonjs modules', async function () { let b = await bundle( path.join( __dirname, @@ -3751,7 +3907,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('concats commonjs modules in the correct order', async function() { + it('concats commonjs modules in the correct order', async function () { let b = await bundle( path.join( __dirname, @@ -3763,7 +3919,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports default imports of commonjs modules', async function() { + it('supports default imports of commonjs modules', async function () { let b = await bundle( path.join( __dirname, @@ -3775,7 +3931,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('concats modules with inserted globals in the correct order', async function() { + it('concats modules with inserted globals in the correct order', async function () { let b = await bundle( path.join( __dirname, @@ -3787,7 +3943,7 @@ describe('scope hoisting', function() { assert.equal(output, 'foobar'); }); - it('supports named imports of commonjs modules', async function() { + it('supports named imports of commonjs modules', async function () { let b = await bundle( path.join( __dirname, @@ -3799,7 +3955,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports namespace imports of commonjs modules', async function() { + it('supports namespace imports of commonjs modules', async function () { let b = await bundle( path.join( __dirname, @@ -3811,7 +3967,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports require of es6 default export of expressions', async function() { + it('supports require of es6 default export of expressions', async function () { let b = await bundle( path.join( __dirname, @@ -3823,7 +3979,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports require of es6 default export of declarations', async function() { + it('supports require of es6 default export of declarations', async function () { let b = await bundle( path.join( __dirname, @@ -3835,7 +3991,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports require of es6 default export of variables', async function() { + it('supports require of es6 default export of variables', async function () { let b = await bundle( path.join( __dirname, @@ -3847,7 +4003,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports require of es6 named export of declarations', async function() { + it('supports require of es6 named export of declarations', async function () { let b = await bundle( path.join( __dirname, @@ -3859,7 +4015,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports require of es6 named export of variables', async function() { + it('supports require of es6 named export of variables', async function () { let b = await bundle( path.join( __dirname, @@ -3871,7 +4027,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports require of es6 renamed exports', async function() { + it('supports require of es6 renamed exports', async function () { let b = await bundle( path.join( __dirname, @@ -3883,7 +4039,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('supports require of es6 module re-exporting all exports from another module', async function() { + it('supports require of es6 module re-exporting all exports from another module', async function () { let b = await bundle( path.join( __dirname, @@ -3895,7 +4051,7 @@ describe('scope hoisting', function() { assert.equal(output, 6); }); - it('supports require of es6 module re-exporting all exports from multiple modules', async function() { + it('supports require of es6 module re-exporting all exports from multiple modules', async function () { let b = await bundle( path.join( __dirname, @@ -3907,7 +4063,7 @@ describe('scope hoisting', function() { assert.equal(output, 7); }); - it('supports re-exporting individual named exports from another module', async function() { + it('supports re-exporting individual named exports from another module', async function () { let b = await bundle( path.join( __dirname, @@ -3919,7 +4075,7 @@ describe('scope hoisting', function() { assert.equal(output, 3); }); - it('supports re-exporting default exports from another module', async function() { + it('supports re-exporting default exports from another module', async function () { let b = await bundle( path.join( __dirname, @@ -3931,7 +4087,7 @@ describe('scope hoisting', function() { assert.equal(output, 3); }); - it('supports re-exporting a namespace from another module', async function() { + it('supports re-exporting a namespace from another module', async function () { let b = await bundle( path.join( __dirname, @@ -3943,7 +4099,7 @@ describe('scope hoisting', function() { assert.equal(output, 6); }); - it('excludes default when re-exporting a module', async function() { + it('excludes default when re-exporting a module', async function () { let b = await bundle( path.join( __dirname, @@ -3955,7 +4111,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {foo: 3}); }); - it('supports hybrid ES6 + commonjs modules', async function() { + it('supports hybrid ES6 + commonjs modules', async function () { let b = await bundle( path.join( __dirname, @@ -3967,7 +4123,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('inserts commonjs exports object in the right place', async function() { + it('inserts commonjs exports object in the right place', async function () { let b = await bundle( path.join( __dirname, @@ -3979,7 +4135,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out exports access resolving if it is accessed freely (exports assign)', async function() { + it('bails out exports access resolving if it is accessed freely (exports assign)', async function () { let b = await bundle( path.join( __dirname, @@ -3991,7 +4147,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out exports access resolving if it is accessed freely (exports define)', async function() { + it('bails out exports access resolving if it is accessed freely (exports define)', async function () { let b = await bundle( path.join( __dirname, @@ -4003,7 +4159,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out exports access resolving if it is accessed freely (module.exports assign)', async function() { + it('bails out exports access resolving if it is accessed freely (module.exports assign)', async function () { let b = await bundle( path.join( __dirname, @@ -4015,7 +4171,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out exports access resolving if it is accessed freely (module.exports define)', async function() { + it('bails out exports access resolving if it is accessed freely (module.exports define)', async function () { let b = await bundle( path.join( __dirname, @@ -4027,7 +4183,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out imported exports access resolving if it is accessed freely (exports assign)', async function() { + it('bails out imported exports access resolving if it is accessed freely (exports assign)', async function () { let b = await bundle( path.join( __dirname, @@ -4039,7 +4195,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out imported exports access resolving if it is accessed freely (exports define)', async function() { + it('bails out imported exports access resolving if it is accessed freely (exports define)', async function () { let b = await bundle( path.join( __dirname, @@ -4051,7 +4207,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out imported exports access resolving if it is accessed freely (module.exports assign)', async function() { + it('bails out imported exports access resolving if it is accessed freely (module.exports assign)', async function () { let b = await bundle( path.join( __dirname, @@ -4063,7 +4219,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out imported exports access resolving if it is accessed freely (module.exports define)', async function() { + it('bails out imported exports access resolving if it is accessed freely (module.exports define)', async function () { let b = await bundle( path.join( __dirname, @@ -4075,7 +4231,7 @@ describe('scope hoisting', function() { assert.equal(output, 5); }); - it('bails out imported exports access resolving if it is accessed freely (exports reexport)', async function() { + it('bails out imported exports access resolving if it is accessed freely (exports reexport)', async function () { let b = await bundle( path.join( __dirname, @@ -4087,7 +4243,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [5, 5]); }); - it('builds commonjs modules that assigns to exports before module.exports', async function() { + it('builds commonjs modules that assigns to exports before module.exports', async function () { let b = await bundle( path.join( __dirname, @@ -4099,7 +4255,7 @@ describe('scope hoisting', function() { assert.equal(output, 42); }); - it('builds commonjs modules that assigns to module.exports before exports', async function() { + it('builds commonjs modules that assigns to module.exports before exports', async function () { let b = await bundle( path.join( __dirname, @@ -4111,7 +4267,7 @@ describe('scope hoisting', function() { assert.equal(output, 42); }); - it('should support assigning to module.exports with another export', async function() { + it('should support assigning to module.exports with another export', async function () { // https://github.com/parcel-bundler/parcel/issues/5782 let b = await bundle( path.join( @@ -4124,7 +4280,7 @@ describe('scope hoisting', function() { assert.equal(output.foo, 'b'); }); - it("doesn't insert parcelRequire for missing non-js assets", async function() { + it("doesn't insert parcelRequire for missing non-js assets", async function () { let b = await bundle( path.join( __dirname, @@ -4136,7 +4292,7 @@ describe('scope hoisting', function() { assert.equal(output, 27); }); - it('define exports in the outermost scope', async function() { + it('define exports in the outermost scope', async function () { let b = await bundle( path.join( __dirname, @@ -4153,7 +4309,7 @@ describe('scope hoisting', function() { assert.equal(output, 'bar'); }); - it('supports live bindings of named exports', async function() { + it('supports live bindings of named exports', async function () { let b = await bundle( path.join( __dirname, @@ -4165,7 +4321,7 @@ describe('scope hoisting', function() { assert.equal(output, 8); }); - it('should wrap modules that use eval in a function', async function() { + it('should wrap modules that use eval in a function', async function () { let b = await bundle( path.join( __dirname, @@ -4177,7 +4333,7 @@ describe('scope hoisting', function() { assert.equal(output, 4); }); - it('should wrap modules that have a top-level return', async function() { + it('should wrap modules that have a top-level return', async function () { let b = await bundle( path.join( __dirname, @@ -4189,7 +4345,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('should remove unused exports assignments for wrapped modules', async function() { + it('should remove unused exports assignments for wrapped modules', async function () { let b = await bundle( path.join( __dirname, @@ -4203,7 +4359,7 @@ describe('scope hoisting', function() { assert.equal(output, 1); }); - it('should hoist all vars in the scope', async function() { + it('should hoist all vars in the scope', async function () { let b = await bundle( path.join( __dirname, @@ -4229,7 +4385,7 @@ describe('scope hoisting', function() { assert.equal(output, true); }); - it('should wrap modules that access `module` as a free variable', async function() { + it('should wrap modules that access `module` as a free variable', async function () { let b = await bundle( path.join( __dirname, @@ -4240,7 +4396,7 @@ describe('scope hoisting', function() { assert.deepEqual((await run(b)).exports, {foo: 2}); }); - it('should call init for wrapped modules when codesplitting', async function() { + it('should call init for wrapped modules when codesplitting', async function () { let b = await bundle( path.join( __dirname, @@ -4251,7 +4407,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), 2); }); - it('should wrap modules that non-statically access `module`', async function() { + it('should wrap modules that non-statically access `module`', async function () { let b = await bundle( path.join( __dirname, @@ -4263,7 +4419,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {foo: 2}); }); - it('should support typeof require when wrapped', async function() { + it('should support typeof require when wrapped', async function () { // https://github.com/parcel-bundler/parcel/issues/5883 let b = await bundle( path.join( @@ -4276,7 +4432,7 @@ describe('scope hoisting', function() { assert.equal(output, 'c1'); }); - it('should not rename function local variables according to global replacements', async function() { + it('should not rename function local variables according to global replacements', async function () { let b = await bundle( path.join( __dirname, @@ -4288,7 +4444,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foo'); }); - it('supports using this in arrow functions', async function() { + it('supports using this in arrow functions', async function () { let b = await bundle( path.join( __dirname, @@ -4303,7 +4459,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 'Say other'); }); - it('supports assigning to this as exports object', async function() { + it('supports assigning to this as exports object', async function () { let b = await bundle( path.join( __dirname, @@ -4315,7 +4471,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 2); }); - it('supports assigning to this as exports object in wrapped module', async function() { + it('supports assigning to this as exports object in wrapped module', async function () { let b = await bundle( path.join( __dirname, @@ -4327,7 +4483,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 6); }); - it('supports using exports self reference', async function() { + it('supports using exports self reference', async function () { let b = await bundle( path.join( __dirname, @@ -4342,7 +4498,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 'Say other'); }); - it('supports using module.exports self reference', async function() { + it('supports using module.exports self reference', async function () { let b = await bundle( path.join( __dirname, @@ -4357,7 +4513,19 @@ describe('scope hoisting', function() { assert.strictEqual(output, 'Say other'); }); - it('support url imports in wrapped modules with interop', async function() { + it('supports using module.require like require', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/commonjs/module-require/a.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output.b, 2); + }); + + it('support url imports in wrapped modules with interop', async function () { let b = await bundle( path.join( __dirname, @@ -4380,7 +4548,7 @@ describe('scope hoisting', function() { assert(output.endsWith('.txt')); }); - it('supports module object properties', async function() { + it('supports module object properties', async function () { let b = await bundle( path.join( __dirname, @@ -4402,7 +4570,7 @@ describe('scope hoisting', function() { assert.equal(output.require, 'function'); }); - it.skip("doesn't support require.resolve calls for included assets", async function() { + it.skip("doesn't support require.resolve calls for included assets", async function () { let message = "'require.resolve' calls for bundled modules or bundled assets aren't supported with scope hoisting"; let source = path.join( @@ -4439,7 +4607,7 @@ describe('scope hoisting', function() { }); }); - it('supports mutations of the exports object by the importer', async function() { + it('supports mutations of the exports object by the importer', async function () { let b = await bundle( path.join( __dirname, @@ -4450,7 +4618,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), [43, {foo: 43}]); }); - it('supports mutations of the exports object by a different asset', async function() { + it('supports mutations of the exports object by a different asset', async function () { let b = await bundle( path.join( __dirname, @@ -4461,7 +4629,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 43); }); - it('supports mutations of the exports object inside an expression', async function() { + it('supports mutations of the exports object inside an expression', async function () { let b = await bundle( path.join( __dirname, @@ -4472,7 +4640,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), [{foo: 3}, 3, 3]); }); - it('supports non-static mutations of the exports object', async function() { + it('supports non-static mutations of the exports object', async function () { // https://github.com/parcel-bundler/parcel/issues/5591 let b = await bundle( path.join( @@ -4484,7 +4652,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), 4); }); - it.skip('supports require.resolve calls for excluded modules', async function() { + it.skip('supports require.resolve calls for excluded modules', async function () { let b = await bundle( path.join( __dirname, @@ -4500,7 +4668,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'my-resolved-fs'); }); - it('should support assets requiring themselves', async function() { + it('should support assets requiring themselves', async function () { let b = await bundle( path.join( __dirname, @@ -4512,7 +4680,7 @@ describe('scope hoisting', function() { assert.strictEqual(output, 4); }); - it('supports requiring a re-exported ES6 import', async function() { + it('supports requiring a re-exported ES6 import', async function () { let b = await bundle( path.join( __dirname, @@ -4524,7 +4692,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 'foobar'); }); - it('supports object pattern requires', async function() { + it('supports object pattern requires', async function () { let b = await bundle( path.join( __dirname, @@ -4536,7 +4704,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 5); }); - it('eliminates CommonJS export object where possible', async function() { + it('eliminates CommonJS export object where possible', async function () { let b = await bundle( path.join( __dirname, @@ -4548,7 +4716,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 6); }); - it('supports multiple assignments in one line', async function() { + it('supports multiple assignments in one line', async function () { let b = await bundle( path.join( __dirname, @@ -4560,7 +4728,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {foo: 2, bar: 2, baz: 2}); }); - it('supports circular dependencies', async function() { + it('supports circular dependencies', async function () { let b = await bundle( path.join( __dirname, @@ -4572,7 +4740,7 @@ describe('scope hoisting', function() { assert.equal(output, 'foo bar'); }); - it('executes modules in the correct order', async function() { + it('executes modules in the correct order', async function () { let b = await bundle( path.join( __dirname, @@ -4590,7 +4758,7 @@ describe('scope hoisting', function() { assert.deepEqual(out, ['a', 'b', 'c', 'd']); }); - it('supports conditional requires', async function() { + it('supports conditional requires', async function () { let b = await bundle( path.join( __dirname, @@ -4619,7 +4787,7 @@ describe('scope hoisting', function() { assert.deepEqual(out, ['a', 'b', 'c', 'd']); }); - it('supports requiring a CSS asset', async function() { + it('supports requiring a CSS asset', async function () { let b = await bundle( path.join( __dirname, @@ -4641,7 +4809,7 @@ describe('scope hoisting', function() { await run(b); }); - it('supports requires inside functions', async function() { + it('supports requires inside functions', async function () { let b = await bundle( path.join( __dirname, @@ -4659,7 +4827,7 @@ describe('scope hoisting', function() { assert.deepEqual(out, ['a', 'c', 'b']); }); - it('supports requires inside functions with es6 import side effects', async function() { + it('supports requires inside functions with es6 import side effects', async function () { let b = await bundle( path.join( __dirname, @@ -4677,7 +4845,7 @@ describe('scope hoisting', function() { assert.deepEqual(out, ['a', 'd', 'c', 'b']); }); - it('hoists import calls to the top', async function() { + it('hoists import calls to the top', async function () { let b = await bundle( path.join( __dirname, @@ -4695,7 +4863,7 @@ describe('scope hoisting', function() { assert.deepEqual(out, ['a', 'd', 'c', 'b']); }); - it('supports requires inside functions with es6 re-export side effects', async function() { + it('supports requires inside functions with es6 re-export side effects', async function () { let b = await bundle( path.join( __dirname, @@ -4713,7 +4881,7 @@ describe('scope hoisting', function() { assert.deepEqual(out, ['a', 'd', 'c', 'b']); }); - it('can bundle the node stream module', async function() { + it('can bundle the node stream module', async function () { let b = await bundle( path.join( __dirname, @@ -4727,7 +4895,7 @@ describe('scope hoisting', function() { assert.equal(typeof res.Duplex, 'function'); }); - it('missing exports should be replaced with an empty object', async function() { + it('missing exports should be replaced with an empty object', async function () { let b = await bundle( path.join( __dirname, @@ -4739,7 +4907,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, {b: {}}); }); - it('removes unused exports', async function() { + it('removes unused exports', async function () { let b = await bundle( path.join( __dirname, @@ -4759,7 +4927,7 @@ describe('scope hoisting', function() { assert(!contents.includes('bar')); }); - it('removes unused exports when assigning with a string literal', async function() { + it('removes unused exports when assigning with a string literal', async function () { let b = await bundle( path.join( __dirname, @@ -4779,7 +4947,7 @@ describe('scope hoisting', function() { assert(!contents.includes('bar')); }); - it('supports removing an unused inline export with uglify minification', async function() { + it('supports removing an unused inline export with uglify minification', async function () { // Uglify does strange things to multiple assignments in a line. // See https://github.com/parcel-bundler/parcel/issues/1549 let b = await bundle( @@ -4798,7 +4966,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 3); }); - it('should support sideEffects: false', async function() { + it('should support sideEffects: false', async function () { let b = await bundle( path.join( __dirname, @@ -4810,7 +4978,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 9); }); - it('can bundle browserify-produced umd bundles', async function() { + it('can bundle browserify-produced umd bundles', async function () { let b = await bundle( path.join( __dirname, @@ -4821,7 +4989,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 'foo'); }); - it('replaces properties of require with undefined', async function() { + it('replaces properties of require with undefined', async function () { let b = await bundle( path.join( __dirname, @@ -4832,7 +5000,7 @@ describe('scope hoisting', function() { await run(b); }); - it('should support two aliases to the same module', async function() { + it('should support two aliases to the same module', async function () { let b = await bundle( path.join( __dirname, @@ -4844,7 +5012,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 42); }); - it('should retain the correct concat order with wrapped assets', async function() { + it('should retain the correct concat order with wrapped assets', async function () { let b = await bundle( path.join( __dirname, @@ -4861,7 +5029,7 @@ describe('scope hoisting', function() { assert.deepStrictEqual(calls, [1, 2, 3, 4, 5, 6, 7]); }); - it('should support optional requires', async function() { + it('should support optional requires', async function () { let b = await bundle( path.join( __dirname, @@ -4873,7 +5041,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 42); }); - it('should insert __esModule interop flag when importing from an ES module', async function() { + it('should insert __esModule interop flag when importing from an ES module', async function () { let b = await bundle( path.join( __dirname, @@ -4886,7 +5054,7 @@ describe('scope hoisting', function() { assert.equal(output.default, 2); }); - it('should export the same values for interop shared modules in main and child bundle', async function() { + it('should export the same values for interop shared modules in main and child bundle', async function () { let b = await bundle( path.join( __dirname, @@ -4897,7 +5065,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 'bar:bar'); }); - it('should export the same values for interop shared modules in main and child bundle if shared bundle is deep nested', async function() { + it('should export the same values for interop shared modules in main and child bundle if shared bundle is deep nested', async function () { let b = await bundle( path.join( __dirname, @@ -4908,7 +5076,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 'bar:bar'); }); - it('should not insert interop default for commonjs modules with default export', async function() { + it('should not insert interop default for commonjs modules with default export', async function () { let b = await bundle( path.join( __dirname, @@ -4924,7 +5092,7 @@ describe('scope hoisting', function() { assert.deepEqual(output.default, obj); }); - it('should not insert default interop for wrapped CJS modules', async function() { + it('should not insert default interop for wrapped CJS modules', async function () { let b = await bundle( path.join( __dirname, @@ -4936,7 +5104,7 @@ describe('scope hoisting', function() { assert.equal(output, 'default'); }); - it('should support multiple requires in the same variable declaration', async function() { + it('should support multiple requires in the same variable declaration', async function () { let b = await bundle( path.join( __dirname, @@ -4948,7 +5116,7 @@ describe('scope hoisting', function() { assert.equal(output, 'before foo middle bar after'); }); - it('should support assigning to exports from inside a function', async function() { + it('should support assigning to exports from inside a function', async function () { let b = await bundle( path.join( __dirname, @@ -4960,7 +5128,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, 2); }); - it('should also hoist inserted polyfills of globals', async function() { + it('should also hoist inserted polyfills of globals', async function () { let b = await bundle( path.join( __dirname, @@ -4972,7 +5140,7 @@ describe('scope hoisting', function() { assert.equal(output, true); }); - it('should support wrapping array destructuring declarations', async function() { + it('should support wrapping array destructuring declarations', async function () { let b = await bundle( path.join( __dirname, @@ -4984,7 +5152,7 @@ describe('scope hoisting', function() { assert.deepEqual(output, [1, 2]); }); - it('should support wrapping object destructuring declarations', async function() { + it('should support wrapping object destructuring declarations', async function () { let b = await bundle( path.join( __dirname, @@ -5007,7 +5175,7 @@ describe('scope hoisting', function() { assert.equal(await run(b), 42); }); - it('can conditionally reference an imported symbol and unconditionally reference it', async function() { + it('can conditionally reference an imported symbol and unconditionally reference it', async function () { let b = await bundle( path.join( __dirname, @@ -5019,7 +5187,7 @@ describe('scope hoisting', function() { assert.equal(output, 'hello'); }); - it('supports assigning to the result of a require', async function() { + it('supports assigning to the result of a require', async function () { let b = await bundle( path.join( __dirname, @@ -5031,7 +5199,7 @@ describe('scope hoisting', function() { assert.equal(output, 4); }); - it('supports both static and non-static exports in the same module with self-reference', async function() { + it('supports both static and non-static exports in the same module with self-reference', async function () { let b = await bundle( path.join( __dirname, @@ -5047,7 +5215,7 @@ describe('scope hoisting', function() { }); }); - it('does not replace assignments to the exports object in the same module', async function() { + it('does not replace assignments to the exports object in the same module', async function () { let b = await bundle( path.join( __dirname, @@ -5063,7 +5231,7 @@ describe('scope hoisting', function() { }); }); - it('replaces static require member expressions with the correct `this` context', async function() { + it('replaces static require member expressions with the correct `this` context', async function () { let b = await bundle( path.join( __dirname, @@ -5078,7 +5246,7 @@ describe('scope hoisting', function() { }); }); - it('does not create a self-referencing dependency for the default symbol without an __esModule flag', async function() { + it('does not create a self-referencing dependency for the default symbol without an __esModule flag', async function () { let b = await bundle( path.join( __dirname, @@ -5090,7 +5258,7 @@ describe('scope hoisting', function() { assert.equal(output, 2); }); - it('should ensure that side effect ordering is correct in sequence expressions with require', async function() { + it('should ensure that side effect ordering is correct in sequence expressions with require', async function () { // https://github.com/parcel-bundler/parcel/issues/5606 let b = await bundle( path.join( @@ -5109,7 +5277,7 @@ describe('scope hoisting', function() { assert.deepEqual(sideEffects, ['before', 'require', 'after']); }); - it('should ensure that side effect ordering is correct in binary expressions with require', async function() { + it('should ensure that side effect ordering is correct in binary expressions with require', async function () { // https://github.com/parcel-bundler/parcel/issues/5606 let b = await bundle( path.join( @@ -5128,7 +5296,7 @@ describe('scope hoisting', function() { assert.deepEqual(sideEffects, ['before', 'require', 'after']); }); - it('should ensure that side effect ordering is correct with default interop', async function() { + it('should ensure that side effect ordering is correct with default interop', async function () { // https://github.com/parcel-bundler/parcel/issues/5662 let b = await bundle( path.join( @@ -5147,7 +5315,7 @@ describe('scope hoisting', function() { assert.deepEqual(sideEffects, ['shared', 'run1', 'async c: 123']); }); - it('should support non-object module.exports', async function() { + it('should support non-object module.exports', async function () { // https://github.com/parcel-bundler/parcel/issues/5892 let b = await bundle( path.join( @@ -5159,7 +5327,7 @@ describe('scope hoisting', function() { await run(b, null, {strict: true}); }); - it('should support assignment to a local variable with require', async function() { + it('should support assignment to a local variable with require', async function () { let b = await bundle( path.join( __dirname, @@ -5180,7 +5348,7 @@ describe('scope hoisting', function() { ]); }); - it('should support out of order assignment to a local variable with require', async function() { + it('should support out of order assignment to a local variable with require', async function () { let b = await bundle( path.join( __dirname, @@ -5201,7 +5369,7 @@ describe('scope hoisting', function() { ]); }); - it('should support assignment to a local variable with require and member expression', async function() { + it('should support assignment to a local variable with require and member expression', async function () { let b = await bundle( path.join( __dirname, @@ -5222,7 +5390,7 @@ describe('scope hoisting', function() { ]); }); - it('should support assignment to a local variable with require and destructuring', async function() { + it('should support assignment to a local variable with require and destructuring', async function () { let b = await bundle( path.join( __dirname, @@ -5243,7 +5411,7 @@ describe('scope hoisting', function() { ]); }); - it('should support assignment to a local variable with require and non-static access', async function() { + it('should support assignment to a local variable with require and non-static access', async function () { let b = await bundle( path.join( __dirname, @@ -5264,7 +5432,7 @@ describe('scope hoisting', function() { ]); }); - it('should handle require as the callee in a new expression', async function() { + it('should handle require as the callee in a new expression', async function () { let b = await bundle( path.join( __dirname, @@ -5276,7 +5444,7 @@ describe('scope hoisting', function() { assert.strictEqual(output.foo(), 1); }); - it('should not update mutated destructured requires', async function() { + it('should not update mutated destructured requires', async function () { let b = await bundle( path.join( __dirname, @@ -5294,7 +5462,7 @@ describe('scope hoisting', function() { assert.deepEqual(outputs, [2, 2]); }); - it('should not update mutated require members', async function() { + it('should not update mutated require members', async function () { let b = await bundle( path.join( __dirname, @@ -5312,7 +5480,7 @@ describe('scope hoisting', function() { assert.deepEqual(outputs, [2, 2]); }); - it('should update live mutated require members', async function() { + it('should update live mutated require members', async function () { let b = await bundle( path.join( __dirname, @@ -5330,7 +5498,7 @@ describe('scope hoisting', function() { assert.deepEqual(outputs, [2, 3]); }); - it('should wrap all assets with an incoming wrapped dependency', async function() { + it('should wrap all assets with an incoming wrapped dependency', async function () { let b = await bundle( path.join( __dirname, @@ -5342,7 +5510,7 @@ describe('scope hoisting', function() { }); }); - it('should not throw with JS included from HTML', async function() { + it('should not throw with JS included from HTML', async function () { let b = await bundle( path.join(__dirname, '/integration/html-js/index.html'), ); @@ -5371,7 +5539,7 @@ describe('scope hoisting', function() { assert.deepEqual(value, ['other']); }); - it('should not throw with JS dynamic imports included from HTML', async function() { + it('should not throw with JS dynamic imports included from HTML', async function () { let b = await bundle( path.join(__dirname, '/integration/html-js-dynamic/index.html'), ); @@ -5396,7 +5564,7 @@ describe('scope hoisting', function() { assert.equal(await res.output(), 'Imported: foobar'); }); - it('should include the prelude in shared entry bundles', async function() { + it('should include the prelude in shared entry bundles', async function () { let b = await bundle( path.join(__dirname, '/integration/html-shared/index.html'), { @@ -5437,7 +5605,7 @@ describe('scope hoisting', function() { assert(contents.includes(`if (parcelRequire == null) {`)); }); - it.skip('does not include prelude if child bundles are isolated', async function() { + it.skip('does not include prelude if child bundles are isolated', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-shared/index.js'), ); @@ -5448,7 +5616,7 @@ describe('scope hoisting', function() { assert(!contents.includes(`if (parcelRequire == null) {`)); }); - it('should include prelude in shared worker bundles', async function() { + it('should include prelude in shared worker bundles', async function () { let b = await bundle( path.join(__dirname, '/integration/worker-shared/index.js'), { @@ -5476,7 +5644,7 @@ describe('scope hoisting', function() { }); // Mirrors the equivalent test in javascript.js - it('should insert global variables when needed', async function() { + it('should insert global variables when needed', async function () { let b = await bundle( path.join(__dirname, '/integration/globals/scope-hoisting.js'), ); @@ -5490,7 +5658,7 @@ describe('scope hoisting', function() { }); }); - it('should be able to named import a reexported namespace in an async bundle', async function() { + it('should be able to named import a reexported namespace in an async bundle', async function () { let b = await bundle( path.join( __dirname, @@ -5501,7 +5669,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), [42, 42, 42, 42]); }); - it('should not remove a binding with a used AssignmentExpression', async function() { + it('should not remove a binding with a used AssignmentExpression', async function () { let b = await bundle( path.join( __dirname, @@ -5512,7 +5680,7 @@ describe('scope hoisting', function() { assert.strictEqual(await run(b), 3); }); - it('should wrap imports inside arrow functions', async function() { + it('should wrap imports inside arrow functions', async function () { let b = await bundle( path.join( __dirname, @@ -5615,10 +5783,9 @@ describe('scope hoisting', function() { it('can static import and dynamic import in the same bundle when another bundle requires async', async () => { let b = await bundle( - [ - 'same-bundle-scope-hoisting.js', - 'get-dep-scope-hoisting.js', - ].map(entry => path.join(__dirname, '/integration/sync-async/', entry)), + ['same-bundle-scope-hoisting.js', 'get-dep-scope-hoisting.js'].map( + entry => path.join(__dirname, '/integration/sync-async/', entry), + ), {mode: 'production'}, ); @@ -5784,7 +5951,7 @@ describe('scope hoisting', function() { assert.deepEqual(await run(b), 43); }); - it('correctly updates dependencies when a specifier is added', async function() { + it('correctly updates dependencies when a specifier is added', async function () { let testDir = path.join( __dirname, '/integration/scope-hoisting/es6/cache-add-specifier', @@ -5816,7 +5983,7 @@ describe('scope hoisting', function() { await subscription.unsubscribe(); }); - it('should not rewrite this in arrow function class properties', async function() { + it('should not rewrite this in arrow function class properties', async function () { let b = await bundle( path.join(__dirname, 'integration/js-class-this-esm/a.js'), ); @@ -5824,7 +5991,7 @@ describe('scope hoisting', function() { assert.deepEqual(res, 'x: 123'); }); - it('should insert the prelude for sibling bundles referenced in HTML', async function() { + it('should insert the prelude for sibling bundles referenced in HTML', async function () { let b = await bundle( path.join( __dirname, @@ -5834,4 +6001,84 @@ describe('scope hoisting', function() { let res = await run(b, {output: null}, {require: false}); assert.equal(res.output, 'a'); }); + + it('should unmark dependency as deferred when dependency becomes used', async function () { + let testDir = path.join( + __dirname, + 'integration/scope-hoisting/es6/unmarks-defer-for-new-deps', + ); + + let packageDir = path.join(testDir, '/package'); + + await overlayFS.mkdirp(packageDir); + await overlayFS.copyFile( + path.join(packageDir, 'b1.js'), + path.join(packageDir, 'b.js'), + ); + + await bundle(path.join(testDir, 'index.js'), { + inputFS: overlayFS, + outputFS: overlayFS, + shouldDisableCache: true, + }); + + await overlayFS.copyFile( + path.join(packageDir, 'b2.js'), + path.join(packageDir, 'b.js'), + ); + + await bundle(path.join(testDir, 'index.js'), { + inputFS: overlayFS, + outputFS: overlayFS, + shouldDisableCache: false, + }); + }); + + it('unmark an asset group as deferred when it becomes used', async function () { + let testDir = path.join( + __dirname, + 'integration/scope-hoisting/es6/unmarks-defer-for-assetgroup', + ); + + await overlayFS.mkdirp(testDir); + await overlayFS.copyFile( + path.join(testDir, 'index1.js'), + path.join(testDir, 'index.js'), + ); + + let b = await bundle(path.join(testDir, 'index.js'), { + inputFS: overlayFS, + outputFS: overlayFS, + shouldDisableCache: true, + }); + + await run(b); + + await overlayFS.copyFile( + path.join(testDir, 'index2.js'), + path.join(testDir, 'index.js'), + ); + + b = await bundle(path.join(testDir, 'index.js'), { + inputFS: overlayFS, + outputFS: overlayFS, + shouldDisableCache: false, + }); + + await run(b); + + await overlayFS.copyFile( + path.join(testDir, 'index3.js'), + path.join(testDir, 'index.js'), + ); + + b = await bundle(path.join(testDir, 'index.js'), { + inputFS: overlayFS, + outputFS: overlayFS, + shouldDisableCache: false, + }); + + let output = await run(b); + assert.strictEqual(output, 'bar foo bar'); + }); }); diff --git a/packages/core/integration-tests/test/server.js b/packages/core/integration-tests/test/server.js index 97c3228296c..0c820c4ff7c 100644 --- a/packages/core/integration-tests/test/server.js +++ b/packages/core/integration-tests/test/server.js @@ -48,7 +48,7 @@ function get(file, port, client = http) { }); } -describe('server', function() { +describe('server', function () { let subscription; afterEach(async () => { @@ -58,7 +58,7 @@ describe('server', function() { subscription = null; }); - it('should serve files', async function() { + it('should serve files', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/commonjs/index.js'), { defaultTargetOptions: { @@ -84,7 +84,7 @@ describe('server', function() { assert.equal(data, distFile); }); - it('should serve source files', async function() { + it('should serve source files', async function () { let port = await getPort(); let inputPath = path.join(__dirname, '/integration/commonjs/index.js'); let b = bundler(inputPath, { @@ -111,7 +111,7 @@ describe('server', function() { assert.equal(data, inputFile); }); - it('should serve sourcemaps', async function() { + it('should serve sourcemaps', async function () { let port = await getPort(); let inputPath = path.join(__dirname, '/integration/commonjs/index.js'); let b = bundler(inputPath, { @@ -138,7 +138,7 @@ describe('server', function() { assert.equal(data, distFile); }); - it('should serve a default page if the main bundle is an HTML asset', async function() { + it('should serve a default page if the main bundle is an HTML asset', async function () { let port = await getPort(); let b = bundler( [ @@ -181,7 +181,7 @@ describe('server', function() { assert.equal(data, fooIndexFile); }); - it('should serve a default page if the main bundle is an HTML asset even if it is not called index', async function() { + it('should serve a default page if the main bundle is an HTML asset even if it is not called index', async function () { let port = await getPort(); let inputPath = path.join(__dirname, '/integration/html/other.html'); let b = bundler(inputPath, { @@ -214,7 +214,7 @@ describe('server', function() { assert.equal(data, rootIndexFile); }); - it('should serve a default page if the main bundle is an HTML asset with package.json#source', async function() { + it('should serve a default page if the main bundle is an HTML asset with package.json#source', async function () { let port = await getPort(); let inputPath = path.join(__dirname, '/integration/html-pkg-source/'); let b = bundler(inputPath, { @@ -246,7 +246,7 @@ describe('server', function() { assert.equal(data, outputFile); }); - it('should serve a 404 if the file does not exist', async function() { + it('should serve a 404 if the file does not exist', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/commonjs/index.js'), { config, @@ -270,7 +270,7 @@ describe('server', function() { assert.equal(statusCode, 404); }); - it('should serve a 500 if the bundler errored', async function() { + it('should serve a 500 if the bundler errored', async function () { let port = await getPort(); let inputDir = path.join(__dirname, '/input/server-500'); await ncp(path.join(__dirname, '/integration/babel'), inputDir); @@ -308,7 +308,7 @@ describe('server', function() { assert.equal(statusCode, 500); }); - it('should support HTTPS', async function() { + it('should support HTTPS', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/commonjs/index.js'), { defaultTargetOptions: { @@ -332,7 +332,7 @@ describe('server', function() { ); }); - it('should support HTTPS via custom certificate', async function() { + it('should support HTTPS via custom certificate', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/commonjs/index.js'), { defaultTargetOptions: { @@ -359,7 +359,7 @@ describe('server', function() { ); }); - it('should support setting a public url', async function() { + it('should support setting a public url', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/commonjs/index.js'), { defaultTargetOptions: { @@ -384,7 +384,7 @@ describe('server', function() { ); }); - it('should work with query parameters that contain a dot', async function() { + it('should work with query parameters that contain a dot', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/commonjs/index.js'), { defaultTargetOptions: { @@ -408,7 +408,7 @@ describe('server', function() { ); }); - it('should work with paths that contain a dot', async function() { + it('should work with paths that contain a dot', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/html/index.html'), { defaultTargetOptions: { @@ -432,7 +432,7 @@ describe('server', function() { ); }); - it('should support lazy bundling', async function() { + it('should support lazy bundling', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/html/index.html'), { defaultTargetOptions: { @@ -525,7 +525,7 @@ describe('server', function() { assert(!dir.includes('other.html')); }); - it('should support lazy bundling sibling css files of dynamic import', async function() { + it('should support lazy bundling sibling css files of dynamic import', async function () { let port = await getPort(); let b = bundler(path.join(__dirname, '/integration/dynamic-css/index.js'), { defaultTargetOptions: { diff --git a/packages/core/integration-tests/test/sourcemaps.js b/packages/core/integration-tests/test/sourcemaps.js index 9b41f180344..e35e4f7272e 100644 --- a/packages/core/integration-tests/test/sourcemaps.js +++ b/packages/core/integration-tests/test/sourcemaps.js @@ -136,8 +136,8 @@ function checkSourceMapping({ ); } -describe('sourcemaps', function() { - it('Should create a basic browser sourcemap', async function() { +describe('sourcemaps', function () { + it('Should create a basic browser sourcemap', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap/index.js', @@ -191,7 +191,7 @@ describe('sourcemaps', function() { }); }); - it('Should create a basic browser sourcemap when serving', async function() { + it('Should create a basic browser sourcemap when serving', async function () { let fixture = path.join(__dirname, '/integration/sourcemap'); let sourceFilename = path.join(fixture, 'index.js'); await bundle(sourceFilename, {serveOptions: {port: 1234}}); @@ -237,7 +237,7 @@ describe('sourcemaps', function() { }); }); - it('Should create a basic node sourcemap', async function() { + it('Should create a basic node sourcemap', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-node/index.js', @@ -297,7 +297,7 @@ describe('sourcemaps', function() { }); }); - it('should create a valid sourcemap for a js file with requires', async function() { + it('should create a valid sourcemap for a js file with requires', async function () { let sourceDir = path.join(__dirname, '/integration/sourcemap-nested/'); let sourceFilename = path.join(sourceDir, '/index.js'); await bundle(sourceFilename); @@ -378,7 +378,7 @@ describe('sourcemaps', function() { }); }); - it('should create a valid sourcemap for a minified js bundle with requires', async function() { + it('should create a valid sourcemap for a minified js bundle with requires', async function () { let sourceDir = path.join( __dirname, '/integration/sourcemap-nested-minified/', @@ -433,7 +433,7 @@ describe('sourcemaps', function() { source: inputs[0], generated: raw, str: 'const local', - generatedStr: 'const o', + generatedStr: 'const t', sourcePath: 'index.js', }); @@ -442,7 +442,7 @@ describe('sourcemaps', function() { source: inputs[0], generated: raw, str: 'local.a', - generatedStr: 'o.a', + generatedStr: 't.a', sourcePath: 'index.js', }); @@ -451,7 +451,7 @@ describe('sourcemaps', function() { source: inputs[1], generated: raw, str: 'exports.a', - generatedStr: 't.a', + generatedStr: 'o.a', sourcePath: 'local.js', }); @@ -460,12 +460,12 @@ describe('sourcemaps', function() { source: inputs[2], generated: raw, str: 'exports.count = function(a, b) {', - generatedStr: 't.count=function(e,n){', + generatedStr: 'o.count=function(e,n){', sourcePath: 'utils/util.js', }); }); - it('should create a valid sourcemap as a child of a TS bundle', async function() { + it('should create a valid sourcemap as a child of a TS bundle', async function () { let inputFilePath = path.join( __dirname, '/integration/sourcemap-typescript/index.ts', @@ -508,7 +508,7 @@ describe('sourcemaps', function() { }); }); - it('should create a valid sourcemap as a child of a nested TS bundle', async function() { + it('should create a valid sourcemap as a child of a nested TS bundle', async function () { let inputFilePath = path.join( __dirname, '/integration/sourcemap-typescript-nested/index.ts', @@ -563,7 +563,47 @@ describe('sourcemaps', function() { }); }); - it('should create a valid sourcemap for a CSS bundle', async function() { + it('should create a valid sourcemap when using the Typescript tsc transformer', async function () { + let inputFilePath = path.join( + __dirname, + '/integration/sourcemap-typescript-tsc/index.ts', + ); + + await bundle(inputFilePath); + let distDir = path.join(__dirname, '../dist/'); + let filename = path.join(distDir, 'index.js'); + let raw = await outputFS.readFile(filename, 'utf8'); + let mapUrlData = await loadSourceMapUrl(outputFS, filename, raw); + if (!mapUrlData) { + throw new Error('Could not load map'); + } + let map = mapUrlData.map; + + assert.equal(map.file, 'index.js.map'); + assert(raw.includes('//# sourceMappingURL=index.js.map')); + // assert.equal(map.sourceRoot, '/__parcel_source_root/'); + + let sourceMap = new SourceMap('/'); + sourceMap.addVLQMap(map); + + let mapData = sourceMap.getMap(); + assert.equal(mapData.sources.length, 1); + assert.deepEqual(mapData.sources, ['index.ts']); + + let input = await inputFS.readFile( + path.join(path.dirname(filename), map.sourceRoot, map.sources[0]), + 'utf8', + ); + checkSourceMapping({ + map: sourceMap, + source: input, + generated: raw, + str: 'nonExistsFunc', + sourcePath: 'index.ts', + }); + }); + + it('should create a valid sourcemap for a CSS bundle', async function () { async function test(minify) { let inputFilePath = path.join( __dirname, @@ -618,7 +658,7 @@ describe('sourcemaps', function() { await test(true); }); - it('should create a valid sourcemap for a CSS bundle with imports', async function() { + it('should create a valid sourcemap for a CSS bundle with imports', async function () { async function test(minify) { let inputFilePath = path.join( __dirname, @@ -720,7 +760,7 @@ describe('sourcemaps', function() { await test(true); }); - it('should create a valid sourcemap for a Sass asset', async function() { + it('should create a valid sourcemap for a Sass asset', async function () { async function test(shouldOptimize) { let inputFilePath = path.join( __dirname, @@ -779,7 +819,7 @@ describe('sourcemaps', function() { await test(true); }); - it('should create a valid sourcemap for a Sass asset w/ imports', async function() { + it('should create a valid sourcemap for a Sass asset w/ imports', async function () { let inputFilePath = path.join( __dirname, '/integration/scss-sourcemap-imports/style.scss', @@ -831,7 +871,7 @@ describe('sourcemaps', function() { }); }); - it('should create a valid sourcemap when for a CSS asset importing Sass', async function() { + it('should create a valid sourcemap when for a CSS asset importing Sass', async function () { async function test(shouldOptimize) { let inputFilePath = path.join( __dirname, @@ -917,7 +957,7 @@ describe('sourcemaps', function() { await test(true); }); - it('should create a valid sourcemap for a LESS asset', async function() { + it('should create a valid sourcemap for a LESS asset', async function () { async function test(shouldOptimize) { let inputFilePath = path.join( __dirname, @@ -975,7 +1015,7 @@ describe('sourcemaps', function() { await test(true); }); - it('Should be able to create a sourcemap with inlined sources', async function() { + it('Should be able to create a sourcemap with inlined sources', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-inline-sources/index.js', @@ -1006,7 +1046,7 @@ describe('sourcemaps', function() { assert.equal(map.sourcesContent[0], sourceContent); }); - it('Should be able to create inline sourcemaps', async function() { + it('Should be able to create inline sourcemaps', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-generate-inline/index.js', @@ -1039,7 +1079,7 @@ describe('sourcemaps', function() { ]); }); - it('should respect --no-source-maps', async function() { + it('should respect --no-source-maps', async function () { let b = await bundle( path.join(__dirname, '/integration/sourcemap/index.js'), { @@ -1055,7 +1095,7 @@ describe('sourcemaps', function() { ); }); - it('Should just skip invalid inlined sourcemaps', async function() { + it('Should just skip invalid inlined sourcemaps', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-invalid-existing/index.js', @@ -1074,7 +1114,7 @@ describe('sourcemaps', function() { assert.equal(map.sources.length, 2); }); - it('should load existing sourcemaps of libraries', async function() { + it('should load existing sourcemaps of libraries', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-existing/index.js', @@ -1105,7 +1145,7 @@ describe('sourcemaps', function() { assert.equal(map.sourcesContent[2], 'module.exports = (a, b) => a + b'); }); - it('should load inline sourcemaps of libraries', async function() { + it('should load inline sourcemaps of libraries', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-inline/index.js', @@ -1135,7 +1175,7 @@ describe('sourcemaps', function() { assert.equal(map.sourcesContent[2], 'module.exports = (a, b) => a + b\n'); }); - it('should load referenced contents of sourcemaps', async function() { + it('should load referenced contents of sourcemaps', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-external-contents/index.js', @@ -1162,7 +1202,7 @@ describe('sourcemaps', function() { } }); - it.skip('should load existing sourcemaps for CSS files', async function() { + it.skip('should load existing sourcemaps for CSS files', async function () { async function test(minify) { let sourceFilename = path.join( __dirname, @@ -1241,7 +1281,7 @@ describe('sourcemaps', function() { await test(true); }); - it('should handle comments correctly in sourcemaps', async function() { + it('should handle comments correctly in sourcemaps', async function () { let sourceFilename = path.join( __dirname, '/integration/sourcemap-comments/index.js', diff --git a/packages/core/integration-tests/test/stylus.js b/packages/core/integration-tests/test/stylus.js index 843a987f79f..66c1fc0546b 100644 --- a/packages/core/integration-tests/test/stylus.js +++ b/packages/core/integration-tests/test/stylus.js @@ -8,8 +8,8 @@ import { outputFS, } from '@parcel/test-utils'; -describe('stylus', function() { - it('should support requiring stylus files', async function() { +describe('stylus', function () { + it('should support requiring stylus files', async function () { let b = await bundle(path.join(__dirname, '/integration/stylus/index.js')); assertBundles(b, [ @@ -31,7 +31,7 @@ describe('stylus', function() { assert(css.includes('.index')); }); - it('should support requiring stylus files with dependencies', async function() { + it('should support requiring stylus files with dependencies', async function () { let b = await bundle( path.join(__dirname, '/integration/stylus-deps/index.js'), ); @@ -61,7 +61,7 @@ describe('stylus', function() { assert(css.includes('.foo')); }); - it('should support linking to assets with url() from stylus', async function() { + it('should support linking to assets with url() from stylus', async function () { let b = await bundle( path.join(__dirname, '/integration/stylus-url/index.js'), ); @@ -97,7 +97,7 @@ describe('stylus', function() { ); }); - it('should ignore paths starting with "#" when resolving with stylus url()', async function() { + it('should ignore paths starting with "#" when resolving with stylus url()', async function () { let b = await bundle( path.join(__dirname, '/integration/stylus-id-url/index.js'), ); @@ -122,7 +122,7 @@ describe('stylus', function() { assert(css.includes('.svg-background')); }); - it('should support transforming stylus with css modules', async function() { + it('should support transforming stylus with css modules', async function () { let b = await bundle( path.join(__dirname, '/integration/stylus-postcss/index.js'), ); @@ -146,7 +146,7 @@ describe('stylus', function() { assert(css.includes('._index_')); }); - it('should support requiring stylus files with glob dependencies', async function() { + it('should support requiring stylus files with glob dependencies', async function () { let b = await bundle( path.join(__dirname, '/integration/stylus-glob-import/index.js'), ); diff --git a/packages/core/integration-tests/test/sugarss.js b/packages/core/integration-tests/test/sugarss.js index 45e12f80a0a..141e58931c3 100644 --- a/packages/core/integration-tests/test/sugarss.js +++ b/packages/core/integration-tests/test/sugarss.js @@ -2,8 +2,8 @@ import assert from 'assert'; import {bundle, assertBundles, outputFS, distDir} from '@parcel/test-utils'; import path from 'path'; -describe('sugarss', function() { - it('should correctly parse SugarSS asset', async function() { +describe('sugarss', function () { + it('should correctly parse SugarSS asset', async function () { let b = await bundle( path.join(__dirname, '/integration/sugarss/index.sss'), ); diff --git a/packages/core/integration-tests/test/svg-react.js b/packages/core/integration-tests/test/svg-react.js index 4de2d507c93..0ae957aa498 100644 --- a/packages/core/integration-tests/test/svg-react.js +++ b/packages/core/integration-tests/test/svg-react.js @@ -2,8 +2,8 @@ import assert from 'assert'; import {bundle, outputFS} from '@parcel/test-utils'; import path from 'path'; -describe('svg-react', function() { - it('should support transforming SVGs to react components', async function() { +describe('svg-react', function () { + it('should support transforming SVGs to react components', async function () { let b = await bundle( path.join(__dirname, '/integration/svg-react/react.js'), { diff --git a/packages/core/integration-tests/test/svg.js b/packages/core/integration-tests/test/svg.js index 302a26a1f9c..3cec93c6192 100644 --- a/packages/core/integration-tests/test/svg.js +++ b/packages/core/integration-tests/test/svg.js @@ -2,7 +2,7 @@ import assert from 'assert'; import {assertBundles, bundle, distDir, outputFS} from '@parcel/test-utils'; import path from 'path'; -describe('svg', function() { +describe('svg', function () { it('should support bundling SVG', async () => { let b = await bundle(path.join(__dirname, '/integration/svg/circle.svg')); @@ -94,7 +94,7 @@ describe('svg', function() { ); }); - it('should minify SVG bundles', async function() { + it('should minify SVG bundles', async function () { let b = await bundle(path.join(__dirname, '/integration/svg/circle.svg'), { defaultTargetOptions: { shouldOptimize: true, @@ -108,7 +108,7 @@ describe('svg', function() { assert(!file.includes('comment')); }); - it('support SVGO config files', async function() { + it('support SVGO config files', async function () { let b = await bundle( path.join(__dirname, '/integration/svgo-config/index.html'), { @@ -126,7 +126,7 @@ describe('svg', function() { assert(file.includes('comment')); }); - it('should detect xml-stylesheet processing instructions', async function() { + it('should detect xml-stylesheet processing instructions', async function () { let b = await bundle( path.join(__dirname, '/integration/svg-xml-stylesheet/img.svg'), ); @@ -155,7 +155,7 @@ describe('svg', function() { assert(file.includes(':root{fill:red}')); }); - it('should be in separate bundles', async function() { + it('should be in separate bundles', async function () { const b = await bundle( path.join(__dirname, '/integration/svg-multiple/index.js'), ); diff --git a/packages/core/integration-tests/test/transpilation.js b/packages/core/integration-tests/test/transpilation.js index 5397e170279..de40708e7e2 100644 --- a/packages/core/integration-tests/test/transpilation.js +++ b/packages/core/integration-tests/test/transpilation.js @@ -14,8 +14,8 @@ import {symlinkSync} from 'fs'; const inputDir = path.join(__dirname, '/input'); -describe('transpilation', function() { - it('should not transpile if no targets are defined', async function() { +describe('transpilation', function () { + it('should not transpile if no targets are defined', async function () { await bundle(path.join(__dirname, '/integration/babel-default/index.js'), { defaultTargetOptions: { engines: undefined, @@ -27,7 +27,7 @@ describe('transpilation', function() { assert(file.includes('class Bar')); }); - it('should support transpiling using browserlist', async function() { + it('should support transpiling using browserlist', async function () { await bundle( path.join(__dirname, '/integration/babel-browserslist/index.js'), ); @@ -56,7 +56,7 @@ describe('transpilation', function() { assert(modern.includes('class Bar')); }); - it('should not transpile node_modules by default', async function() { + it('should not transpile node_modules by default', async function () { await bundle( path.join(__dirname, '/integration/babel-node-modules/index.js'), ); @@ -66,7 +66,7 @@ describe('transpilation', function() { assert(file.includes('function Bar')); }); - it('should not compile node_modules with a source field in package.json when not symlinked', async function() { + it('should not compile node_modules with a source field in package.json when not symlinked', async function () { await bundle( path.join( __dirname, @@ -79,7 +79,7 @@ describe('transpilation', function() { assert(file.includes('function Bar')); }); - it('should support compiling JSX', async function() { + it('should support compiling JSX', async function () { await bundle(path.join(__dirname, '/integration/jsx/index.jsx')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); @@ -87,14 +87,21 @@ describe('transpilation', function() { assert(file.includes('fileName: "integration/jsx/index.jsx"')); }); - it('should support compiling JSX in JS files with React dependency', async function() { + it('should support compiling JSX correctly with member expression type', async function () { + await bundle(path.join(__dirname, '/integration/jsx-member/index.jsx')); + + let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); + assert(file.includes('React.createElement(S.Foo')); + }); + + it('should support compiling JSX in JS files with React dependency', async function () { await bundle(path.join(__dirname, '/integration/jsx-react/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); assert(file.includes('React.createElement("div"')); }); - it('should support compiling JSX with pure annotations', async function() { + it('should support compiling JSX with pure annotations', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-react/pure-comment.js'), ); @@ -109,21 +116,21 @@ describe('transpilation', function() { assert(res.Foo()); }); - it('should support compiling JSX in JS files with React aliased to Preact', async function() { + it('should support compiling JSX in JS files with React aliased to Preact', async function () { await bundle(path.join(__dirname, '/integration/jsx-react-alias/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); assert(file.includes('React.createElement("div"')); }); - it('should support compiling JSX in JS files with Preact dependency', async function() { + it('should support compiling JSX in JS files with Preact dependency', async function () { await bundle(path.join(__dirname, '/integration/jsx-preact/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); assert(file.includes('h("div"')); }); - it('should support compiling JSX in TS files with Preact dependency', async function() { + it('should support compiling JSX in TS files with Preact dependency', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-preact-ts/index.tsx'), ); @@ -131,21 +138,21 @@ describe('transpilation', function() { assert(typeof (await run(b)) === 'object'); }); - it('should support compiling JSX in JS files with Nerv dependency', async function() { + it('should support compiling JSX in JS files with Nerv dependency', async function () { await bundle(path.join(__dirname, '/integration/jsx-nervjs/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); assert(file.includes('Nerv.createElement("div"')); }); - it('should support compiling JSX in JS files with Hyperapp dependency', async function() { + it('should support compiling JSX in JS files with Hyperapp dependency', async function () { await bundle(path.join(__dirname, '/integration/jsx-hyperapp/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); assert(file.includes('h("div"')); }); - it('should not transpile spread in JSX with modern targets', async function() { + it('should not transpile spread in JSX with modern targets', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-spread/index.jsx'), ); @@ -156,7 +163,7 @@ describe('transpilation', function() { assert(!file.includes('@swc/helpers')); }); - it('should support the automatic JSX runtime with React >= 17', async function() { + it('should support the automatic JSX runtime with React >= 17', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-automatic/index.js'), ); @@ -166,7 +173,7 @@ describe('transpilation', function() { assert(file.includes('_jsxRuntime.jsx("div"')); }); - it('should support the automatic JSX runtime with preact >= 10.5', async function() { + it('should support the automatic JSX runtime with preact >= 10.5', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-automatic-preact/index.js'), ); @@ -176,7 +183,7 @@ describe('transpilation', function() { assert(file.includes('_jsxRuntime.jsx("div"')); }); - it('should support the automatic JSX runtime with explicit tsconfig.json', async function() { + it('should support the automatic JSX runtime with explicit tsconfig.json', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-automatic-tsconfig/index.js'), ); @@ -186,7 +193,7 @@ describe('transpilation', function() { assert(file.includes('_jsxRuntime.jsx("div"')); }); - it('should support explicit JSX pragma in tsconfig.json', async function() { + it('should support explicit JSX pragma in tsconfig.json', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-pragma-tsconfig/index.js'), ); @@ -196,7 +203,7 @@ describe('transpilation', function() { assert(file.includes('JSX("div"')); }); - it('should support explicitly enabling JSX in tsconfig.json', async function() { + it('should support explicitly enabling JSX in tsconfig.json', async function () { let b = await bundle( path.join(__dirname, '/integration/jsx-tsconfig/index.js'), ); @@ -205,7 +212,7 @@ describe('transpilation', function() { assert(file.includes('React.createElement("div"')); }); - it('should support enabling decorators in tsconfig.json', async function() { + it('should support enabling decorators in tsconfig.json', async function () { let b = await bundle( path.join(__dirname, '/integration/decorators/index.ts'), ); @@ -225,7 +232,7 @@ describe('transpilation', function() { ]); }); - it('should support transpiling optional chaining', async function() { + it('should support transpiling optional chaining', async function () { let b = await bundle( path.join(__dirname, '/integration/babel-optional-chaining/index.js'), ); @@ -238,7 +245,7 @@ describe('transpilation', function() { assert.deepEqual(output.default, [undefined, undefined]); }); - it('should only include necessary parts of core-js using browserlist', async function() { + it('should only include necessary parts of core-js using browserlist', async function () { await bundle(path.join(__dirname, '/integration/babel-core-js/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); @@ -250,13 +257,8 @@ describe('transpilation', function() { assert(!file.includes('es.array.concat')); }); - it('should resolve @swc/helpers and regenerator-runtime relative to parcel', async function() { - let dir = path.join( - '/tmp/' + - Math.random() - .toString(36) - .slice(2), - ); + it('should resolve @swc/helpers and regenerator-runtime relative to parcel', async function () { + let dir = path.join('/tmp/' + Math.random().toString(36).slice(2)); await outputFS.mkdirp(dir); await ncp(path.join(__dirname, '/integration/swc-helpers'), dir); await bundle(path.join(dir, 'index.js'), { @@ -284,7 +286,7 @@ describe('transpilation', function() { } }); - it('should compile node_modules when symlinked with a source field in package.json', async function() { + it('should compile node_modules when symlinked with a source field in package.json', async function () { if (process.platform === 'win32') { this.skip(); return; diff --git a/packages/core/integration-tests/test/ts-types.js b/packages/core/integration-tests/test/ts-types.js index 0a668cf2b49..b06890f96ed 100644 --- a/packages/core/integration-tests/test/ts-types.js +++ b/packages/core/integration-tests/test/ts-types.js @@ -9,8 +9,8 @@ import { ncp, } from '@parcel/test-utils'; -describe('typescript types', function() { - it('should generate a typescript declaration file', async function() { +describe('typescript types', function () { + it('should generate a typescript declaration file', async function () { let b = await bundle( path.join(__dirname, '/integration/ts-types/main/index.ts'), ); @@ -39,7 +39,7 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should generate ts declarations with imports', async function() { + it('should generate ts declarations with imports', async function () { let b = await bundle( path.join(__dirname, '/integration/ts-types/importing/index.ts'), ); @@ -68,7 +68,7 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should generate ts declarations with imports and naming collisions', async function() { + it('should generate ts declarations with imports and naming collisions', async function () { let b = await bundle( path.join( __dirname, @@ -106,7 +106,7 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should generate ts declarations with exports', async function() { + it('should generate ts declarations with exports', async function () { let b = await bundle( path.join(__dirname, '/integration/ts-types/exporting/index.ts'), ); @@ -135,7 +135,42 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should generate ts declarations with externals', async function() { + it('should generate ts declarations with export of an overloaded function signature', async function () { + let b = await bundle( + path.join(__dirname, '/integration/ts-types/exporting-overload/index.ts'), + ); + + assertBundles(b, [ + { + type: 'js', + assets: ['index.ts'], + }, + { + type: 'ts', + assets: ['index.ts'], + }, + ]); + + let dist = ( + await outputFS.readFile( + path.join( + __dirname, + '/integration/ts-types/exporting-overload/dist/types.d.ts', + ), + 'utf8', + ) + ).replace(/\r\n/g, '\n'); + let expected = await inputFS.readFile( + path.join( + __dirname, + '/integration/ts-types/exporting-overload/expected.d.ts', + ), + 'utf8', + ); + assert.equal(dist, expected); + }); + + it('should generate ts declarations with externals', async function () { let b = await bundle( path.join(__dirname, '/integration/ts-types/externals/index.tsx'), ); @@ -164,7 +199,7 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should generate ts declarations with externals that conflict with exported names', async function() { + it('should generate ts declarations with externals that conflict with exported names', async function () { let b = await bundle( path.join( __dirname, @@ -202,7 +237,7 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should remove private properties', async function() { + it('should remove private properties', async function () { await bundle( path.join(__dirname, '/integration/ts-types/private/index.ts'), ); @@ -220,7 +255,7 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should not throw errors on typing of a callback which returns a promise or value', async function() { + it('should not throw errors on typing of a callback which returns a promise or value', async function () { await bundle( path.join(__dirname, '/integration/ts-types/promise-or-value/index.ts'), ); @@ -245,7 +280,7 @@ describe('typescript types', function() { assert.equal(dist, expected); }); - it('should correctly reference unbuilt monorepo packages', async function() { + it('should correctly reference unbuilt monorepo packages', async function () { let fixtureDir = path.join(__dirname, 'integration/ts-types/monorepo'); await outputFS.mkdirp(path.join(fixtureDir, 'node_modules')); await ncp(fixtureDir, fixtureDir); @@ -271,7 +306,7 @@ describe('typescript types', function() { assert(/import\s*{\s*B\s*}\s*from\s*"b";/.test(dist)); }); - it('should generate a typescript declaration file even when composite is true', async function() { + it('should generate a typescript declaration file even when composite is true', async function () { await bundle( path.join(__dirname, '/integration/ts-types/composite/index.ts'), ); diff --git a/packages/core/integration-tests/test/ts-validation.js b/packages/core/integration-tests/test/ts-validation.js index d3623913380..6c568bd8350 100644 --- a/packages/core/integration-tests/test/ts-validation.js +++ b/packages/core/integration-tests/test/ts-validation.js @@ -15,7 +15,7 @@ const config = path.join( './integration/custom-configs/.parcelrc-typescript-validation', ); -describe('ts-validator', function() { +describe('ts-validator', function () { let subscription; afterEach(async () => { if (subscription) { @@ -24,7 +24,7 @@ describe('ts-validator', function() { subscription = null; }); - it('should throw validation error on typescript typing errors across multiple files', async function() { + it('should throw validation error on typescript typing errors across multiple files', async function () { let didThrow = false; let entry = normalizeFilePath( path.join(__dirname, '/integration/ts-validation-error/index.ts'), @@ -71,7 +71,7 @@ describe('ts-validator', function() { assert(didThrow); }); - it('should re-run when .ts files change', async function() { + it('should re-run when .ts files change', async function () { // We to try to avoid conflicts between tests using the same in-memory file system, we're creating a separate folder. // During the first test pass, this is unnecessary, but because fileSystems won't be re-created when running in 'watch' mode, this is safer. const inputDir = path.join(__dirname, '/ts-validator-change'); @@ -117,7 +117,7 @@ describe('ts-validator', function() { ); }); - it('should report correct errors when multiple .ts files change at the same time - no errors', async function() { + it('should report correct errors when multiple .ts files change at the same time - no errors', async function () { // We to try to avoid conflicts between tests using the same in-memory file system, we're creating a separate folder. // During the first test pass, this is unnecessary, but because fileSystems won't be re-created when running in 'watch' mode, this is safer. const inputDir = path.join(__dirname, '/ts-validator-multi-change'); @@ -161,7 +161,7 @@ describe('ts-validator', function() { assert.equal(output.output, 123456); }); - it('should report correct errors when multiple .ts files change at the same time - with errors', async function() { + it('should report correct errors when multiple .ts files change at the same time - with errors', async function () { // We to try to avoid conflicts between tests using the same in-memory file system, we're creating a separate folder. // During the first test pass, this is unnecessary, but because fileSystems won't be re-created when running in 'watch' mode, this is safer. const inputDir = path.join(__dirname, '/ts-validator-multi-change-errors'); @@ -211,7 +211,7 @@ describe('ts-validator', function() { ); }); - it('should report correct errors when .ts dependencies change in a way that breaks a contract', async function() { + it('should report correct errors when .ts dependencies change in a way that breaks a contract', async function () { // We to try to avoid conflicts between tests using the same in-memory file system, we're creating a separate folder. // During the first test pass, this is unnecessary, but because fileSystems won't be re-created when running in 'watch' mode, this is safer. const inputDir = path.join(__dirname, '/ts-validator-dependencies-change'); diff --git a/packages/core/integration-tests/test/typescript-tsc.js b/packages/core/integration-tests/test/typescript-tsc.js index 23932fce248..3499dcfb53e 100644 --- a/packages/core/integration-tests/test/typescript-tsc.js +++ b/packages/core/integration-tests/test/typescript-tsc.js @@ -10,7 +10,7 @@ import { const config = path.join(__dirname, '/integration/typescript-config/.parcelrc'); -describe('typescript tsc', function() { +describe('typescript tsc', function () { it('should support loading tsconfig.json', async () => { let b = await bundle( path.join(__dirname, '/integration/typescript-config/index.ts'), @@ -37,7 +37,7 @@ describe('typescript tsc', function() { assert(!js.includes('/* test comment */')); }); - it('should produce a type declaration file when overriding the ts pipeline', async function() { + it('should produce a type declaration file when overriding the ts pipeline', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript-types-parcelrc/index.ts'), ); diff --git a/packages/core/integration-tests/test/typescript.js b/packages/core/integration-tests/test/typescript.js index 14a45158447..ea312076978 100644 --- a/packages/core/integration-tests/test/typescript.js +++ b/packages/core/integration-tests/test/typescript.js @@ -14,7 +14,7 @@ const tscConfig = path.join( '/integration/typescript-config/.parcelrc', ); -describe('typescript', function() { +describe('typescript', function () { // This tests both the SWC transformer implementation of typescript (which // powers typescript by default in Parcel) as well as through the Typescript // tsc transformer. Use a null config to indicate the default config, and the @@ -25,7 +25,7 @@ describe('typescript', function() { null /* default config -- testing SWC typescript */, tscConfig, ]) { - it('should produce a ts bundle using ES6 imports', async function() { + it('should produce a ts bundle using ES6 imports', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript/index.ts'), {config}, @@ -43,7 +43,7 @@ describe('typescript', function() { assert.equal(output.count(), 3); }); - it('should produce a ts bundle using commonJS require', async function() { + it('should produce a ts bundle using commonJS require', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript-require/index.ts'), {config}, @@ -61,7 +61,7 @@ describe('typescript', function() { assert.equal(output.count(), 3); }); - it('should support json require', async function() { + it('should support json require', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript-json/index.ts'), ); @@ -74,7 +74,7 @@ describe('typescript', function() { assert.equal(output.count(), 3); }); - it('should support env variables', async function() { + it('should support env variables', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript-env/index.ts'), {config}, @@ -92,7 +92,7 @@ describe('typescript', function() { assert.equal(output.env(), 'test'); }); - it('should support importing a URL to a raw asset', async function() { + it('should support importing a URL to a raw asset', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript-raw/index.ts'), {config}, @@ -119,7 +119,7 @@ describe('typescript', function() { ); }); - it('should minify with minify enabled', async function() { + it('should minify with minify enabled', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript-require/index.ts'), { @@ -145,7 +145,7 @@ describe('typescript', function() { assert(!js.includes('local.a')); }); - it('should support compiling JSX', async function() { + it('should support compiling JSX', async function () { await bundle( path.join(__dirname, '/integration/typescript-jsx/index.tsx'), {config}, @@ -158,7 +158,7 @@ describe('typescript', function() { assert(file.includes('React.createElement("div"')); }); - it('should use esModuleInterop by default', async function() { + it('should use esModuleInterop by default', async function () { let b = await bundle( path.join(__dirname, '/integration/typescript-interop/index.ts'), {config}, @@ -176,7 +176,7 @@ describe('typescript', function() { assert.equal(output.test(), 'test passed'); }); - it('fs.readFileSync should inline a file as a string', async function() { + it('fs.readFileSync should inline a file as a string', async function () { if (config != null) { return; } @@ -193,5 +193,46 @@ describe('typescript', function() { fromTsx: text, }); }); + + it('should handle legacy cast in .ts file', async function () { + if (config != null) { + return; + } + await bundle( + path.join(__dirname, '/integration/typescript-legacy-cast/index.ts'), + {config}, + ); + }); + + it('should handle compile enums correctly', async function () { + if (config != null) { + return; + } + let b = await bundle( + path.join(__dirname, '/integration/typescript-enum/index.ts'), + {config}, + ); + + let output = await run(b); + + assert.deepEqual(output, { + A: { + X: 'X', + Y: 'Y', + }, + B: { + X: 'X', + Y: 'Y', + }, + C: { + X: 'X', + Y: 'Y', + }, + z: { + a: 'X', + c: 'Y', + }, + }); + }); } }); diff --git a/packages/core/integration-tests/test/vue.js b/packages/core/integration-tests/test/vue.js index f55b0b82376..e6ad047f26e 100644 --- a/packages/core/integration-tests/test/vue.js +++ b/packages/core/integration-tests/test/vue.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, run, outputFS, distDir} from '@parcel/test-utils'; -describe('vue', function() { - it('should produce a basic vue bundle', async function() { +describe('vue', function () { + it('should produce a basic vue bundle', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-basic/Basic.vue'), ); @@ -11,7 +11,7 @@ describe('vue', function() { assert.equal(typeof output.render, 'function'); assert.deepEqual(output.data(), {msg: 'Hello from Component A!'}); }); - it('should produce a vue bundle with dependencies', async function() { + it('should produce a vue bundle with dependencies', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-dependencies/App.vue'), ); @@ -19,7 +19,7 @@ describe('vue', function() { assert.equal(typeof output.render, 'function'); assert.deepEqual(output.data(), {msg: 'Welcome to Your Vue.js App!'}); }); - it('should produce a vue bundle using preprocessors', async function() { + it('should produce a vue bundle using preprocessors', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-preprocessors/pre-processors.vue'), ); @@ -34,7 +34,7 @@ describe('vue', function() { assert(contents.includes('background: red')); assert(contents.includes('color: green')); }); - it('should produce a vue bundle using a functional component', async function() { + it('should produce a vue bundle using a functional component', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-functional/functional.vue'), ); @@ -49,7 +49,7 @@ describe('vue', function() { ); assert(contents.includes('.' + modules.$style.red)); }); - it('should produce a vue bundle using scoped styles', async function() { + it('should produce a vue bundle using scoped styles', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-scoped/App.vue'), ); @@ -63,7 +63,7 @@ describe('vue', function() { ); assert(contents.includes(`.test[${output.__scopeId}]`)); }); - it('should produce a vue bundle using CSS modules', async function() { + it('should produce a vue bundle using CSS modules', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-css-modules/App.vue'), ); @@ -77,7 +77,7 @@ describe('vue', function() { ); assert(contents.includes('.' + modules.$style.red)); }); - it('should bundle nested components dynamically', async function() { + it('should bundle nested components dynamically', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-nested-components/testcomp.vue'), ); @@ -85,7 +85,7 @@ describe('vue', function() { assert.equal(typeof output.render, 'function'); assert.equal(typeof output.components.InsideComp, 'function'); }); - it('should apply custom block preprocessors', async function() { + it('should apply custom block preprocessors', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-custom-blocks/App.vue'), ); @@ -97,7 +97,7 @@ describe('vue', function() { brief: '\nHome Page\n', }); }); - it('should produce a basic production vue bundle', async function() { + it('should produce a basic production vue bundle', async function () { let b = await bundle( path.join(__dirname, '/integration/vue-basic/Basic.vue'), ); @@ -105,4 +105,19 @@ describe('vue', function() { assert.equal(typeof output.render, 'function'); assert.deepEqual(output.data(), {msg: 'Hello from Component A!'}); }); + it('should load external templates/styles/scripts properly', async function () { + let b = await bundle( + path.join(__dirname, '/integration/vue-external-files/App.vue'), + ); + let output = (await run(b)).default; + assert.equal(typeof output.render, 'function'); + assert.deepEqual(output.data(), {msg: 'Hello World'}); + let contents = await outputFS.readFile( + path.join(distDir, 'App.css'), + 'utf8', + ); + assert(contents.includes('color: #c0ff33')); + assert(contents.includes('h2:hover')); + assert(contents.includes('.box p')); + }); }); diff --git a/packages/core/integration-tests/test/wasm.js b/packages/core/integration-tests/test/wasm.js index a26bbc37adb..e105baa87a3 100644 --- a/packages/core/integration-tests/test/wasm.js +++ b/packages/core/integration-tests/test/wasm.js @@ -2,14 +2,14 @@ import assert from 'assert'; import path from 'path'; import {bundle, run, assertBundleTree, deferred} from '@parcel/test-utils'; -describe.skip('wasm', function() { +describe.skip('wasm', function () { if (typeof WebAssembly === 'undefined') { return; } for (const target of ['browser', 'node']) { - describe(`--target=${target}`, function() { - it('should preload a wasm file for a sync require', async function() { + describe(`--target=${target}`, function () { + it('should preload a wasm file for a sync require', async function () { let b = await bundle( path.join(__dirname, '/integration/wasm-sync/index.js'), { @@ -42,7 +42,7 @@ describe.skip('wasm', function() { assert.equal(await promise, 5); }); - it('should load a wasm file asynchronously with dynamic import', async function() { + it('should load a wasm file asynchronously with dynamic import', async function () { let b = await bundle( path.join(__dirname, '/integration/wasm-async/index.js'), { @@ -74,7 +74,7 @@ describe.skip('wasm', function() { assert.equal(await res, 5); }); - it('should load a wasm file in parallel with a dynamic JS import', async function() { + it('should load a wasm file in parallel with a dynamic JS import', async function () { let b = await bundle( path.join(__dirname, '/integration/wasm-dynamic/index.js'), { diff --git a/packages/core/integration-tests/test/watcher.js b/packages/core/integration-tests/test/watcher.js index a0675d4629b..2dccb2f24b8 100644 --- a/packages/core/integration-tests/test/watcher.js +++ b/packages/core/integration-tests/test/watcher.js @@ -20,7 +20,7 @@ import {symlinkSync} from 'fs'; const inputDir = path.join(__dirname, '/watcher'); const distDir = path.join(inputDir, 'dist'); -describe('watcher', function() { +describe('watcher', function () { let subscription; afterEach(async () => { if (subscription) { @@ -29,7 +29,7 @@ describe('watcher', function() { subscription = null; }); - it('should rebuild on source file change', async function() { + it('should rebuild on source file change', async function () { await outputFS.mkdirp(inputDir); await outputFS.writeFile( path.join(inputDir, '/index.js'), @@ -74,7 +74,7 @@ describe('watcher', function() { assert.equal(output, 'hello'); }); - it('should rebuild on a config file change', async function() { + it('should rebuild on a config file change', async function () { let inDir = path.join(__dirname, 'integration/parcelrc-custom'); let outDir = path.join(inDir, 'dist'); @@ -106,7 +106,7 @@ describe('watcher', function() { assert(distFile.includes('TRANSFORMED CODE')); }); - it('should rebuild properly when a dependency is removed', async function() { + it('should rebuild properly when a dependency is removed', async function () { await ncp(path.join(__dirname, 'integration/babel-default'), inputDir); let b = bundler(path.join(inputDir, 'index.js'), { @@ -137,7 +137,7 @@ describe('watcher', function() { assert(!distFile.includes('Foo')); }); - it.skip('should re-generate bundle tree when files change', async function() { + it.skip('should re-generate bundle tree when files change', async function () { await ncp(path.join(__dirname, '/integration/dynamic-hoist'), inputDir); let b = bundler(path.join(inputDir, '/index.js'), {watch: true}); @@ -215,7 +215,7 @@ describe('watcher', function() { assert.equal(await output(), 8); }); - it.skip('should only re-package bundles that changed', async function() { + it.skip('should only re-package bundles that changed', async function () { await ncp(path.join(__dirname, '/integration/dynamic-hoist'), inputDir); let b = bundler(path.join(inputDir, '/index.js'), {watch: true}); @@ -244,7 +244,7 @@ describe('watcher', function() { assert.notEqual(mtimes[mtimes.length - 1], newMtimes[newMtimes.length - 1]); }); - it.skip('should unload assets that are orphaned', async function() { + it.skip('should unload assets that are orphaned', async function () { await ncp(path.join(__dirname, '/integration/dynamic-hoist'), inputDir); let b = bundler(path.join(inputDir, '/index.js'), {watch: true}); @@ -330,7 +330,7 @@ describe('watcher', function() { assert(!b.loadedAssets.has(path.join(inputDir, 'common-dep.js'))); }); - it.skip('should recompile all assets when a config file changes', async function() { + it.skip('should recompile all assets when a config file changes', async function () { await ncp(path.join(__dirname, '/integration/babel'), inputDir); let b = bundler(path.join(inputDir, 'index.js'), {watch: true}); @@ -357,7 +357,7 @@ describe('watcher', function() { assert(file.includes('function Bar')); }); - it.skip('should rebuild if the file behind a symlink changes', async function() { + it.skip('should rebuild if the file behind a symlink changes', async function () { await ncp( path.join(__dirname, '/integration/commonjs-with-symlinks/'), inputDir, @@ -446,7 +446,7 @@ describe('watcher', function() { ]); }); - it('should rebuild if a missing file is added', async function() { + it('should rebuild if a missing file is added', async function () { await outputFS.mkdirp(inputDir); await outputFS.writeFile( path.join(inputDir, '/index.js'), diff --git a/packages/core/integration-tests/test/webextension.js b/packages/core/integration-tests/test/webextension.js index e405d4c2d07..d308b1c859a 100644 --- a/packages/core/integration-tests/test/webextension.js +++ b/packages/core/integration-tests/test/webextension.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, assertBundles, outputFS} from '@parcel/test-utils'; -describe('webextension', function() { - it('should resolve a full webextension bundle', async function() { +describe('webextension', function () { + it('should resolve a full webextension bundle', async function () { let b = await bundle( path.join(__dirname, '/integration/webextension/manifest.json'), ); @@ -39,7 +39,7 @@ describe('webextension', function() { ]); }); - it('should resolve the web_accessible_resources globs', async function() { + it('should resolve the web_accessible_resources globs', async function () { let b = await bundle( path.join( __dirname, diff --git a/packages/core/integration-tests/test/webmanifest.js b/packages/core/integration-tests/test/webmanifest.js index d3773d891cc..e63cf3918dd 100644 --- a/packages/core/integration-tests/test/webmanifest.js +++ b/packages/core/integration-tests/test/webmanifest.js @@ -3,8 +3,8 @@ import path from 'path'; import {bundle, assertBundles, inputFS, outputFS} from '@parcel/test-utils'; import {md} from '@parcel/diagnostic'; -describe('webmanifest', function() { - it('should support .webmanifest', async function() { +describe('webmanifest', function () { + it('should support .webmanifest', async function () { let b = await bundle( path.join(__dirname, '/integration/webmanifest/index.html'), ); @@ -36,7 +36,7 @@ describe('webmanifest', function() { assert(/icon\.[0-9a-f]+\.png/.test(manifest)); }); - it('should support .json', async function() { + it('should support .json', async function () { let b = await bundle( path.join(__dirname, '/integration/webmanifest-json/index.html'), ); @@ -68,7 +68,7 @@ describe('webmanifest', function() { assert(/icon\.[0-9a-f]+\.png/.test(manifest)); }); - it('should throw on malformed icons and screenshots', async function() { + it('should throw on malformed icons and screenshots', async function () { let manifestPath = path.join( __dirname, '/integration/webmanifest-schema/manifest.webmanifest', @@ -135,7 +135,7 @@ describe('webmanifest', function() { ); }); - it('should throw on missing dependency', async function() { + it('should throw on missing dependency', async function () { let manifestPathRelative = './integration/webmanifest-not-found/manifest.webmanifest'; let manifestPath = path.join(__dirname, manifestPathRelative); @@ -186,7 +186,7 @@ describe('webmanifest', function() { ); }); - it('should work when there is a target in package.json', async function() { + it('should work when there is a target in package.json', async function () { let b = await bundle( path.join(__dirname, '/integration/webmanifest-targets/index.html'), ); diff --git a/packages/core/integration-tests/test/xml.js b/packages/core/integration-tests/test/xml.js new file mode 100644 index 00000000000..b7e98ff4869 --- /dev/null +++ b/packages/core/integration-tests/test/xml.js @@ -0,0 +1,125 @@ +import assert from 'assert'; +import path from 'path'; +import {bundle, assertBundles, outputFS} from '@parcel/test-utils'; + +describe('xml', function () { + it('should transform an atom feed', async function () { + let b = await bundle(path.join(__dirname, '/integration/xml/atom.xml'), { + defaultTargetOptions: { + publicUrl: 'http://example.org/', + }, + }); + + assertBundles(b, [ + { + type: 'png', + assets: ['100x100.png'], + }, + { + type: 'xhtml', + assets: ['atom.xml'], + }, + { + name: 'post.html', + assets: ['post.html'], + }, + { + name: 'atom.xml', + assets: ['atom.xml'], + }, + ]); + + let contents = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert( + contents.includes( + ``, + ), + ); + assert(contents.includes(``)); + }); + + it('should transform an atom feed with namespaced elements', async function () { + let b = await bundle( + path.join(__dirname, '/integration/xml/atom-namespace.xml'), + { + defaultTargetOptions: { + publicUrl: 'http://example.org/', + }, + }, + ); + + assertBundles(b, [ + { + type: 'png', + assets: ['100x100.png'], + }, + { + type: 'xhtml', + assets: ['atom-namespace.xml'], + }, + { + name: 'post.html', + assets: ['post.html'], + }, + { + name: 'atom-namespace.xml', + assets: ['atom-namespace.xml'], + }, + ]); + + let contents = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert( + contents.includes( + ``, + ), + ); + assert( + contents.includes(``), + ); + }); + + it('should transform an rss feed', async function () { + let b = await bundle(path.join(__dirname, '/integration/xml/rss.xml'), { + defaultTargetOptions: { + publicUrl: 'http://example.org/', + }, + }); + + assertBundles(b, [ + { + type: 'png', + assets: ['100x100.png'], + }, + { + type: 'html', + assets: ['rss.xml'], + }, + { + type: 'html', + assets: ['rss.xml'], + }, + { + name: 'post.html', + assets: ['post.html'], + }, + { + name: 'rss.xml', + assets: ['rss.xml'], + }, + ]); + + let contents = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert( + contents.includes( + `<img src="http://example.org/${path.basename( + b.getBundles().find(b => b.type === 'png').filePath, + )}">`, + ), + ); + assert(contents.includes(`http://example.org/post.html`)); + }); +}); diff --git a/packages/core/is-v2-ready-yet/package.json b/packages/core/is-v2-ready-yet/package.json index 9354864e1a7..f6db2097ad4 100644 --- a/packages/core/is-v2-ready-yet/package.json +++ b/packages/core/is-v2-ready-yet/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/is-v2-ready-yet", - "version": "2.0.0-rc.0", + "version": "2.0.1", "private": true, "license": "MIT", "repository": { @@ -13,7 +13,7 @@ "build-app": "yarn parcel build index.html" }, "dependencies": { - "@parcel/integration-tests": "2.0.0-rc.0", + "@parcel/integration-tests": "^2.0.1", "react": "^16.6.3", "react-dom": "^16.6.3", "victory": "^31.0.1" diff --git a/packages/core/logger/package.json b/packages/core/logger/package.json index da260e00365..1de22920df7 100644 --- a/packages/core/logger/package.json +++ b/packages/core/logger/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/logger", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { @@ -20,7 +20,7 @@ "node": ">= 12.0.0" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/events": "2.0.0-rc.0" + "@parcel/diagnostic": "^2.0.1", + "@parcel/events": "^2.0.1" } } diff --git a/packages/core/markdown-ansi/package.json b/packages/core/markdown-ansi/package.json index 5f02214c027..f78299bbdd7 100644 --- a/packages/core/markdown-ansi/package.json +++ b/packages/core/markdown-ansi/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/markdown-ansi", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "publishConfig": { "access": "public" diff --git a/packages/core/package-manager/package.json b/packages/core/package-manager/package.json index d417aad5a4d..84e80253b1e 100644 --- a/packages/core/package-manager/package.json +++ b/packages/core/package-manager/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/package-manager", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { @@ -25,12 +25,12 @@ "check-ts": "tsc --noEmit index.d.ts" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/fs": "2.0.0-rc.0", - "@parcel/logger": "2.0.0-rc.0", - "@parcel/types": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", - "@parcel/workers": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/fs": "^2.0.1", + "@parcel/logger": "^2.0.1", + "@parcel/types": "^2.0.1", + "@parcel/utils": "^2.0.1", + "@parcel/workers": "^2.0.1", "command-exists": "^1.2.6", "cross-spawn": "^6.0.4", "nullthrows": "^1.1.1", @@ -38,6 +38,6 @@ "split2": "^3.1.1" }, "peerDependencies": { - "@parcel/core": "^2.0.0-alpha.3.1" + "@parcel/core": "^2.0.0" } } diff --git a/packages/core/package-manager/src/NodePackageManager.js b/packages/core/package-manager/src/NodePackageManager.js index 97756a20752..cb6273187a4 100644 --- a/packages/core/package-manager/src/NodePackageManager.js +++ b/packages/core/package-manager/src/NodePackageManager.js @@ -18,7 +18,6 @@ import ThrowableDiagnostic, { md, } from '@parcel/diagnostic'; import nativeFS from 'fs'; -// $FlowFixMe this is untyped import Module from 'module'; import path from 'path'; import semver from 'semver'; diff --git a/packages/core/package-manager/src/Npm.js b/packages/core/package-manager/src/Npm.js index 307091b5955..6391ce5f82c 100644 --- a/packages/core/package-manager/src/Npm.js +++ b/packages/core/package-manager/src/Npm.js @@ -2,7 +2,6 @@ import type {PackageInstaller, InstallerOptions} from './types'; -import fs from 'fs'; import path from 'path'; import spawn from 'cross-spawn'; import logger from '@parcel/logger'; @@ -19,6 +18,7 @@ export class Npm implements PackageInstaller { async install({ modules, cwd, + fs, packagePath, saveDev = true, }: InstallerOptions): Promise { diff --git a/packages/core/package-manager/src/Yarn.js b/packages/core/package-manager/src/Yarn.js index b959f9cbb56..24d33e431f8 100644 --- a/packages/core/package-manager/src/Yarn.js +++ b/packages/core/package-manager/src/Yarn.js @@ -4,6 +4,8 @@ import type {PackageInstaller, InstallerOptions} from './types'; import commandExists from 'command-exists'; import spawn from 'cross-spawn'; +import {exec as _exec} from 'child_process'; +import {promisify} from 'util'; import logger from '@parcel/logger'; import split from 'split2'; import JSONParseStream from './JSONParseStream'; @@ -15,6 +17,7 @@ import {npmSpecifierFromModuleRequest} from './utils'; import pkg from '../package.json'; const YARN_CMD = 'yarn'; +const exec = promisify(_exec); type YarnStdOutMessage = | {| @@ -35,6 +38,8 @@ type YarnStdErrMessage = {| |}; let hasYarn: ?boolean; +let yarnVersion: ?number; + export class Yarn implements PackageInstaller { static async exists(): Promise { if (hasYarn != null) { @@ -55,12 +60,20 @@ export class Yarn implements PackageInstaller { cwd, saveDev = true, }: InstallerOptions): Promise { + if (yarnVersion == null) { + let version = await exec('yarn --version'); + yarnVersion = parseInt(version.stdout, 10); + } + let args = ['add', '--json'].concat( modules.map(npmSpecifierFromModuleRequest), ); if (saveDev) { - args.push('-D', '-W'); + args.push('-D'); + if (yarnVersion < 2) { + args.push('-W'); + } } // When Parcel is run by Yarn (e.g. via package.json scripts), several environment variables are diff --git a/packages/core/package-manager/test/NodePackageManager.test.js b/packages/core/package-manager/test/NodePackageManager.test.js index 1e60da9153b..905d2ce50df 100644 --- a/packages/core/package-manager/test/NodePackageManager.test.js +++ b/packages/core/package-manager/test/NodePackageManager.test.js @@ -12,7 +12,7 @@ import {MockPackageInstaller, NodePackageManager} from '../src'; const FIXTURES_DIR = path.join(__dirname, 'fixtures'); -describe('NodePackageManager', function() { +describe('NodePackageManager', function () { let fs; let packageManager; let packageInstaller; diff --git a/packages/core/parcel/README.md b/packages/core/parcel/README.md index 87390c57c37..86b35105722 100644 --- a/packages/core/parcel/README.md +++ b/packages/core/parcel/README.md @@ -1,6 +1,6 @@

- Parcel + Parcel

@@ -8,1538 +8,59 @@ [![Build Status](https://dev.azure.com/devongovett/devongovett/_apis/build/status/parcel-bundler.parcel?branchName=v2)](https://dev.azure.com/devongovett/devongovett/_build/latest?definitionId=1) [![npm package](https://img.shields.io/npm/v/parcel.svg)](https://www.npmjs.com/package/parcel) [![npm package](https://img.shields.io/npm/dm/parcel.svg)](https://www.npmjs.com/package/parcel) +[![Discord](https://img.shields.io/discord/894288336095690753)](https://discord.gg/XSCzqGRuvr) [![Twitter Follow](https://img.shields.io/twitter/follow/parceljs.svg?style=social)](https://twitter.com/parceljs) -## Features - -- 🚀 **Blazing fast** bundle times - multicore compilation, and a filesystem cache for fast rebuilds even after a restart. -- 📦 Out of the box support for JS, CSS, HTML, file assets, and more - **no plugins to install**. -- 🐠 **Automatically transforms modules** using Babel, PostCSS, and PostHTML when needed - even `node_modules`. -- ✂️ Zero configuration **code splitting** using dynamic `import()` statements. -- 🔥 Built in support for **hot module replacement** -- 🚨 Friendly error logging experience - syntax highlighted code frames help pinpoint the problem. - - ---- - -**Below is the design document that was created before work on the implementation of Parcel 2 started and some sections are outdated. The actual (somewhat complete) documentation for Parcel 2 is available here: https://v2.parceljs.org/.** +Parcel is a zero configuration build tool for the web. It combines a great out-of-the-box development experience with a scalable architecture that can take your project from just getting started to massive production application. +## Features ----- +- 😍 **Zero config** – Parcel supports many languages and file types out of the box, from web technologies like HTML, CSS, and JavaScript, to assets like images, fonts, videos, and more. It has a built in dev server with hot reloading, beautiful error diagnostics, and much more. No configuration needed! +- ⚡️ **Lighting fast** – Parcel's JavaScript compiler is written in Rust for native performance. Your code is built in parallel using worker threads, utilizing all of the cores on your machine. Everything is cached, so you never build the same code twice. It's like using watch mode, but even when you restart Parcel! +- 🚀 **Automatic production optimization** – Parcel optimizes your whole app for production automatically. This includes tree-shaking and minifying your JavaScript, CSS, and HTML, resizing and optimizing images, content hashing, automatic code splitting, and much more. +- 🎯 **Ship for any target** – Parcel automatically transforms your code for your target environments. From modern and legacy browser support, to zero config JSX and TypeScript compilation, Parcel makes it easy to build for any target – or many! +- 🌍 **Scalable** – Parcel requires zero configuration to get started. But as your application grows and your build requirements become more complex, it's possible to extend Parcel in just about every way. A simple configuration format and powerful plugin system that's designed from the ground up for performance means Parcel can support projects of any size. ## Getting Started -Before we get started, you'll need to install Node and Yarn (or npm) and create -a `package.json` for your project if you haven't already. - -```sh -yarn init -``` - -Then with Yarn you can install `parcel` into your app: - -```sh -yarn add --dev parcel@next -``` - -From there you just need to point Parcel at some of your entry files. Like if -you're building a website, an `index.html` file: - -```html - - - - - My First Parcel App - - -

Hello, World!

- - -``` - -Now if you just run: +See the following guides in our documentation on how to get started with Parcel. -```sh -yarn parcel index.html -``` - -You should get a URL that looks something like: `http://localhost:1234/`. - -Next you can start adding dependencies by specifying them in your code (however -your language specifies other assets). So for HTML we could create a -`styles.css` file next to our `index.html` file and include it with a `` -tag. - -```css -h1 { - color: hotpink; - font-family: cursive; -} -``` - -```html - - - - - My First Parcel App - - - -

Hello, World!

- - -``` - -If we want parcel to update our changes in the browser without refreshing the page, -we need to add at least a dummy javascript file e.g. `app.js` next to our `index.html`. -This file allows parcel to inject all the necessary code to show your changes. -This file will later contain your javascript application. - -```javascript -console.log("Hello World"); -``` - -```html - - - - - My First Parcel App - - - - -

Hello, World!

- - -``` +* [Building a webapp with Parcel](https://parceljs.org/getting-started/webapp/) +* [Building a library with Parcel](https://parceljs.org/getting-started/library/) +* [Migrating from Parcel v1](https://parceljs.org/getting-started/migration/) ## Documentation - - - - -- [Introduction](#introduction) -- [Parcel CLI](#parcel-cli) - - [CLI Args & Flags](#cli-args--flags) - - [`parcel serve`](#parcel-serve) - - [`parcel watch`](#parcel-watch) - - [`parcel build`](#parcel-build) - - [`[...entries]`](#entries) - - [`--target [name]`](#--target-name) - - [`--open, -o [browser]`](#--open--o-browser) - - [`--host `](#--host-host) - - [`--port , -p`](#--port-port--p) - - [`--https`](#--https) - - [`--cert `](#--cert-path) - - [`--key `](#--key-path) - - [`--dist-dir `](#--dist-dir-dir) - - [`--cache-dir `, `--no-cache`](#--cache-dir-dir---no-cache) - - [`--config `](#--config-path) - - [`--hot`, `--no-hot`](#--hot---no-hot) - - [`--hot-host `](#--hot-host-hostname) - - [`--hot-port `](#--hot-port-port) - - [`--[no-]source-maps`](#--no-source-maps) - - [`--autoinstall [npm/yarn], --no-autoinstall`](#--autoinstall-npmyarn---no-autoinstall) - - [`--log-level `](#--log-level-level) - - [`--version, -v, -V`](#--version--v--v) - - [`--help, -h`](#--help--h) -- [Parcel Config](#parcel-config) - - [Configuring external tools](#configuring-external-tools) - - [Configuring Parcel](#configuring-parcel) - - [`package.json`](#packagejson) - - [`package.json#name`](#packagejsonname) - - [`package.json#version`](#packagejsonversion) - - [`package.json#main`](#packagejsonmain) - - [`package.json#module`](#packagejsonmodule) - - [`package.json#browser`](#packagejsonbrowser) - - [`package.json#source`](#packagejsonsource) - - [`package.json#browserslist`](#packagejsonbrowserslist) - - [`package.json#engines`](#packagejsonengines) - - [`package.json#targets`](#packagejsontargets) - - [`package.json#alias`](#packagejsonalias) - - [`.parcelrc`](#parcelrc) - - [Glob maps in `.parcelrc`](#glob-maps-in-parcelrc) - - [`.parcelrc#extends`](#parcelrcextends) - - [`.parcelrc#resolvers`](#parcelrcresolvers) - - [`.parcelrc#transformers`](#parcelrctransformers) - - [`.parcelrc#bundler`](#parcelrcbundler) - - [`.parcelrc#namers`](#parcelrcnamers) - - [`.parcelrc#runtimes`](#parcelrcruntimes) - - [`.parcelrc#packagers`](#parcelrcpackagers) - - [`.parcelrc#optimizers`](#parcelrcoptimizers) - - [`.parcelrc#reporters`](#parcelrcreporters) - - [`.parcelrc#validators`](#parcelrcvalidators) -- [Parcel Architecture](#parcel-architecture) - - [Phases of Parcel](#phases-of-parcel) - - [Asset Graph](#asset-graph) - - [Bundles](#bundles) - - [Sources](#sources) - - [Targets](#targets) - - [Target Configuration](#target-configuration) - - [Environments](#environments) - - [Caching](#caching) -- [Asset Resolution](#asset-resolution) - - [Local Paths](#local-paths) - - [Package Paths](#package-paths) - - [URLs](#urls) - - [Tilde Paths](#tilde-paths) - - [Aliases](#aliases) -- [Plugins](#plugins) - - [Resolvers](#resolvers) - - [Transformers](#transformers) - - [Bundlers](#bundlers) - - [Namers](#namers) - - [Runtimes](#runtimes) - - [Packagers](#packagers) - - [Optimizers](#optimizers) - - [Reporters](#reporters) - - [Validators](#validators) -- [Creating Plugins](#creating-plugins) - - [Naming](#naming) - - [Versioning](#versioning) - - [Engines](#engines) -- [Plugin APIs](#plugin-apis) - - [Resolvers](#resolvers-1) - - [Transformers](#transformers-1) - - [Bundler](#bundler) - - [Namers](#namers-1) - - [Runtimes](#runtimes-1) - - [Packagers](#packagers-1) - - [Optimizers](#optimizers-1) - - [Reporters](#reporters-1) - - [Validators](#validators-1) - - - -## Introduction - -Parcel is a compiler for all your code, regardless of the language or toolchain. - -Parcel takes all of your files and dependencies, transforms them, and merges -them together into a smaller set of output files that can be used to run your -code. - -Parcel supports many different languages and file types out of the box, from -web technologies like HTML, CSS, and JavaScript, to lower level languages like -Rust, and anything that compiles to WebAssembly (WASM), to assets like images, -fonts, videos, and more. - -Parcel makes your code portable. You can build your code for different -environments, for the web for your server, or for an app. You can even build -multiple targets at once and have them live update as you make changes. - -Parcel is fast and predictable. It compiles all of your files in isolation in -parallel inside workers, caching all of them as it goes along. Caches are -stable across machines and are only affected by the files and configs within -your project (unless you want to pass specific environment variables). - -## Parcel CLI - -The Parcel CLI is built into the main `parcel` package. While you can install -it globally and run it, it is much better to install it locally into your -project as a dev dependency. - -```sh -yarn add --dev parcel@next -``` - -You should also add some "scripts" to your `package.json` to run it easier. - -```json -{ - "name": "my-project", - "scripts": { - "build": "parcel build index.html", - "start": "parcel serve index.html" - }, - "devDependencies": { - "parcel": "latest" - } -} -``` - -Now you can run `yarn build` to bundle your project for production and -`yarn start` to dev on your project. - -### CLI Args & Flags - -Usage: - -```sh -$ parcel [command] [...entries] [...flags] -``` - -#### `parcel serve` - -Serve assets on a local server. - -#### `parcel watch` - -Watch and rebuild code on file changes. - -#### `parcel build` - -Build code once, in production mode. - -#### `[...entries]` - -Entry files to start bundling, these will be preserved as entry points in the -output. Defaults to `package.json#source`, falling back to `src/index.*` or -`index.*`. See [#Sources](#sources). - -#### `--target [name]` - -Specifies a specific target to build. If unspecified, Parcel builds all -targets specified in package.json. See [#Targets](#targets). - -#### `--open, -o [browser]` - -Open your local server in a browser. You can optionally pass the name of the -browser you want to open, otherwise it will use your default browser. - -#### `--host ` - -Configure the host to serve assets on. The default is to listen on all interfaces. - -#### `--port , -p` - -Configure the port to serve assets on. Alternatively you can use the `$PORT` -environment variable. - -#### `--https` - -This will generate a local certificate (which will be untrusted by your -browser, you'll need to approve it) and serve your assets over `https://` - -##### `--cert ` - -Specify the filepath to your SSL certificate when using `--https`. - -##### `--key ` - -Specify the filepath to your SSL key when using `--https`. - -#### `--dist-dir ` - -Configure the directory where compiled assets are output. Default is `./dist`. - -#### `--cache-dir `, `--no-cache` - -Configure the cache directory with `--cache ` or disable it altogether -with `--no-cache`. - -#### `--config ` -specify which config to use. can be a path or a package name. -`--config ../.myparcelrc` or `--config @parcel/config-default` - -#### `--hot`, `--no-hot` - -Turn hot reloading on or off. - -##### `--hot-host ` - -Configure the hot reloading hostname. - -##### `--hot-port ` - -Configure the hot reloading port. - -#### `--[no-]source-maps` - -Turn source maps on or off. Source maps are turned on by default. - -#### `--autoinstall [npm/yarn], --no-autoinstall` - -When enabled, whenever Parcel discovers a dependency that isn't installed it -will attempt to install it with either npm or Yarn (defaults to npm unless a -`yarn.lock` exists). - -#### `--log-level ` - -Set the log level, either either "none", "error", "warn", "info", or "verbose". -The default is "info". - -#### `--version, -v, -V` - -Return the current version of Parcel. - -#### `--help, -h` - -Get help with the CLI. - -## Parcel Config - -Parcel has always and will always work out of the box for many projects with -zero configuration. It should always be extremely simple to get started. But if -you do want more control, we give you the tools to do so. - -### Configuring external tools - -A huge part of what Parcel does is run other tools over your code. Instead of -pulling all that configuration into Parcel, we make use of their own -configuration systems. So if you're using Babel, you should just use `.babelrc` -files to configure it. - -When we do need to introduce config, we create tool specific config files in -order to do so. - -### Configuring Parcel - -When you do need to configure Parcel, it will be in one of 3 places. - -- If you need to configure the CLI, it will be a CLI flag -- If you need to configure your package, it will be in the `package.json` -- If you need to configure something with your files or the Parcel asset - pipeline, it will be in `.parcelrc` - -### `package.json` - -[todo] - -```json -{ - "name": "foo", - "main": "dist/main/index.js", - "module": "dist/module/index.js", - "browser": "dist/browser/index.js", - "browserslist": ["> 1%", "not dead"], - "engines": { - "node": ">=4.x" - }, - "source": "src/index.js", - "targets": { - "main": { - "engines": { - "node": ">=4.x" - } - }, - "module": { - "engines": { - "node": ">=8.x" - } - }, - "browser": { - "engines": { - "browsers": ["> 1%", "not dead"] - } - } - }, - "alias": { - "react": "preact-compat", - "react-dom": "preact-compat" - } -} -``` - -#### `package.json#name` - -**(Required)** The name of the package is always required in order to be -considered a valid `package.json`. - -```json -{ - "name": "my-package" -} -``` - -#### `package.json#version` - -**(Required)** All packages inside `node_modules` must have a `package.json#version`. - -```json -{ - "version": "1.0.0" -} -``` - -#### `package.json#main` - -This is the "main" target's entry point for the package, by default in library mode (doesn't bundle dependencies). - -```json -{ - "main": "dist/main/index.js" -} -``` - -See [Targets](#targets) - -#### `package.json#module` - -This is the "module" target's entry point for the package, by default in library mode (doesn't bundle dependencies). - -```json -{ - "module": "dist/module/index.js" -} -``` - -See [Targets](#targets) - -#### `package.json#browser` - -This is the "browser" target's entry point for the package, by default in library mode (doesn't bundle dependencies). - -```json -{ - "browser": "dist/browser/index.js" -} -``` - -See [Targets](#targets) - -#### `package.json#source` - -Specify the entry points for your source code which gets mapped to your -targets. - -```json -{ - "source": "src/index.js", - "source": ["src/index.js", "src/index.html"] -} -``` - -See [Sources](#sources) - -#### `package.json#browserslist` - -As specified by Browserslist, this field is for specifying which transformers -should be applied to browser bundles. - -```json -{ - "browserslist": ["> 0.2%", "not dead"] -} -``` - -See [Environments](#environments) - -#### `package.json#engines` - -Specify what versions of what engines you want to support. - -```json -{ - "engines": { - "node": ">=4.x", - "electron": ">=2.x" - } -} -``` - -See [Environments](#environments) - -#### `package.json#targets` - -Configuration for individual targets. - -```json -{ - "targets": { - "main": { - "engines": { - "node": ">=4.x", - "electron": ">=2.x" - }, - }, - "browser": { - "engines": { - "browsers": ["> 1%", "not dead"] - } - } - } -} -``` - -See [Targets](#targets) - -#### `package.json#alias` - -Aliases asset names/paths to other assets. - -```json -{ - "alias": { - "react": "preact-compat", - "react-dom": "preact-compat" - } -} -``` - -See [Aliases](#aliases) - -### `.parcelrc` - -Your `.parcelrc` file will likely contain just a few fields (if you have one at -all), but here's an example of a `.parcelrc` file that contains every field: - -```json -{ - "extends": ["@parcel/config-default"], - "resolvers": ["@parcel/resolver-default"], - "transformers": { - "*.vue": ["@parcel/transformer-vue"], - "*.scss": ["@parcel/transformer-sass"], - "*.js": ["@parcel/transformer-babel"], - "*.css": ["@parcel/transformer-postcss"], - "*.html": ["@parcel/transformer-posthtml"] - }, - "bundler": "@parcel/bundler-default", - "namers": ["@parcel/namer-default"], - "runtimes": ["@parcel/runtime-js", "@parcel/runtime-browser-hmr"], - "packagers": { - "*.js": "@parcel/packager-js", - "*.css": "@parcel/packager-css", - "*.html": "@parcel/packager-html", - "*.wasm": "@parcel/packager-wasm", - "*.raw": "@parcel/packager-raw" - }, - "optimizers": { - "*.js": ["@parcel/optimizer-uglify"], - "*.css": ["@parcel/optimizer-cssnano"], - "*.html": ["@parcel/optimizer-htmlnano"], - "*.{png,jpg,jpeg,svg,...}": ["@parcel/optimizer-imagemin"] - }, - "reporters": ["@parcel/reporter-cli"] -} -``` - -#### Glob maps in `.parcelrc` - -Many config properties like `transformers` or `packagers` use objects as maps of -globs to package names. While objects in JSON are technically unordered, Parcel -does use the order to give globs priority when a file name is being tested -against them. - -```json -{ - "transformers": { - "icons/*.svg": ["highest-priority"], - "*.svg": ["lowest-priority"] - } -} -``` - -Here if we are trying to find a transform for the file `icons/home.svg`, we'll -work our way down the globs until we find a match, which would be -`icons/*.svg`, we never reach `*.svg`. - -#### `.parcelrc#extends` - -`extends` can either be a string or an array of strings that specify base -configs to extend. That base configuration can be the path to another -`.parcelrc` file or the name of a Parcel config package. - -```json -{ - "extends": "@parcel/config-default", - "extends": "../.parcelrc", - "extends": ["@parcel/config-default", "@company/parcel-config"] -} -``` - -When extending a config, Parcel does a shallow merge of the two configs. - -#### `.parcelrc#resolvers` - -`resolvers` is an array of strings that specifies the name of a Parcel resolver -package. - -```json -{ - "resolvers": ["@parcel/resolver-default"] -} -``` - -See [Resolvers](#resolvers) - -#### `.parcelrc#transformers` - -`transformers` is an object map of globs to arrays of Parcel transform packages. - -```json -{ - "transformers": { - "*.js": ["@parcel/transformer-babel"] - } -} -``` - -See [Transformers](#transformers) - -#### `.parcelrc#bundler` - -`bundler` is a string that specifies the name of a Parcel bundler package. - -```json -{ - "bundler": "@parcel/bundler-default" -} -``` - -See [Bundlers](#bundlers) - -#### `.parcelrc#namers` - -`namers` is an array of Parcel namer packages. - -```json -{ - "namers": ["@parcel/namer-default"] -} -``` - -See [Namers](#namers) - -#### `.parcelrc#runtimes` - -`runtimes` is an array of Parcel runtime packages. - -```json -{ - "runtimes": ["@parcel/runtime-js", "@parcel/runtime-browser-hmr"], -} -``` - -See [Runtimes](#runtimes) - -#### `.parcelrc#packagers` - -`packagers` is an object map of globs to Parcel packager packages. - -```json -{ - "packagers": { - "*.js": ["@parcel/packager-js"] - } -} -``` - -See [Packagers](#packagers) - -#### `.parcelrc#optimizers` - -`optimizers` is an object map of globs to arrays of Parcel optimizer packages. - -```json -{ - "optimizers": { - "*.js": ["@parcel/optimizer-uglify"] - } -} -``` - -See [Optimizers](#optimizers) - -#### `.parcelrc#reporters` - -`reporters` is an array of Parcel reporter packages. - -```json -{ - "reporters": ["@parcel/reporter-detailed"] -} -``` - -See [Reporters](#reporters). - -#### `.parcelrc#validators` - -`validators` is an object map of globs to arrays of Parcel validator packages. - -```json - - "validators": { - "*.ts": ["@parcel/validator-typescript"] - } -} -``` - -See [Validators](#validators). - -## Parcel Architecture - -Even if you aren't doing anything that complex, if you are going to use Parcel -a lot it makes sense to take some time and understand how it works. - -### Phases of Parcel - -At a high level Parcel runs through several phases: - -- Resolving -- Transforming -- Bundling -- Packaging -- Optimizing -- (Validating) - -The **resolving** and **transforming** phases work together in parallel to -build a graph of all your assets. - -This asset graph gets translated into bundles in the **bundling** phase. - -Then the **packaging** phase takes the assets in the calculated bundles and -merges them together into files each containing an entire bundle. - -Finally, in the **optimizing** phase, Parcel takes these bundles files and runs -them through optimizing transforms. - -### Asset Graph - -During the resolving and transforming phases, Parcel discovers all the assets -in your app or program. Every asset can have its own dependencies on other -assets which Parcel will pull in. - -The data structure that represents all of these assets and their dependencies -on one another is known as "The Asset Graph". - -| Asset Name | Dependencies | -| ------------ | ------------------- | -| `index.html` | `app.css`, `app.js` | -| `app.css` | N/A | -| `app.js` | `navbar.js` | -| `navbar.js` | etc. | - -### Bundles - -Once Parcel has built the entire Asset Graph, it begins turning it into -"bundles". These bundles are groupings of assets that get placed together in a -single file. - -Bundles will (generally) contain only assets in the same language: - -| Bundle Name | Assets | -| ------------ | --------------------------- | -| `index.html` | `index.html` | -| `app.css` | `app.css` | -| `app.js` | `app.js`, `navbar.js`, etc. | - -Some assets are considered "entry" points into your app, and will stay as -separate bundles. For example, if your `index.html` file links to an -`about.html` file, they won't be merged together. - -| Bundle Name | Assets | Entry URL | -| ------------ | ------------ | --------- | -| `index.html` | `index.html` | `/` | -| `about.html` | `about.html` | `/about` | - -### Sources - -"Sources" are the files that contain the source code to your app before being -compiled by Parcel. - -Parcel discovers these sources by following their dependencies on one another -starting at your "entries". - -These entries will be one of: - -1. `$ parcel <...entries>` -2. `~/package.json#source` -3. `./src/index.*` -4. `./index.*` - -From there, everything those assets depend on will be considered a "source" in -Parcel. - -### Targets - -When Parcel runs, it can build your asset graph in multiple different ways -simultaneously. These are called "targets". - -For example, you could have a "modern" target that _targets_ newer browsers -and a "legacy" target for older browsers. - -Sources get mapped to targets, - -#### Target Configuration - -In the most explicit form, targets are configured via the -`package.json#targets` field. - -```js -{ - "app": "dist/browser/index.js", - "appModern": "dist/browserModern/index.js", - "targets": { - "app": { /* target env */ }, - "appModern": { /* target env */ } - } -} -``` - -Each target has a name which corresponds to a top-level `package.json` field -such as `package.json#main` or `package.json#browser` which specify the primary -entry point for that target. - -Inside each of those targets contains the target's environment configuration: - -| Option | Possible values | Description | -| -------------------- | --------------- | ----------- | -| `context` | `'node' \| 'browser' \| 'web-worker' \| 'electron-main' \| 'electron-renderer'` | Where the bundle should run | -| `includeNodeModules` | `boolean \| [String]` | Whether to bundle all/none/some `node_module` dependency | -| `outputFormat` | `'global' \| 'esmodule' \| 'commonjs'` | Which type of imports/exports should be emitted| -| `publicUrl` | `string` | The public url of the bundle at runtime | -| `isLibrary` | `boolean` | Library as in 'npm library' | -| `sourceMap` | `boolean \| {inlineSources?: boolean, sourceRoot?: string, inline?: boolean}` | Enable/disable sourcemap and set options -| `engines` | Engines | Same as `package.json#engines` | - - -However, a lot of the normal configuration you might want will already have -defaults provided for you: - -```cs -targets = { - main: { - engines: { - node: value("package.json#engines.node"), - browsers: unless exists("package.json#browser") then value("package.json#browserlist") - }, - isLibrary: true - }, - module: { - engines: { - node: value("package.json#engines.node"), - browsers: unless exists("package.json#browser") then value("package.json#browserlist") - }, - isLibrary: true - }, - browser: { - engines: { - browsers: value("package.json#browserslist") - }, - isLibrary: true - }, - ...value("package.json#targets"), -} -``` - -### Environments - -Environments tell Parcel how to transform and bundle each asset. They tell -Parcel if an asset is going to be run in a browser or in NodeJS/Electron. - -They also tell Parcel's transform plugins how they should run. They tell -[Babel](http://babeljs.io/docs/en/babel-preset-env#targetsbrowsers) or -[Autoprefixer](https://github.com/postcss/autoprefixer#browsers) what browsers -your asset is targetting. - -You can configure environments through your targets. - -```json -{ - "targets": { - "main": { - "engines": { - "node": ">=4.x", - "electron": ">=2.x", - "browsers": ["> 1%", "not dead"] - } - } - } -} -``` - -When one asset depends on another, the environment is inherited from its -parent. But how you depend on the asset can change some properties of that -environment. - -For example: - -```js -navigator.serviceWorker.register('./service-worker.js'); -``` - -```js -let childEnvironment = {...parentEnvironment, browserContext: 'service-worker'}; -``` - -### Caching - -Parcel will create a `/.parcel-cache` directory. It will be filled with -directories with two letters, which are the start of a hash which is finished -by the names of the JSON files inside. - -``` -/.parcel-cache - /00/ - 213debd8ddd45819b79a3a974ed487.json - 40ae9b581afc53841307a4b3c2463d.json - 63a9dd58fc1e8f8bb819759ea9793c.json - ... - /01/ - /../ - /zy/ - /zz/ -``` - -It follows this weird structure in order to avoid too many files being created -in a single directory, which degrades file system performance. - -## Asset Resolution - -Parcel follows the Node module resolution algorithm with a few additions. - -### Local Paths - -``` -./path/to/file -./path/to/file.js -``` - -These follow the [Node module resolution algorithm](https://nodejs.org/api/modules.html#modules_all_together). - -### Package Paths - -``` -preact -lodash/cloneDeep -@sindresorhus/is -``` - -These follow the [Node module resolution algorithm](https://nodejs.org/api/modules.html#modules_all_together). - -### URLs - -``` -https://unpkg.com/preact@8.2.9/dist/preact.min.js -``` - -Parcel by default will ignore URL dependencies, other resolver plugins may -choose to do something with them. - -### Tilde Paths - -``` -~/src/file.js -``` - -Only when used outside of `node_modules` directories, the `~` is replaced by an -absolute path to the closest package root: - -```sh -/path/to/app #(/package.json) -``` - -To form a path that looks like: - -``` -/path/to/app/src/file.js -``` - -Then it follows the [Node module resolution algorithm](https://nodejs.org/api/modules.html#modules_all_together). - -### Aliases - -Aliases come in two forms: - -1. Package Aliases: `react -> preact` -2. File/Directory Aliases: `utils` -> `./src/utils` - -```json -{ - "name": "my-project", - "alias": { - "react": "preact-compat", - "react-dom": "preact-compat", - "utils": "./src/utils", - "components": "./src/components" - } -} -``` - -There are a couple of rules: - -1. Aliases will only be respected when specified outside of `node_modules`. -2. Aliases specified outside of `node_modules` will affect assets inside of `node_modules`. -3. Aliases cannot build off of other aliases. -4. Only one alias will be applied at a time. -5. Aliases must be valid npm package names. - -## Plugins - -### Resolvers - -When one asset depends on another through an asset specifier, the resolver is -responsible for determining what asset is being requested. - -See [Asset Resolution](#asset-resolution) for more details. - -```json -{ - "resolvers": ["@parcel/resolver-v1"] -} -``` - -**Official Resolvers:** - -- `@parcel/resolver-v1` - -### Transformers - -transformers _transform_ single assets as they are discovered and added to the -asset graph. They mostly call out to different compilers and preprocessors. - -```json -{ - "transformers": { - "*.js": ["@parcel/transformer-babel"] - } -} -``` - -**Official Transformers:** - -- `@parcel/transformer-babel` -- `@parcel/transformer-coffeescript` -- `@parcel/transformer-glsl` -- `@parcel/transformer-graphql` -- `@parcel/transformer-json` -- `@parcel/transformer-json5` -- `@parcel/transformer-less` -- `@parcel/transformer-posthtml` -- `@parcel/transformer-postcss` -- `@parcel/transformer-pug` -- `@parcel/transformer-raw` -- `@parcel/transformer-reason` -- `@parcel/transformer-rust` -- `@parcel/transformer-stylus` -- `@parcel/transformer-toml` -- `@parcel/transformer-typescript` -- `@parcel/transformer-vue` -- `@parcel/transformer-wasm` -- `@parcel/transformer-webmanifest` -- `@parcel/transformer-yaml` -- `@parcel/transformer-elm` -- ... - -### Bundlers - -Bundlers accept the entire asset graph and turn it into sets of bundles. - -```json -{ - "bundler": "@parcel/bundler-default" -} -``` - -**Official Bundlers:** - -- `@parcel/bundler-default` - -### Namers - -Namers accept a bundle and return a filename for that bundle. - -```json -{ - "namers": ["@parcel/namer-default"] -} -``` - -**Official Namers:** - -- `@parcel/namer-default` - -### Runtimes - -Runtimes get called after the bundler phase and generate an asset which gets -included in the final bundle. - -```json -{ - "runtimes": ["@parcel/runtime-js", "@parcel/runtime-browser-hmr"] -} -``` - -**Official Runtimes:** - -- `@parcel/runtime-js` -- `@parcel/runtime-hmr` - -### Packagers - -Packagers determine how to merge different asset types into a single bundle. - -```json -{ - "packagers": { - "*.css": "@parcel/packager-css" - } -} -``` - -**Official Packagers:** - -- `@parcel/packager-html` -- `@parcel/packager-js` -- `@parcel/packager-css` -- `@parcel/packager-wasm` -- `@parcel/packager-raw` - -### Optimizers - -Optimizers are similar to transformers, but they accept a bundle instead -of a single asset. - -```json -{ - "optimizers": { - "*.js": ["@parcel/optimizer-terser"], - "*.css": ["@parcel/optimizer-csso"] - } -} -``` - -**Official Optimizers:** - -- `@parcel/packager-terser` -- `@parcel/packager-csso` -- [todo] - -### Reporters - -Reporters receive events as they happen and can either use the Parcel logger to -output to stdout/stderr or they can return assets to be generated on the file -system. - -```json -{ - "reporters": ["@parcel/reporter-cli", "@parcel/reporter-dev-server"] -} -``` - -**Official Reporters:** - -- `@parcel/reporter-cli` -- `@parcel/reporter-dev-server` -- [todo] - -### Validators - -Validators emit errors for source code after a build is completed. -For example, type checking and linting. - -```json -{ - "validators": { - "*.ts": ["@parcel/validator-typescript"] - } -} -``` - -**Official Validators:** - -- `@parcel/validator-typescript` -- `@parcel/validator-eslint` -- [todo] - -## Creating Plugins - -### Naming - -All plugins must follow a naming system: - -| | Official package | Community packages | Private company/scoped team packages | -| ---------- | -------------------------- | ------------------------- | ------------------------------------ | -| Configs | `@parcel/config-{name}` | `parcel-config-{name}` | `@scope/parcel-config[-{name}]` | -| Resolvers | `@parcel/resolver-{name}` | `parcel-resolver-{name}` | `@scope/parcel-resolver[-{name}]` | -| Transformers | `@parcel/transformer-{name}` | `parcel-transformer-{name}` | `@scope/parcel-transformer[-{name}]` | -| Bundlers | `@parcel/bundler-{name}` | `parcel-bundler-{name}` | `@scope/parcel-bundler[-{name}]` | -| Namers | `@parcel/namer-{name}` | `parcel-namer-{name}` | `@scope/parcel-namer[-{name}]` | -| Runtimes | `@parcel/runtime-{name}` | `parcel-runtime-{name}` | `@scope/parcel-runtime[-{name}]` | -| Packagers | `@parcel/packager-{name}` | `parcel-packager-{name}` | `@scope/parcel-packager[-{name}]` | -| Optimizers | `@parcel/optimizer-{name}` | `parcel-optimizer-{name}` | `@scope/parcel-optimizer[-{name}]` | -| Reporters | `@parcel/reporter-{name}` | `parcel-reporter-{name}` | `@scope/parcel-reporter[-{name}]` | -| Validators | `@parcel/validator-{name}` | `parcel-validator-{name}`| `@scope/parcel-validator[-{name}]` | - -The `{name}` must be descriptive and directly related to the purpose of the -package. Someone should be able to have an idea of what the package does simply -by reading the name in a `.parcelrc` or `package.json#devDependencies`. - -``` -parcel-transformer-posthtml -parcel-packager-wasm -parcel-reporter-graph-visualizer -``` - -If your plugin adds support for a specific tool, please use the name of the -tool. - -``` -parcel-transformer-es6 (bad) -parcel-transformer-babel (good) -``` - -If your plugin is a reimplementation of something that exists, try naming it -something that explains why it is a separate: - -``` -parcel-transformer-better-typescript (bad) -parcel-transformer-typescript-server (good) -``` - -We ask that community members work together and when forks happen to try and -resolve them. If someone made a better version of your plugin, please consider -giving the better package name over, have them make a major version bump, and -redirect people to the new tool. - -### Versioning - -You must follow semantic versioning (to the best of your ability). No, it's not -the perfect system, but it's the best one we have and people do depend on it. - -If plugin authors intentionally don't follow semantic versioning, Parcel may -start warning users that they should be locking down the version number for -your plugin. - -> Warning: The plugin "parcel-transform-typescript" does not follow semantic -> versioning. You should lock the version range down so your code does not -> break when they make changes. Please upvote this issue to encourage them to -> follow semver: https://github.com/user/parcel-transform-typescript/issues/43 - -### Engines - -You must specify a `package.json#engines.parcel` field with the version range -of Parcel that your plugin supports: - -```json -{ - "name": "parcel-transform-imagemin", - "engines": { - "parcel": "2.x" - } -} -``` - -If you do not specify this field, Parcel will output a warning: - -``` -Warning: The plugin "parcel-transform-typescript" needs to specify a `package.json#engines.parcel` field with the supported Parcel version range. -``` - -If you do specify the parcel engine field and the user is using an incompatible -version of Parcel, they will see an error: - -``` -Error: The plugin "parcel-transform-typescript" is not compatible with the -current version of Parcel. Requires "2.x" but the current version is "3.1.4" -``` - -Parcel uses node-semver to match version ranges. - -## Plugin APIs - -There are several different types of plugins. They all look very similar, but -are kept separate so we can have strict contracts one what each one is allowed -to do. - -There are some rules that should be followed across every type of plugin: - -- **Stateless** — Avoid any kind of state, it will likely be the source of bugs - for your users. For example, the same transform may exist in multiple - separate workers which are not allowed to communicate with one another, state - will not work as expected. -- **Pure** — Given the same input, a plugin must produce the same output, and - you must not have any observable side effects, or implicit dependencies. - Otherwise Parcel's caching will break and your users will be sad. You should - never have to tell users to delete their caches. - -The plugin APIs all follow a common shape: - -```js -import {NameOfPluginType} from '@parcel/plugin'; - -export default new NameOfPluginType({ - async methodName(opts: JSONObject): Promise { - return result; - } -}); -``` - -They are made up of modules with well-known named exports of async functions -that: - -- Accept a strictly validated JSON-serializable `opts` object. -- Return a strictly validated JSON-serializable `vals` object. - -If something you need is not being passed through `opts`, please come talk to -the Parcel team about it. Avoid trying to get information yourself from other -sources, especially from the file system. - -### Resolvers - -Resolvers get called with an asset request (consisting of a source file path -and the specifier of what is being requested) which it then attempts to -resolve. If the resolver isn't sure how to handle a request, it can also return -`null` and pass it to the next resolver in the chain. - -```js -import {Resolver} from '@parcel/plugin'; - -export default new Resolver({ - async resolve({dependency}) { - // ... - return {filePath} || null; - } -}); -``` - -### Transformers - -Transformers _transform_ single assets as they are discovered and added to the -asset graph. They mostly call out to different compilers and preprocessors. - -```js -import {Transform} from '@parcel/plugin'; - -export default new Transform({ - async parse({asset}) { - // ... - return ast; - }, - - async transform({asset}) { - // ... - return [assets]; - }, - - async generate({asset}) { - // ... - return {code, map}; - } -}); -``` - -### Bundler - -Bundlers accept the entire asset graph and modify it to add bundle nodes that group the assets -into output bundles. - -```js -import {Bundler} from '@parcel/plugin'; - -export default new Bundler({ - async bundle({graph}) { - // ... - }, - - async optimize({graph}) { - // ... - } -}); -``` - -### Namers - -Namers accept a bundle and output a filename for that bundle. - -```js -import {Namer} from '@parcel/plugin'; - -export default new Namer({ - async name({bundle, bundleGraph}) { - // ... - return name; - } -}); -``` - -### Runtimes - -Runtimes accept a bundle and return assets to be inserted into that bundle. - -```js -import {Runtime} from '@parcel/runtime'; - -export default new Runtime({ - async apply({bundle, bundleGraph}) { - // ... - return assets; - } -}); -``` - -### Packagers - -Packagers determine how to merge different asset types into a single bundle. - -```js -import {Packager} from '@parcel/plugin'; - -export default new Packager({ - async package({bundle}) { - // ... - return {contents, map}; - }, -}); -``` - -### Optimizers - -Optimizers are similar to transformers, but they accept a bundle instead -of a single asset. - -```js -import {Optimizer} from '@parcel/plugin'; - -export default new Optimizer({ - async optimize({bundle, contents, map}) { - // ... - return {contents, map}; - } -}); -``` - -### Reporters - -Reporters receive events as they happen and can output to stdout/stderr, -or perform other actions. - -```js -import {Reporter} from '@parcel/plugin'; +Read the docs at https://parceljs.org/docs/. -export default new Reporter({ - async report({ event: { type, ... } }) { - // ... - } -}); -``` +## Community -### Validators +- ❓ Ask questions on [GitHub Discussions](https://github.com/parcel-bundler/parcel/discussions). +- 💬 Join the community on [Discord](https://discord.gg/XSCzqGRuvr). +- 📣 Stay up to date on new features and announcements on [Twitter](https://twitter.com/parceljs). -Validators receive an asset, and can throw errors if that asset is invalid -in some way, e.g. type errors or linting errors. +## Contributors -```js -import {Validator} from '@parcel/plugin'; +This project exists thanks to all the people who contribute. [[Contribute]](CONTRIBUTING.md). +contributors -export default new Validator({ - async validate({asset}) { - // ... - throw error; - } -}); -``` -Some validators (such as `@parcel/validator-typescript`) may wish to maintain a project-wide cache for efficiency. For these cases, it is appropriate to use a different interface where parcel hands _all_ changed files to the validator at the same time: +## Backers -```js -import {Validator} from '@parcel/plugin'; +Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/parcel#backer)] -export default new Validator({ - async validateAll({assets}) { - // ... - throw error; - } -}); -``` + -If your plugin implements `validateAll`, Parcel will make sure to always invoke this method on the same thread (so that your cache state is accessible). +## Sponsors -## License +Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/parcel#sponsor)] -This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/parcel-bundler/parcel/blob/v2/LICENSE) file for details + + + + + + + + + + diff --git a/packages/core/parcel/package.json b/packages/core/parcel/package.json index 8866eaae154..dd0376e0e28 100644 --- a/packages/core/parcel/package.json +++ b/packages/core/parcel/package.json @@ -1,6 +1,6 @@ { "name": "parcel", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { @@ -21,22 +21,22 @@ "node": ">= 12.0.0" }, "dependencies": { - "@parcel/config-default": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0", - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/events": "2.0.0-rc.0", - "@parcel/fs": "2.0.0-rc.0", - "@parcel/logger": "2.0.0-rc.0", - "@parcel/package-manager": "2.0.0-rc.0", - "@parcel/reporter-cli": "2.0.0-rc.0", - "@parcel/reporter-dev-server": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/config-default": "^2.0.1", + "@parcel/core": "^2.0.1", + "@parcel/diagnostic": "^2.0.1", + "@parcel/events": "^2.0.1", + "@parcel/fs": "^2.0.1", + "@parcel/logger": "^2.0.1", + "@parcel/package-manager": "^2.0.1", + "@parcel/reporter-cli": "^2.0.1", + "@parcel/reporter-dev-server": "^2.0.1", + "@parcel/utils": "^2.0.1", "chalk": "^4.1.0", "commander": "^7.0.0", "get-port": "^4.2.0", "v8-compile-cache": "^2.0.0" }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1" } } diff --git a/packages/core/parcel/src/cli.js b/packages/core/parcel/src/cli.js index 53bdd4ec9a3..6c22e391d57 100755 --- a/packages/core/parcel/src/cli.js +++ b/packages/core/parcel/src/cli.js @@ -25,13 +25,8 @@ const SIGINT_EXIT_CODE = 130; async function logUncaughtError(e: mixed) { if (e instanceof ThrowableDiagnostic) { for (let diagnostic of e.diagnostics) { - let { - message, - codeframe, - stack, - hints, - documentation, - } = await prettyDiagnostic(diagnostic); + let {message, codeframe, stack, hints, documentation} = + await prettyDiagnostic(diagnostic); INTERNAL_ORIGINAL_CONSOLE.error(chalk.red(message)); if (codeframe || stack) { INTERNAL_ORIGINAL_CONSOLE.error(''); @@ -177,12 +172,12 @@ applyOptions(build, commonOptions); program .command('help [command]') .description('display help information for a command') - .action(function(command) { + .action(function (command) { let cmd = program.commands.find(c => c.name() === command) || program; cmd.help(); }); -program.on('--help', function() { +program.on('--help', function () { INTERNAL_ORIGINAL_CONSOLE.log(''); INTERNAL_ORIGINAL_CONSOLE.log( ' Run `' + @@ -193,7 +188,7 @@ program.on('--help', function() { }); // Override to output option description if argument was missing -commander.Command.prototype.optionMissingArgument = function(option) { +commander.Command.prototype.optionMissingArgument = function (option) { INTERNAL_ORIGINAL_CONSOLE.error( "error: option `%s' argument missing", option.flags, @@ -325,8 +320,9 @@ async function run( if (command.open && options.serveOptions) { await openInBrowser( - `${options.serveOptions.https ? 'https' : 'http'}://${options - .serveOptions.host || 'localhost'}:${options.serveOptions.port}`, + `${options.serveOptions.https ? 'https' : 'http'}://${ + options.serveOptions.host || 'localhost' + }:${options.serveOptions.port}`, command.open, ); } diff --git a/packages/core/plugin/package.json b/packages/core/plugin/package.json index c3b5beda4e2..852b3f0c1af 100644 --- a/packages/core/plugin/package.json +++ b/packages/core/plugin/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/plugin", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -23,6 +23,6 @@ "check-ts": "tsc --noEmit src/PluginAPI.d.ts" }, "dependencies": { - "@parcel/types": "2.0.0-rc.0" + "@parcel/types": "^2.0.1" } } diff --git a/packages/core/register/package.json b/packages/core/register/package.json index 650e9119779..a8d3bb43886 100644 --- a/packages/core/register/package.json +++ b/packages/core/register/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/register", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -23,10 +23,10 @@ "clean": "rimraf .parcel-cache" }, "dependencies": { - "@parcel/config-default": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0", - "@parcel/fs": "2.0.0-rc.0", - "@parcel/package-manager": "2.0.0-rc.0", + "@parcel/config-default": "^2.0.1", + "@parcel/core": "^2.0.1", + "@parcel/fs": "^2.0.1", + "@parcel/package-manager": "^2.0.1", "deasync": "^0.1.14", "pirates": "^4.0.0" } diff --git a/packages/core/test-utils/package.json b/packages/core/test-utils/package.json index 41746b34ffb..427bad01863 100644 --- a/packages/core/test-utils/package.json +++ b/packages/core/test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/test-utils", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "private": true, @@ -13,11 +13,11 @@ "node": ">= 12.0.0" }, "dependencies": { - "@parcel/config-default": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0", - "@parcel/fs": "2.0.0-rc.0", - "@parcel/package-manager": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/config-default": "^2.0.1", + "@parcel/core": "^2.0.1", + "@parcel/fs": "^2.0.1", + "@parcel/package-manager": "^2.0.1", + "@parcel/utils": "^2.0.1", "chalk": "^4.1.0", "ncp": "^2.0.0", "nullthrows": "^1.1.1", diff --git a/packages/core/test-utils/src/utils.js b/packages/core/test-utils/src/utils.js index e513992b8b0..1d988e85b8f 100644 --- a/packages/core/test-utils/src/utils.js +++ b/packages/core/test-utils/src/utils.js @@ -600,7 +600,7 @@ function prepareBrowserContext( if (el.tag === 'script') { let {deferred, promise} = makeDeferredWithPromise(); promises.push(promise); - setTimeout(function() { + setTimeout(function () { let pathname = url.parse(el.src).pathname; let file = path.join(bundle.target.distDir, pathname); @@ -1005,7 +1005,7 @@ export async function runESM( // $FlowFixMe Experimental m = new vm.SyntheticModule( Object.keys(ns), - function() { + function () { for (let [k, v] of Object.entries(ns)) { this.setExport(k, v); } diff --git a/packages/core/types/index.js b/packages/core/types/index.js index 25cf7a0b0b8..a30e6fca871 100644 --- a/packages/core/types/index.js +++ b/packages/core/types/index.js @@ -25,8 +25,6 @@ export type ConfigResultWithFilePath = {| /** process.env */ export type EnvMap = typeof process.env; -export type QueryParameters = {[key: string]: string, ...}; - export type JSONValue = | null | void // ? Is this okay? @@ -188,7 +186,7 @@ export type EnvironmentOptions = {| */ export type VersionMap = { [string]: string, - ..., + ... }; export type EnvironmentFeature = @@ -400,9 +398,11 @@ export interface AssetSymbols // eslint-disable-next-line no-undef * This is the default state. */ +isCleared: boolean; - get( - exportSymbol: Symbol, - ): ?{|local: Symbol, loc: ?SourceLocation, meta?: ?Meta|}; + get(exportSymbol: Symbol): ?{| + local: Symbol, + loc: ?SourceLocation, + meta?: ?Meta, + |}; hasExportSymbol(exportSymbol: Symbol): boolean; hasLocalSymbol(local: Symbol): boolean; exportSymbols(): Iterable; @@ -441,9 +441,12 @@ export interface MutableDependencySymbols // eslint-disable-next-line no-undef * This is the default state. */ +isCleared: boolean; - get( - exportSymbol: Symbol, - ): ?{|local: Symbol, loc: ?SourceLocation, isWeak: boolean, meta?: ?Meta|}; + get(exportSymbol: Symbol): ?{| + local: Symbol, + loc: ?SourceLocation, + isWeak: boolean, + meta?: ?Meta, + |}; hasExportSymbol(exportSymbol: Symbol): boolean; hasLocalSymbol(local: Symbol): boolean; exportSymbols(): Iterable; @@ -634,7 +637,7 @@ export interface BaseAsset { */ +type: string; /** The transformer options for the asset from the dependency query string. */ - +query: QueryParameters; + +query: URLSearchParams; /** The environment of the asset. */ +env: Environment; /** @@ -1412,8 +1415,12 @@ export interface BundleGraph { asset: Asset, boundary: ?Bundle, ): Array; - /** Returns a list of symbols from an asset or dependency that are referenced by a dependent asset. */ - getUsedSymbols(Asset | Dependency): $ReadOnlySet; + /** + * Returns a list of symbols from an asset or dependency that are referenced by a dependent asset. + * + * Returns null if symbol propagation didn't run (so the result is unknown). + */ + getUsedSymbols(Asset | Dependency): ?$ReadOnlySet; /** Returns the common root directory for the entry assets of a target. */ getEntryRoot(target: Target): FilePath; } @@ -1455,7 +1462,7 @@ export type ResolveResult = {| /** An optional named pipeline to use to compile the resolved file. */ +pipeline?: ?string, /** Query parameters to be used by transformers when compiling the resolved file. */ - +query?: QueryParameters, + +query?: URLSearchParams, /** Whether the resolved file should be excluded from the build. */ +isExcluded?: boolean, /** Overrides the priority set on the dependency. */ diff --git a/packages/core/types/package.json b/packages/core/types/package.json index fe1f0d45666..af6f2e1bc73 100644 --- a/packages/core/types/package.json +++ b/packages/core/types/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/types", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "main": "src/index.js", "types": "lib/index.d.ts", @@ -16,12 +16,12 @@ "check-ts": "tsc --noEmit lib/index.d.ts" }, "dependencies": { - "@parcel/cache": "2.0.0-rc.0", - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/fs": "2.0.0-rc.0", - "@parcel/package-manager": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", - "@parcel/workers": "2.0.0-rc.0", + "@parcel/cache": "^2.0.1", + "@parcel/diagnostic": "^2.0.1", + "@parcel/fs": "^2.0.1", + "@parcel/package-manager": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "@parcel/workers": "^2.0.1", "utility-types": "^3.10.0" } } diff --git a/packages/core/utils/package.json b/packages/core/utils/package.json index faf829a2340..73335e473cf 100644 --- a/packages/core/utils/package.json +++ b/packages/core/utils/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/utils", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { @@ -21,13 +21,13 @@ }, "dependencies": { "@iarna/toml": "^2.2.0", - "@parcel/codeframe": "2.0.0-rc.0", - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/hash": "2.0.0-rc.0", - "@parcel/logger": "2.0.0-rc.0", - "@parcel/markdown-ansi": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", - "ansi-html": "^0.0.7", + "@parcel/codeframe": "^2.0.1", + "@parcel/diagnostic": "^2.0.1", + "@parcel/hash": "^2.0.1", + "@parcel/logger": "^2.0.1", + "@parcel/markdown-ansi": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "ansi-html-community": "0.0.8", "chalk": "^4.1.0", "clone": "^2.1.1", "fast-glob": "3.1.1", @@ -36,7 +36,7 @@ "is-url": "^1.2.2", "json5": "^1.0.1", "lru-cache": "^6.0.0", - "micromatch": "^3.0.4", + "micromatch": "^4.0.4", "node-forge": "^0.10.0", "nullthrows": "^1.1.1", "open": "^7.0.3", diff --git a/packages/core/utils/src/ansi-html.js b/packages/core/utils/src/ansi-html.js index ad052b0daf6..1897188da57 100644 --- a/packages/core/utils/src/ansi-html.js +++ b/packages/core/utils/src/ansi-html.js @@ -1,5 +1,5 @@ // @flow strict-local -import ansiHTML from 'ansi-html'; +import ansiHTML from 'ansi-html-community'; import {escapeHTML} from './escape-html'; export function ansiHtml(ansi: string): string { diff --git a/packages/core/utils/src/collection.js b/packages/core/utils/src/collection.js index 21f2751d486..077c1034980 100644 --- a/packages/core/utils/src/collection.js +++ b/packages/core/utils/src/collection.js @@ -6,14 +6,14 @@ export function unique(array: Array): Array { export function objectSortedEntries(obj: { +[string]: mixed, - ..., + ... }): Array<[string, mixed]> { return Object.entries(obj).sort(([keyA], [keyB]) => keyA.localeCompare(keyB)); } export function objectSortedEntriesDeep(object: { +[string]: mixed, - ..., + ... }): Array<[string, mixed]> { let sortedEntries = objectSortedEntries(object); for (let i = 0; i < sortedEntries.length; i++) { diff --git a/packages/core/utils/src/debounce.js b/packages/core/utils/src/debounce.js index dec61438c63..0bb57673c19 100644 --- a/packages/core/utils/src/debounce.js +++ b/packages/core/utils/src/debounce.js @@ -6,7 +6,7 @@ export default function debounce>( ): (...args: TArgs) => void { let timeout; - return function(...args: TArgs) { + return function (...args: TArgs) { if (timeout) { clearTimeout(timeout); } diff --git a/packages/core/utils/src/getExisting.js b/packages/core/utils/src/getExisting.js index d84b46bad6c..0206dc19fe5 100644 --- a/packages/core/utils/src/getExisting.js +++ b/packages/core/utils/src/getExisting.js @@ -14,10 +14,7 @@ export default function getExisting( return { source, minified: fs.existsSync(minifiedPath) - ? fs - .readFileSync(minifiedPath, 'utf8') - .trim() - .replace(/;$/, '') + ? fs.readFileSync(minifiedPath, 'utf8').trim().replace(/;$/, '') : source, }; } diff --git a/packages/core/utils/src/hash.js b/packages/core/utils/src/hash.js index f3dfae78725..d166761fe97 100644 --- a/packages/core/utils/src/hash.js +++ b/packages/core/utils/src/hash.js @@ -16,7 +16,7 @@ export function hashStream(stream: Readable): Promise { .on('data', chunk => { hash.writeBuffer(chunk); }) - .on('end', function() { + .on('end', function () { resolve(hash.finish()); }) .on('error', err => { diff --git a/packages/core/utils/src/replaceBundleReferences.js b/packages/core/utils/src/replaceBundleReferences.js index 1ef272ffc7e..573391fc10c 100644 --- a/packages/core/utils/src/replaceBundleReferences.js +++ b/packages/core/utils/src/replaceBundleReferences.js @@ -131,9 +131,10 @@ export async function replaceInlineReferences({ entryBundle, bundleGraph, ); - let packagedContents = (packagedBundle.contents instanceof Readable - ? await bufferStream(packagedBundle.contents) - : packagedBundle.contents + let packagedContents = ( + packagedBundle.contents instanceof Readable + ? await bufferStream(packagedBundle.contents) + : packagedBundle.contents ).toString(); let inlineType = nullthrows(entryBundle.getMainEntry()).meta.inlineType; diff --git a/packages/core/utils/src/schema.js b/packages/core/utils/src/schema.js index 0e71fda6a77..852f8eb1e62 100644 --- a/packages/core/utils/src/schema.js +++ b/packages/core/utils/src/schema.js @@ -378,7 +378,7 @@ export function fuzzySearch( return result.map(([v]) => v); } -validateSchema.diagnostic = function( +validateSchema.diagnostic = function ( schema: SchemaEntity, data: {| ... diff --git a/packages/core/utils/src/sourcemap.js b/packages/core/utils/src/sourcemap.js index 87ae8f3a4a2..5c744035e39 100644 --- a/packages/core/utils/src/sourcemap.js +++ b/packages/core/utils/src/sourcemap.js @@ -5,7 +5,8 @@ import SourceMap from '@parcel/source-map'; import path from 'path'; import {normalizeSeparators, isAbsolute} from './path'; -export const SOURCEMAP_RE: RegExp = /(?:\/\*|\/\/)\s*[@#]\s*sourceMappingURL\s*=\s*([^\s*]+)(?:\s*\*\/)?\s*$/; +export const SOURCEMAP_RE: RegExp = + /(?:\/\*|\/\/)\s*[@#]\s*sourceMappingURL\s*=\s*([^\s*]+)(?:\s*\*\/)?\s*$/; const DATA_URL_RE = /^data:[^;]+(?:;charset=[^;]+)?;base64,(.*)/; export const SOURCEMAP_EXTENSIONS: Set = new Set([ 'css', diff --git a/packages/core/utils/test/DefaultMap.test.js b/packages/core/utils/test/DefaultMap.test.js index a923529a0b4..8e853d695eb 100644 --- a/packages/core/utils/test/DefaultMap.test.js +++ b/packages/core/utils/test/DefaultMap.test.js @@ -5,10 +5,13 @@ import {DefaultMap} from '../src/DefaultMap'; describe('DefaultMap', () => { it('constructs with entries just like Map', () => { - let map = new DefaultMap(k => k, [ - [1, 3], - [2, 27], - ]); + let map = new DefaultMap( + k => k, + [ + [1, 3], + [2, 27], + ], + ); assert.equal(map.get(1), 3); assert.deepEqual(Array.from(map.entries()), [ [1, 3], diff --git a/packages/core/utils/test/throttle.test.js b/packages/core/utils/test/throttle.test.js index 3b69782b5dd..f9ff8e00f1f 100644 --- a/packages/core/utils/test/throttle.test.js +++ b/packages/core/utils/test/throttle.test.js @@ -34,7 +34,7 @@ describe('throttle', () => { it('preserves the `this` when throttled functions are invoked', () => { let result; - let throttled = throttle(function() { + let throttled = throttle(function () { result = this.bar; }, 100); diff --git a/packages/core/workers/package.json b/packages/core/workers/package.json index 01198dee569..6248ec76342 100644 --- a/packages/core/workers/package.json +++ b/packages/core/workers/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/workers", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "publishConfig": { @@ -21,14 +21,14 @@ "node": ">= 12.0.0" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/logger": "2.0.0-rc.0", - "@parcel/types": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/logger": "^2.0.1", + "@parcel/types": "^2.0.1", + "@parcel/utils": "^2.0.1", "chrome-trace-event": "^1.0.2", "nullthrows": "^1.1.1" }, "peerDependencies": { - "@parcel/core": "^2.0.0-alpha.3.1" + "@parcel/core": "^2.0.0" } } diff --git a/packages/core/workers/src/cpuCount.js b/packages/core/workers/src/cpuCount.js index 971a5029262..2f09e6d110f 100644 --- a/packages/core/workers/src/cpuCount.js +++ b/packages/core/workers/src/cpuCount.js @@ -53,8 +53,9 @@ export default function getCores(bypassCache?: boolean = false): number { // Guess the amount of real cores cores = os .cpus() - .filter((cpu, index) => !cpu.model.includes('Intel') || index % 2 === 1) - .length; + .filter( + (cpu, index) => !cpu.model.includes('Intel') || index % 2 === 1, + ).length; } // Another fallback diff --git a/packages/core/workers/test/cpuCount.test.js b/packages/core/workers/test/cpuCount.test.js index 8b3a49737c4..d89b2d98034 100644 --- a/packages/core/workers/test/cpuCount.test.js +++ b/packages/core/workers/test/cpuCount.test.js @@ -3,7 +3,7 @@ import os from 'os'; import getCores, {detectRealCores} from '../src/cpuCount'; -describe('cpuCount', function() { +describe('cpuCount', function () { it('Should be able to detect real cpu count', () => { // Windows not supported as getting the cpu count takes a couple seconds... if (os.platform() === 'win32') return; diff --git a/packages/core/workers/test/workerfarm.js b/packages/core/workers/test/workerfarm.js index a37de830641..28c302669fb 100644 --- a/packages/core/workers/test/workerfarm.js +++ b/packages/core/workers/test/workerfarm.js @@ -2,7 +2,7 @@ import Logger from '@parcel/logger'; import assert from 'assert'; import WorkerFarm from '../src'; -describe('WorkerFarm', function() { +describe('WorkerFarm', function () { this.timeout(30000); it('Should start up workers', async () => { diff --git a/packages/dev/babel-preset/package.json b/packages/dev/babel-preset/package.json index 21bcc550040..0e4f8b60a93 100644 --- a/packages/dev/babel-preset/package.json +++ b/packages/dev/babel-preset/package.json @@ -1,8 +1,13 @@ { "name": "@parcel/babel-preset", - "version": "2.0.0-rc.0", + "version": "2.0.1", "private": true, "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/parcel-bundler/parcel.git", + "directory": "packages/dev/babel-preset" + }, "dependencies": { "@babel/plugin-proposal-class-properties": "^7.1.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", diff --git a/packages/dev/babel-register/package.json b/packages/dev/babel-register/package.json index 708f5d17f6d..3034124c8c7 100644 --- a/packages/dev/babel-register/package.json +++ b/packages/dev/babel-register/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/babel-register", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Blazing fast, zero configuration web application bundler", "license": "MIT", "private": true, @@ -10,7 +10,7 @@ }, "dependencies": { "@babel/register": "^7.4.4", - "@parcel/babel-preset": "2.0.0-rc.0", + "@parcel/babel-preset": "^2.0.1", "resolve": "^1.12.0" } } diff --git a/packages/dev/eslint-config-browser/package.json b/packages/dev/eslint-config-browser/package.json index e783f1b4f04..46317af6ae6 100644 --- a/packages/dev/eslint-config-browser/package.json +++ b/packages/dev/eslint-config-browser/package.json @@ -1,8 +1,8 @@ { "name": "@parcel/eslint-config-browser", "private": true, - "version": "2.0.0-rc.0", + "version": "2.0.1", "dependencies": { - "@parcel/eslint-config": "2.0.0-rc.0" + "@parcel/eslint-config": "^2.0.1" } } diff --git a/packages/dev/eslint-config/package.json b/packages/dev/eslint-config/package.json index cc5b5c94f3f..a27405f09f2 100644 --- a/packages/dev/eslint-config/package.json +++ b/packages/dev/eslint-config/package.json @@ -1,10 +1,10 @@ { "name": "@parcel/eslint-config", "private": true, - "version": "2.0.0-rc.0", + "version": "2.0.1", "dependencies": { "@babel/eslint-parser": "^7.12.1", - "@parcel/eslint-plugin": "2.0.0-rc.0", + "@parcel/eslint-plugin": "^2.0.1", "eslint-config-prettier": "^7.2.0", "eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-import": "^2.22.1", diff --git a/packages/dev/eslint-plugin/package.json b/packages/dev/eslint-plugin/package.json index c258be7f355..d118ba6d9c9 100644 --- a/packages/dev/eslint-plugin/package.json +++ b/packages/dev/eslint-plugin/package.json @@ -1,7 +1,7 @@ { "name": "@parcel/eslint-plugin", "private": true, - "version": "2.0.0-rc.0", + "version": "2.0.1", "main": "index.js", "scripts": {}, "dependencies": { diff --git a/packages/dev/eslint-plugin/test/rules/no-self-package-imports.test.js b/packages/dev/eslint-plugin/test/rules/no-self-package-imports.test.js index 4595d376c5f..d62013b131a 100644 --- a/packages/dev/eslint-plugin/test/rules/no-self-package-imports.test.js +++ b/packages/dev/eslint-plugin/test/rules/no-self-package-imports.test.js @@ -20,8 +20,7 @@ new RuleTester({ ], invalid: [ { - code: - "require('@parcel/eslint-plugin/lib/rules/no-self-package-imports');", + code: "require('@parcel/eslint-plugin/lib/rules/no-self-package-imports');", errors: [{message}], filename, output: "require('../../lib/rules/no-self-package-imports');", @@ -33,8 +32,7 @@ new RuleTester({ output: "require('../../');", }, { - code: - "require.resolve('@parcel/eslint-plugin/lib/rules/no-self-package-imports');", + code: "require.resolve('@parcel/eslint-plugin/lib/rules/no-self-package-imports');", filename, errors: [{message}], output: "require.resolve('../../lib/rules/no-self-package-imports');", @@ -46,8 +44,7 @@ new RuleTester({ output: "import rule from '../../';", }, { - code: - "import rule from '@parcel/eslint-plugin/lib/rules/no-self-package-imports';", + code: "import rule from '@parcel/eslint-plugin/lib/rules/no-self-package-imports';", filename, errors: [{message}], output: "import rule from '../../lib/rules/no-self-package-imports';", diff --git a/packages/dev/esm-fuzzer/package.json b/packages/dev/esm-fuzzer/package.json index 47d7ccda1fd..122afeafaf8 100644 --- a/packages/dev/esm-fuzzer/package.json +++ b/packages/dev/esm-fuzzer/package.json @@ -1,6 +1,6 @@ { "name": "fuzzer", - "version": "2.0.0-rc.0", + "version": "2.0.1", "private": true, "scripts": { "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules -r @parcel/babel-register index.js" diff --git a/packages/examples/eslint-example/package.json b/packages/examples/eslint-example/package.json index f46b1d993d1..349402b97ef 100644 --- a/packages/examples/eslint-example/package.json +++ b/packages/examples/eslint-example/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/eslint-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { @@ -17,8 +17,8 @@ } }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0", - "@parcel/validator-eslint": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1", + "@parcel/core": "^2.0.1", + "@parcel/validator-eslint": "^2.0.1" } } diff --git a/packages/examples/html/package.json b/packages/examples/html/package.json index dba48bf087b..9ad9b3a3ced 100644 --- a/packages/examples/html/package.json +++ b/packages/examples/html/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/html-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { @@ -12,8 +12,8 @@ "not firefox < 67" ], "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0", - "parcel": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1", + "parcel": "^2.0.1" }, "dependencies": { "lodash": "^4.17.11", diff --git a/packages/examples/internalize-example/package.json b/packages/examples/internalize-example/package.json index 490981341d2..56afc15e830 100644 --- a/packages/examples/internalize-example/package.json +++ b/packages/examples/internalize-example/package.json @@ -1,4 +1,4 @@ { "name": "internalize-example", - "version": "2.0.0-rc.0" + "version": "2.0.1" } diff --git a/packages/examples/kitchen-sink/package.json b/packages/examples/kitchen-sink/package.json index 64ee29869ac..c8b1dcfd050 100644 --- a/packages/examples/kitchen-sink/package.json +++ b/packages/examples/kitchen-sink/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/kitchen-sink-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { @@ -8,11 +8,11 @@ "build": "rm -rf dist && parcel build src/index.html --no-cache" }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0", - "@parcel/config-default": "2.0.0-rc.0", - "@parcel/optimizer-esbuild": "2.0.0-rc.0", - "@parcel/reporter-sourcemap-visualiser": "2.0.0-rc.0", - "parcel": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1", + "@parcel/config-default": "^2.0.1", + "@parcel/optimizer-esbuild": "^2.0.1", + "@parcel/reporter-sourcemap-visualiser": "^2.0.1", + "parcel": "^2.0.1" }, "browser": "dist/legacy/index.html", "browserModern": "dist/modern/index.html", diff --git a/packages/examples/react-hmr/package.json b/packages/examples/react-hmr/package.json index 7a9b29e0bd1..5963dd248f9 100644 --- a/packages/examples/react-hmr/package.json +++ b/packages/examples/react-hmr/package.json @@ -1,13 +1,13 @@ { "name": "@parcel/react-hmr-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { "demo": "parcel serve src/index.html --no-cache --https" }, "devDependencies": { - "parcel": "2.0.0-rc.0" + "parcel": "^2.0.1" }, "browser": "dist/legacy/index.html", "browserModern": "dist/modern/index.html", diff --git a/packages/examples/react-hmr/src/index.js b/packages/examples/react-hmr/src/index.js index ac80f26cfa1..44d8d9f9033 100644 --- a/packages/examples/react-hmr/src/index.js +++ b/packages/examples/react-hmr/src/index.js @@ -4,11 +4,11 @@ import ReactDOM from 'react-dom'; console.log({hmrOptions: module.hot}); if (module.hot) { - module.hot.dispose(function() { + module.hot.dispose(function () { console.log('HOT DISPOSE'); }); - module.hot.accept(function() { + module.hot.accept(function () { console.log('HOT ACCEPT'); }); } diff --git a/packages/examples/react-refresh/package.json b/packages/examples/react-refresh/package.json index 35f3da0198f..173179641fd 100644 --- a/packages/examples/react-refresh/package.json +++ b/packages/examples/react-refresh/package.json @@ -1,14 +1,14 @@ { "name": "@parcel/react-refresh-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { "start": "parcel src/index.html" }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1", + "@parcel/core": "^2.0.1" }, "dependencies": { "react": "^16.11.0", diff --git a/packages/examples/simple/package.json b/packages/examples/simple/package.json index c82e875c027..082c2a02889 100644 --- a/packages/examples/simple/package.json +++ b/packages/examples/simple/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/simple-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { @@ -8,8 +8,8 @@ "clean-demo": "rm -rf .parcel-cache dist && yarn demo" }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1", + "@parcel/core": "^2.0.1" }, "browser": "dist/legacy/index.js", "browserModern": "dist/modern/index.js", diff --git a/packages/examples/simple/src/foo.js b/packages/examples/simple/src/foo.js index abaf0b992d3..6b6158e5c6e 100644 --- a/packages/examples/simple/src/foo.js +++ b/packages/examples/simple/src/foo.js @@ -1,3 +1,3 @@ -export default function() { +export default function () { return 'hello!'; } diff --git a/packages/examples/three/package.json b/packages/examples/three/package.json index bcba5ba1dc3..9c3da32eaa6 100644 --- a/packages/examples/three/package.json +++ b/packages/examples/three/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/three-js-stresstest", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { @@ -27,7 +27,7 @@ } }, "devDependencies": { - "@parcel/config-default": "2.0.0-rc.0", - "parcel": "2.0.0-rc.0" + "@parcel/config-default": "^2.0.1", + "parcel": "^2.0.1" } } diff --git a/packages/examples/ts-example/package.json b/packages/examples/ts-example/package.json index fd27de544a8..f3771d55c20 100644 --- a/packages/examples/ts-example/package.json +++ b/packages/examples/ts-example/package.json @@ -1,14 +1,14 @@ { "name": "@parcel/ts-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { "demo": "parcel build src/index.ts" }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1", + "@parcel/core": "^2.0.1" }, "main": "dist/main.js", "module": "dist/module.js", diff --git a/packages/examples/ts-typecheck-example/package.json b/packages/examples/ts-typecheck-example/package.json index 4e2b7c5fcc7..a8db3ee471e 100644 --- a/packages/examples/ts-typecheck-example/package.json +++ b/packages/examples/ts-typecheck-example/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/ts-typecheck-example", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "private": true, "scripts": { @@ -17,8 +17,8 @@ } }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0", - "@parcel/core": "2.0.0-rc.0", - "@parcel/validator-typescript": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1", + "@parcel/core": "^2.0.1", + "@parcel/validator-typescript": "^2.0.1" } } diff --git a/packages/namers/default/package.json b/packages/namers/default/package.json index 3a1e4148324..c6460acd772 100644 --- a/packages/namers/default/package.json +++ b/packages/namers/default/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/namer-default", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/DefaultNamer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", "nullthrows": "^1.1.1" } } diff --git a/packages/namers/default/src/DefaultNamer.js b/packages/namers/default/src/DefaultNamer.js index 6779425de22..e765f01c167 100644 --- a/packages/namers/default/src/DefaultNamer.js +++ b/packages/namers/default/src/DefaultNamer.js @@ -63,12 +63,11 @@ export default (new Namer({ { start: loc.start, end: loc.end, - message: md`Did you mean "${fullName.slice( - 0, - -path.extname(fullName).length, - ) + + message: md`Did you mean "${ + fullName.slice(0, -path.extname(fullName).length) + '.' + - bundle.type}"?`, + bundle.type + }"?`, }, ], }, diff --git a/packages/optimizers/blob-url/package.json b/packages/optimizers/blob-url/package.json index e3a21ca3b59..f187d8840c7 100644 --- a/packages/optimizers/blob-url/package.json +++ b/packages/optimizers/blob-url/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/optimizer-blob-url", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/BlobURLOptimizer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1" } } diff --git a/packages/optimizers/cssnano/package.json b/packages/optimizers/cssnano/package.json index c0b801a11ee..8f04db0525f 100644 --- a/packages/optimizers/cssnano/package.json +++ b/packages/optimizers/cssnano/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/optimizer-cssnano", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/CSSNanoOptimizer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", "cssnano": "^5.0.5", "postcss": "^8.3.0" } diff --git a/packages/optimizers/data-url/package.json b/packages/optimizers/data-url/package.json index c958ee5d519..8eed6c323ac 100644 --- a/packages/optimizers/data-url/package.json +++ b/packages/optimizers/data-url/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/optimizer-data-url", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/DataURLOptimizer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "isbinaryfile": "^4.0.2", "mime": "^2.4.4" } diff --git a/packages/optimizers/data-url/src/DataURLOptimizer.js b/packages/optimizers/data-url/src/DataURLOptimizer.js index 89f9fb30ffe..6f39c6db6f4 100644 --- a/packages/optimizers/data-url/src/DataURLOptimizer.js +++ b/packages/optimizers/data-url/src/DataURLOptimizer.js @@ -6,7 +6,7 @@ import mime from 'mime'; import {isBinaryFile} from 'isbinaryfile'; const fixedEncodeURIComponent = (str: string): string => { - return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { + return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { return '%' + c.charCodeAt(0).toString(16); }); }; diff --git a/packages/optimizers/esbuild/package.json b/packages/optimizers/esbuild/package.json index 23bb42609d0..68bea088afa 100644 --- a/packages/optimizers/esbuild/package.json +++ b/packages/optimizers/esbuild/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/optimizer-esbuild", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,14 +17,14 @@ "source": "src/ESBuildOptimizer.js", "engines": { "node": ">= 10.0.0", - "parcel": "^2.0.0-alpha.1.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", - "@parcel/utils": "2.0.0-rc.0", - "esbuild": "^0.8.11", + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "@parcel/utils": "^2.0.1", + "esbuild": "^0.13.0", "nullthrows": "^1.1.1" } } diff --git a/packages/optimizers/esbuild/src/ESBuildOptimizer.js b/packages/optimizers/esbuild/src/ESBuildOptimizer.js index 9ac42c01c08..a6d566f8544 100644 --- a/packages/optimizers/esbuild/src/ESBuildOptimizer.js +++ b/packages/optimizers/esbuild/src/ESBuildOptimizer.js @@ -1,23 +1,18 @@ // @flow -import {startService} from 'esbuild'; +import {transform} from 'esbuild'; import {Optimizer} from '@parcel/plugin'; import {blobToString, normalizePath} from '@parcel/utils'; import SourceMap from '@parcel/source-map'; import path from 'path'; import invariant from 'assert'; -let service = null; export default (new Optimizer({ async optimize({contents, map, bundle, options, getSourceMapReference}) { if (!bundle.env.shouldOptimize) { return {contents, map}; } - if (!service) { - service = await startService(); - } - let relativeBundlePath = path.relative( options.projectRoot, path.join(bundle.target.distDir, bundle.name), @@ -33,10 +28,12 @@ export default (new Optimizer({ code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${vlqMappings}`; } - let {code: js, map: jsSourceMap} = await service.transform(code, { + let {code: js, map: jsSourceMap} = await transform(code, { sourcemap: 'external', sourcefile: relativeBundlePath, minify: true, + treeShaking: true, + format: 'esm', }); let sourcemap = null; diff --git a/packages/optimizers/htmlnano/package.json b/packages/optimizers/htmlnano/package.json index 6c738f9ff61..ec744a6db20 100644 --- a/packages/optimizers/htmlnano/package.json +++ b/packages/optimizers/htmlnano/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/optimizer-htmlnano", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/HTMLNanoOptimizer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", "htmlnano": "^1.0.1", "nullthrows": "^1.1.1", "posthtml": "^0.16.5", diff --git a/packages/optimizers/htmlnano/src/HTMLNanoOptimizer.js b/packages/optimizers/htmlnano/src/HTMLNanoOptimizer.js index 59dae165f47..6eae2b144fc 100644 --- a/packages/optimizers/htmlnano/src/HTMLNanoOptimizer.js +++ b/packages/optimizers/htmlnano/src/HTMLNanoOptimizer.js @@ -53,7 +53,10 @@ export default (new Optimizer({ delete clonedConfig.preset; const htmlNanoConfig = { + // Inline is added to make sure HMR is working even if user - // didn't add any. It's inserted at the very end to take into account cases - // when there's no html/head/body in source html. + // didn't add any. if (options.hmrOptions && !(hasScripts || hasInlineScripts)) { - ast.program.push({ + const script = { tag: 'script', attrs: { src: asset.addURLDependency('hmr.js', { @@ -51,7 +53,17 @@ export default (new Transformer({ }), }, content: [], - }); + }; + + const found = findFirstMatch(ast, [{tag: 'body'}, {tag: 'html'}]); + + if (found) { + found.content = found.content || []; + found.content.push(script); + } else { + // Insert at the very end. + ast.program.push(script); + } asset.setAST(ast); @@ -65,9 +77,29 @@ export default (new Transformer({ return result; }, - generate({ast}) { + generate({ast, asset}) { return { - content: render(ast.program), + content: render(ast.program, { + closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined, + }), }; }, }): Transformer); + +function findFirstMatch( + ast: AST, + expressions: PostHTMLExpression[], +): ?PostHTMLNode { + let found; + + for (const expression of expressions) { + PostHTML().match.call(ast.program, expression, node => { + found = node; + return node; + }); + + if (found) { + return found; + } + } +} diff --git a/packages/transformers/html/src/dependencies.js b/packages/transformers/html/src/dependencies.js index 98e76f92313..5ce79ca5d8f 100644 --- a/packages/transformers/html/src/dependencies.js +++ b/packages/transformers/html/src/dependencies.js @@ -245,7 +245,7 @@ export default function collectDependencies( for (let attr in attrs) { // Check for virtual paths - if (tag === 'a' && attrs[attr].lastIndexOf('.') < 1) { + if (tag === 'a' && attrs[attr].split('#')[0].lastIndexOf('.') < 1) { continue; } diff --git a/packages/transformers/image/package.json b/packages/transformers/image/package.json index c5f509ed8c6..3afd7e6a4b8 100644 --- a/packages/transformers/image/package.json +++ b/packages/transformers/image/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-image", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -13,12 +13,14 @@ "source": "src/ImageTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1", + "@parcel/workers": "^2.0.1", + "nullthrows": "^1.1.1" }, "devDependencies": { - "sharp": "^0.28.3" + "sharp": "^0.29.1" } } diff --git a/packages/transformers/image/src/ImageTransformer.js b/packages/transformers/image/src/ImageTransformer.js index 3f2c577349a..b067a992962 100644 --- a/packages/transformers/image/src/ImageTransformer.js +++ b/packages/transformers/image/src/ImageTransformer.js @@ -1,64 +1,118 @@ // @flow +import {validateConfig} from './validateConfig'; import {Transformer} from '@parcel/plugin'; +import nullthrows from 'nullthrows'; +import WorkerFarm from '@parcel/workers'; +import loadSharp from './loadSharp'; // from https://github.com/lovell/sharp/blob/df7b8ba73808fc494be413e88cfb621b6279218c/lib/output.js#L6-L17 const FORMATS = new Map([ - ['heic', 'heif'], - ['heif', 'heif'], - ['avif', 'avif'], ['jpeg', 'jpeg'], ['jpg', 'jpeg'], ['png', 'png'], - ['raw', 'raw'], - ['tiff', 'tiff'], ['webp', 'webp'], ['gif', 'gif'], + ['tiff', 'tiff'], + ['avif', 'avif'], + ['heic', 'heif'], + ['heif', 'heif'], ]); -const SHARP_RANGE = '^0.28.3'; +let isSharpLoadedOnMainThread = false; export default (new Transformer({ - async transform({asset, options}) { + async loadConfig({config}) { + let configFile: any = await config.getConfig( + ['sharp.config.json'], // '.sharprc', '.sharprc.json' + {packageKey: 'sharp'}, + ); + + if (configFile?.contents) { + validateConfig(configFile.contents, configFile.filePath); + return configFile.contents; + } else { + return {}; + } + }, + + async transform({config, asset, options}) { asset.bundleBehavior = 'isolated'; - let width = asset.query.width ? parseInt(asset.query.width, 10) : null; - let height = asset.query.height ? parseInt(asset.query.height, 10) : null; - let quality = asset.query.quality - ? parseInt(asset.query.quality, 10) - : undefined; - let format = asset.query.as ? asset.query.as.toLowerCase().trim() : null; + const originalFormat = FORMATS.get(asset.type); + if (!originalFormat) { + throw new Error( + `The image transformer does not support ${asset.type} images.`, + ); + } + + const width = asset.query.has('width') + ? parseInt(asset.query.get('width'), 10) + : null; + const height = asset.query.has('height') + ? parseInt(asset.query.get('height'), 10) + : null; + const quality = asset.query.has('quality') + ? parseInt(asset.query.get('quality'), 10) + : config.quality; + let targetFormat = asset.query.get('as')?.toLowerCase().trim(); + if (targetFormat && !FORMATS.has(targetFormat)) { + throw new Error( + `The image transformer does not support ${targetFormat} images.`, + ); + } + + const format = nullthrows(FORMATS.get(targetFormat || originalFormat)); + const outputOptions = config[format]; + + if (width || height || quality || targetFormat || outputOptions) { + // Sharp must be required from the main thread as well to prevent errors when workers exit + // See https://sharp.pixelplumbing.com/install#worker-threads and https://github.com/lovell/sharp/issues/2263 + if (WorkerFarm.isWorker() && !isSharpLoadedOnMainThread) { + let api = WorkerFarm.getWorkerApi(); + await api.callMaster({ + location: __dirname + '/loadSharp.js', + args: [ + options.packageManager, + asset.filePath, + options.shouldAutoInstall, + ], + }); + + isSharpLoadedOnMainThread = true; + } - if (width || height || quality || format) { let inputBuffer = await asset.getBuffer(); - let sharp = await options.packageManager.require( - 'sharp', + let sharp = await loadSharp( + options.packageManager, asset.filePath, - { - range: SHARP_RANGE, - shouldAutoInstall: options.shouldAutoInstall, - }, + options.shouldAutoInstall, + true, ); let imagePipeline = sharp(inputBuffer); + + imagePipeline.withMetadata(); + if (width || height) { imagePipeline.resize(width, height); } imagePipeline.rotate(); - if (format) { - if (!FORMATS.has(format)) { - throw new Error(`Sharp does not support ${format} images.`); - } - - asset.type = format; - - imagePipeline[FORMATS.get(format)]({ - quality, - }); + const normalizedOutputOptions = outputOptions || {}; + if (format === 'jpeg') { + normalizedOutputOptions.mozjpeg = + normalizedOutputOptions.mozjpeg ?? true; } + imagePipeline[format]({ + quality, + ...normalizedOutputOptions, + }); + + asset.type = format; - asset.setStream(imagePipeline); + let buffer = await imagePipeline.toBuffer(); + asset.setBuffer(buffer); } return [asset]; diff --git a/packages/transformers/image/src/loadSharp.js b/packages/transformers/image/src/loadSharp.js new file mode 100644 index 00000000000..52e598cbf26 --- /dev/null +++ b/packages/transformers/image/src/loadSharp.js @@ -0,0 +1,23 @@ +// @flow +import type {PackageManager} from '@parcel/package-manager'; +import type {FilePath} from '@parcel/types'; + +const SHARP_RANGE = '^0.29.1'; + +// This is used to load sharp on the main thread, which prevents errors when worker threads exit +// See https://sharp.pixelplumbing.com/install#worker-threads and https://github.com/lovell/sharp/issues/2263 +module.exports = async ( + packageManager: PackageManager, + filePath: FilePath, + shouldAutoInstall: boolean, + shouldReturn: boolean, +): Promise => { + let sharp = await packageManager.require('sharp', filePath, { + range: SHARP_RANGE, + shouldAutoInstall: shouldAutoInstall, + }); + + if (shouldReturn) { + return sharp; + } +}; diff --git a/packages/transformers/image/src/validateConfig.js b/packages/transformers/image/src/validateConfig.js new file mode 100644 index 00000000000..03206b92294 --- /dev/null +++ b/packages/transformers/image/src/validateConfig.js @@ -0,0 +1,260 @@ +// @flow +import type {SchemaEntity} from '@parcel/utils'; +import {validateSchema} from '@parcel/utils'; + +// https://sharp.pixelplumbing.com/api-output#jpeg +const JPEG_OUTPUT_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + quality: { + type: 'number', + }, + progressive: { + type: 'boolean', + }, + chromaSubsampling: { + type: 'string', + }, + optimiseCoding: { + type: 'boolean', + }, + optimizeCoding: { + type: 'boolean', + }, + mozjpeg: { + type: 'boolean', + }, + trellisQuantisation: { + type: 'boolean', + }, + overshootDeringing: { + type: 'boolean', + }, + optimiseScans: { + type: 'boolean', + }, + optimizeScans: { + type: 'boolean', + }, + quantisationTable: { + type: 'number', + }, + quantizationTable: { + type: 'number', + }, + force: { + type: 'boolean', + }, + }, + additionalProperties: true, +}; + +// https://sharp.pixelplumbing.com/api-output#png +const PNG_OUTPUT_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + quality: { + type: 'number', + }, + progressive: { + type: 'boolean', + }, + compressionLevel: { + type: 'number', + }, + adaptiveFiltering: { + type: 'boolean', + }, + palette: { + type: 'boolean', + }, + colours: { + type: 'number', + }, + colors: { + type: 'number', + }, + dither: { + type: 'number', + }, + force: { + type: 'boolean', + }, + }, + additionalProperties: true, +}; + +// https://sharp.pixelplumbing.com/api-output#webp +const WEBP_OUTPUT_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + quality: { + type: 'number', + }, + alphaQuality: { + type: 'number', + }, + lossless: { + type: 'boolean', + }, + nearLossless: { + type: 'boolean', + }, + smartSubsample: { + type: 'boolean', + }, + reductionEffort: { + type: 'number', + }, + pageHeight: { + type: 'number', + }, + loop: { + type: 'number', + }, + delay: { + type: 'array', + items: { + type: 'number', + }, + }, + force: { + type: 'boolean', + }, + }, + additionalProperties: true, +}; + +// https://sharp.pixelplumbing.com/api-output#gif +const GIF_OUTPUT_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + pageHeight: { + type: 'number', + }, + loop: { + type: 'number', + }, + delay: { + type: 'array', + items: { + type: 'number', + }, + }, + force: { + type: 'boolean', + }, + }, + additionalProperties: true, +}; + +// https://sharp.pixelplumbing.com/api-output#tiff +const TIFF_OUTPUT_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + quality: { + type: 'number', + }, + force: { + type: 'boolean', + }, + compression: { + type: 'string', + }, + predictor: { + type: 'string', + }, + pyramid: { + type: 'boolean', + }, + tile: { + type: 'boolean', + }, + tileWidth: { + type: 'number', + }, + tileHeight: { + type: 'number', + }, + xres: { + type: 'number', + }, + yres: { + type: 'number', + }, + bitdepth: { + type: 'number', + }, + }, + additionalProperties: true, +}; + +// https://sharp.pixelplumbing.com/api-output#avif +const AVIF_OUTPUT_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + quality: { + type: 'number', + }, + lossless: { + type: 'boolean', + }, + speed: { + type: 'number', + }, + chromaSubsampling: { + type: 'string', + }, + }, + additionalProperties: true, +}; + +// https://sharp.pixelplumbing.com/api-output#heif +const HEIF_OUTPUT_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + quality: { + type: 'number', + }, + compression: { + type: 'string', + }, + lossless: { + type: 'boolean', + }, + speed: { + type: 'number', + }, + chromaSubsampling: { + type: 'string', + }, + }, + additionalProperties: true, +}; + +const CONFIG_SCHEMA: SchemaEntity = { + type: 'object', + properties: { + // Fallback quality + quality: { + type: 'number', + }, + jpeg: JPEG_OUTPUT_SCHEMA, + png: PNG_OUTPUT_SCHEMA, + webp: WEBP_OUTPUT_SCHEMA, + gif: GIF_OUTPUT_SCHEMA, + tiff: TIFF_OUTPUT_SCHEMA, + avif: AVIF_OUTPUT_SCHEMA, + heif: HEIF_OUTPUT_SCHEMA, + }, + additionalProperties: false, +}; + +export function validateConfig(data: any, filePath: string) { + validateSchema.diagnostic( + CONFIG_SCHEMA, + {data, filePath}, + '@parcel/transformer-image', + 'Invalid sharp config', + ); +} diff --git a/packages/transformers/inline-string/package.json b/packages/transformers/inline-string/package.json index 5bc76ed05f8..9c362cc5659 100644 --- a/packages/transformers/inline-string/package.json +++ b/packages/transformers/inline-string/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-inline-string", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,9 +17,9 @@ "source": "src/InlineStringTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/transformers/inline/package.json b/packages/transformers/inline/package.json index d6cc684b3d5..eb1ab52d6d6 100644 --- a/packages/transformers/inline/package.json +++ b/packages/transformers/inline/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-inline", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,9 +17,9 @@ "source": "src/InlineTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/transformers/js/core/Cargo.toml b/packages/transformers/js/core/Cargo.toml index 27af8cd6b8f..20edeb22740 100644 --- a/packages/transformers/js/core/Cargo.toml +++ b/packages/transformers/js/core/Cargo.toml @@ -8,10 +8,10 @@ edition = "2018" crate-type = ["rlib"] [dependencies] -swc_ecmascript = { version = "0.63.1", features = ["parser", "transforms", "module", "optimization", "react", "typescript", "utils", "visit", "codegen", "utils"] } -swc_ecma_preset_env = "0.42.1" -swc_common = { version = "0.12.1", features = ["tty-emitter", "sourcemap"] } -swc_atoms = "0.2.7" +swc_ecmascript = { version = "0.84.1", features = ["parser", "transforms", "module", "optimization", "react", "typescript", "utils", "visit", "codegen", "utils"] } +swc_ecma_preset_env = "0.63.1" +swc_common = { version = "0.14.3", features = ["tty-emitter", "sourcemap"] } +swc_atoms = "0.2.9" indoc = "1.0.3" serde = "1.0.123" serde_bytes = "0.11.5" diff --git a/packages/transformers/js/core/src/dependency_collector.rs b/packages/transformers/js/core/src/dependency_collector.rs index a8347af897d..6b2c4a34185 100644 --- a/packages/transformers/js/core/src/dependency_collector.rs +++ b/packages/transformers/js/core/src/dependency_collector.rs @@ -10,6 +10,7 @@ use swc_ecmascript::ast; use swc_ecmascript::utils::ident::IdentLike; use swc_ecmascript::visit::{Fold, FoldWith}; +use crate::fold_member_expr_skip_prop; use crate::utils::*; use crate::Config; @@ -208,7 +209,7 @@ impl<'a> DependencyCollector<'a> { show_environment: true, severity: DiagnosticSeverity::Error, documentation_url: Some(String::from( - "https://v2.parceljs.org/languages/javascript/#classic-scripts", + "https://parceljs.org/languages/javascript/#classic-scripts", )), }); } @@ -394,7 +395,7 @@ impl<'a> Fold for DependencyCollector<'a> { show_environment: self.config.source_type == SourceType::Script, severity: DiagnosticSeverity::Error, documentation_url: Some(String::from( - "https://v2.parceljs.org/languages/javascript/#classic-script-workers", + "https://parceljs.org/languages/javascript/#classic-script-workers", )), }); } @@ -429,7 +430,9 @@ impl<'a> Fold for DependencyCollector<'a> { } } Member(member) => { - if self.config.is_browser + if match_member_expr(member, vec!["module", "require"], self.decls) { + DependencyKind::Require + } else if self.config.is_browser && match_member_expr( member, vec!["navigator", "serviceWorker", "register"], @@ -551,7 +554,7 @@ impl<'a> Fold for DependencyCollector<'a> { let (msg, docs) = if kind == DependencyKind::ServiceWorker { ( "Registering service workers with a string literal is not supported.", - "https://v2.parceljs.org/languages/javascript/#service-workers", + "https://parceljs.org/languages/javascript/#service-workers", ) } else { ( @@ -739,7 +742,7 @@ impl<'a> Fold for DependencyCollector<'a> { show_environment: false, severity: DiagnosticSeverity::Error, documentation_url: Some(String::from( - "https://v2.parceljs.org/languages/javascript/#web-workers", + "https://parceljs.org/languages/javascript/#web-workers", )), }); return node; @@ -778,16 +781,7 @@ impl<'a> Fold for DependencyCollector<'a> { node.fold_children_with(self) } - fn fold_member_expr(&mut self, mut node: ast::MemberExpr) -> ast::MemberExpr { - node.obj = node.obj.fold_children_with(self); - - // To ensure that fold_expr doesn't replace `require` in non-computed member expressions - if node.computed { - node.prop = node.prop.fold_children_with(self); - } - - node - } + fold_member_expr_skip_prop! {} fn fold_expr(&mut self, node: ast::Expr) -> ast::Expr { use ast::*; @@ -1226,7 +1220,7 @@ impl<'a> DependencyCollector<'a> { show_environment: true, severity: DiagnosticSeverity::Error, documentation_url: Some(String::from( - "https://v2.parceljs.org/languages/javascript/#classic-scripts", + "https://parceljs.org/languages/javascript/#classic-scripts", )), }) } diff --git a/packages/transformers/js/core/src/hoist.rs b/packages/transformers/js/core/src/hoist.rs index e114daaead7..d2a4abed5b1 100644 --- a/packages/transformers/js/core/src/hoist.rs +++ b/packages/transformers/js/core/src/hoist.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use std::collections::hash_map::DefaultHasher; use std::collections::{HashMap, HashSet}; -use std::hash::{Hash, Hasher}; +use std::hash::Hasher; use swc_atoms::JsWord; use swc_common::{sync::Lrc, Mark, Span, SyntaxContext, DUMMY_SP}; use swc_ecmascript::ast::*; @@ -22,7 +22,7 @@ macro_rules! id { macro_rules! hash { ($str:expr) => {{ let mut hasher = DefaultHasher::new(); - $str.hash(&mut hasher); + hasher.write($str.as_bytes()); hasher.finish() }}; } @@ -55,14 +55,30 @@ pub fn hoist( Ok((module, hoist.get_result(), diagnostics)) } +#[derive(Debug, Serialize, Deserialize)] +struct ExportedSymbol { + local: JsWord, + exported: JsWord, + loc: SourceLocation, +} + +#[derive(Debug, Serialize, Deserialize)] +struct ImportedSymbol { + source: JsWord, + local: JsWord, + imported: JsWord, + loc: SourceLocation, +} + struct Hoist<'a> { module_id: &'a str, collect: &'a Collect, module_items: Vec, export_decls: HashSet, - imported_symbols: HashMap, - exported_symbols: HashMap, - re_exports: Vec<(JsWord, JsWord, JsWord, SourceLocation)>, + hoisted_imports: Vec, + imported_symbols: Vec, + exported_symbols: Vec, + re_exports: Vec, self_references: HashSet, dynamic_imports: HashMap, in_function_scope: bool, @@ -71,9 +87,9 @@ struct Hoist<'a> { #[derive(Debug, Default, Serialize, Deserialize)] pub struct HoistResult { - imported_symbols: HashMap, - exported_symbols: HashMap, - re_exports: Vec<(JsWord, JsWord, JsWord, SourceLocation)>, + imported_symbols: Vec, + exported_symbols: Vec, + re_exports: Vec, self_references: HashSet, wrapped_requires: HashSet, dynamic_imports: HashMap, @@ -90,8 +106,9 @@ impl<'a> Hoist<'a> { collect, module_items: vec![], export_decls: HashSet::new(), - imported_symbols: HashMap::new(), - exported_symbols: HashMap::new(), + hoisted_imports: vec![], + imported_symbols: vec![], + exported_symbols: vec![], re_exports: vec![], self_references: HashSet::new(), dynamic_imports: HashMap::new(), @@ -131,24 +148,25 @@ macro_rules! hoist_visit_fn { impl<'a> Fold for Hoist<'a> { fn fold_module(&mut self, node: Module) -> Module { let mut node = node; - let mut hoisted_imports = vec![]; for item in node.body { match item { ModuleItem::ModuleDecl(decl) => { match decl { ModuleDecl::Import(import) => { - hoisted_imports.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { - specifiers: vec![], - asserts: None, - span: DUMMY_SP, - src: Str { - value: format!("{}:{}", self.module_id, import.src.value).into(), + self + .hoisted_imports + .push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { + specifiers: vec![], + asserts: None, span: DUMMY_SP, - kind: StrKind::Synthesized, - has_escape: false, - }, - type_only: false, - }))); + src: Str { + value: format!("{}:{}", self.module_id, import.src.value).into(), + span: DUMMY_SP, + kind: StrKind::Synthesized, + has_escape: false, + }, + type_only: false, + }))); // Ensure that all import specifiers are constant. for specifier in &import.specifiers { @@ -186,18 +204,20 @@ impl<'a> Fold for Hoist<'a> { ModuleDecl::ExportNamed(export) => { if let Some(src) = export.src { // TODO: skip if already imported. - hoisted_imports.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { - specifiers: vec![], - asserts: None, - span: DUMMY_SP, - src: Str { - value: format!("{}:{}", self.module_id, src.value).into(), + self + .hoisted_imports + .push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { + specifiers: vec![], + asserts: None, span: DUMMY_SP, - kind: StrKind::Synthesized, - has_escape: false, - }, - type_only: false, - }))); + src: Str { + value: format!("{}:{}", self.module_id, src.value).into(), + span: DUMMY_SP, + kind: StrKind::Synthesized, + has_escape: false, + }, + type_only: false, + }))); for specifier in export.specifiers { match specifier { @@ -206,28 +226,28 @@ impl<'a> Fold for Hoist<'a> { Some(exported) => exported.sym, None => named.orig.sym.clone(), }; - self.re_exports.push(( - exported, - src.value.clone(), - named.orig.sym, - SourceLocation::from(&self.collect.source_map, named.span), - )); + self.re_exports.push(ImportedSymbol { + source: src.value.clone(), + local: exported, + imported: named.orig.sym, + loc: SourceLocation::from(&self.collect.source_map, named.span), + }); } ExportSpecifier::Default(default) => { - self.re_exports.push(( - default.exported.sym, - src.value.clone(), - js_word!("default"), - SourceLocation::from(&self.collect.source_map, default.exported.span), - )); + self.re_exports.push(ImportedSymbol { + source: src.value.clone(), + local: default.exported.sym, + imported: js_word!("default"), + loc: SourceLocation::from(&self.collect.source_map, default.exported.span), + }); } ExportSpecifier::Namespace(namespace) => { - self.re_exports.push(( - namespace.name.sym, - src.value.clone(), - "*".into(), - SourceLocation::from(&self.collect.source_map, namespace.span), - )); + self.re_exports.push(ImportedSymbol { + source: src.value.clone(), + local: namespace.name.sym, + imported: "*".into(), + loc: SourceLocation::from(&self.collect.source_map, namespace.span), + }); } } } @@ -243,50 +263,54 @@ impl<'a> Fold for Hoist<'a> { source, specifier, .. }) = self.collect.imports.get(&id) { - self.re_exports.push(( - exported, - source.clone(), - specifier.clone(), - SourceLocation::from(&self.collect.source_map, named.span), - )); + self.re_exports.push(ImportedSymbol { + source: source.clone(), + local: exported, + imported: specifier.clone(), + loc: SourceLocation::from(&self.collect.source_map, named.span), + }); } else { // A variable will appear only once in the `exports` mapping but // could be exported multiple times with different names. // Find the original exported name, and remap. - let orig_exported = self.collect.exports.get(&id).unwrap(); let id = if self.collect.should_wrap { - Ident::new(orig_exported.clone(), DUMMY_SP) + id.0 } else { - self.get_export_ident(DUMMY_SP, orig_exported) + self + .get_export_ident(DUMMY_SP, self.collect.exports.get(&id).unwrap()) + .sym }; - self.exported_symbols.entry(exported).or_insert(( - id.sym, - SourceLocation::from(&self.collect.source_map, named.span), - )); + self.exported_symbols.push(ExportedSymbol { + local: id, + exported, + loc: SourceLocation::from(&self.collect.source_map, named.span), + }); } } } } } ModuleDecl::ExportAll(export) => { - hoisted_imports.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { - specifiers: vec![], - asserts: None, - span: DUMMY_SP, - src: Str { - value: format!("{}:{}", self.module_id, export.src.value).into(), + self + .hoisted_imports + .push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { + specifiers: vec![], + asserts: None, span: DUMMY_SP, - kind: StrKind::Synthesized, - has_escape: false, - }, - type_only: false, - }))); - self.re_exports.push(( - "*".into(), - export.src.value, - "*".into(), - SourceLocation::from(&self.collect.source_map, export.span), - )); + src: Str { + value: format!("{}:{}", self.module_id, export.src.value).into(), + span: DUMMY_SP, + kind: StrKind::Synthesized, + has_escape: false, + }, + type_only: false, + }))); + self.re_exports.push(ImportedSymbol { + source: export.src.value, + local: "*".into(), + imported: "*".into(), + loc: SourceLocation::from(&self.collect.source_map, export.span), + }); } ModuleDecl::ExportDefaultExpr(export) => { let ident = self.get_export_ident(export.span, &"default".into()); @@ -308,12 +332,20 @@ impl<'a> Fold for Hoist<'a> { ModuleDecl::ExportDefaultDecl(export) => { let decl = match export.decl { DefaultDecl::Class(class) => Decl::Class(ClassDecl { - ident: self.get_export_ident(DUMMY_SP, &"default".into()), + ident: if self.collect.should_wrap && class.ident.is_some() { + class.ident.unwrap() + } else { + self.get_export_ident(DUMMY_SP, &"default".into()) + }, declare: false, class: class.class.fold_with(self), }), DefaultDecl::Fn(func) => Decl::Fn(FnDecl { - ident: self.get_export_ident(DUMMY_SP, &"default".into()), + ident: if self.collect.should_wrap && func.ident.is_some() { + func.ident.unwrap() + } else { + self.get_export_ident(DUMMY_SP, &"default".into()) + }, declare: false, function: func.function.fold_with(self), }), @@ -497,21 +529,9 @@ impl<'a> Fold for Hoist<'a> { } } - for name in self.export_decls.drain() { - hoisted_imports.push(ModuleItem::Stmt(Stmt::Decl(Decl::Var(VarDecl { - declare: false, - kind: VarDeclKind::Var, - span: node.span, - decls: vec![VarDeclarator { - definite: false, - span: node.span, - name: Pat::Ident(BindingIdent::from(Ident::new(name, DUMMY_SP))), - init: None, - }], - })))); - } - - self.module_items.splice(0..0, hoisted_imports); + self + .module_items + .splice(0..0, self.hoisted_imports.drain(0..)); node.body = std::mem::take(&mut self.module_items); node } @@ -551,7 +571,7 @@ impl<'a> Fold for Hoist<'a> { match &**expr { Expr::Ident(ident) => { // import * as y from 'x'; OR const y = require('x'); OR const y = await import('x'); - // y.foo -> $id$import$10b1f2ceae7ab64e$y + // y.foo -> $id$import$d141bba7fdc215a3$y if let Some(Import { source, specifier, @@ -560,7 +580,7 @@ impl<'a> Fold for Hoist<'a> { }) = self.collect.imports.get(&id!(ident)) { // If there are any non-static accesses of the namespace, don't perform any replacement. - // This will be handled in the Ident visitor below, which replaces y -> $id$import$10b1f2ceae7ab64e. + // This will be handled in the Ident visitor below, which replaces y -> $id$import$d141bba7fdc215a3. if specifier == "*" && !self.collect.non_static_access.contains_key(&id!(ident)) && !self.collect.non_const_bindings.contains_key(&id!(ident)) @@ -574,14 +594,12 @@ impl<'a> Fold for Hoist<'a> { hash!(key) ) .into(); - self.imported_symbols.insert( - name, - ( - source.clone(), - key.clone(), - SourceLocation::from(&self.collect.source_map, member.span), - ), - ); + self.imported_symbols.push(ImportedSymbol { + source: source.clone(), + local: name, + imported: key.clone(), + loc: SourceLocation::from(&self.collect.source_map, member.span), + }); } else { return Expr::Ident(self.get_import_ident( member.span, @@ -668,14 +686,12 @@ impl<'a> Fold for Hoist<'a> { let name: JsWord = format!("${}$importAsync${:x}", self.module_id, hash!(source)).into(); self.dynamic_imports.insert(name.clone(), source.clone()); if self.collect.non_static_requires.contains(&source) || self.collect.should_wrap { - self.imported_symbols.insert( - name.clone(), - ( - source, - "*".into(), - SourceLocation::from(&self.collect.source_map, call.span), - ), - ); + self.imported_symbols.push(ImportedSymbol { + source, + local: name.clone(), + imported: "*".into(), + loc: SourceLocation::from(&self.collect.source_map, call.span), + }); } return Expr::Ident(Ident::new(name, call.span)); } @@ -776,15 +792,21 @@ impl<'a> Fold for Hoist<'a> { hash!(specifier) ) .into(); - self - .imported_symbols - .insert(name, (source.clone(), specifier.clone(), loc.clone())); + self.imported_symbols.push(ImportedSymbol { + source: source.clone(), + local: name, + imported: specifier.clone(), + loc: loc.clone(), + }); } else if self.collect.non_static_access.contains_key(&id!(node)) { let name: JsWord = format!("${}$importAsync${:x}", self.module_id, hash!(source)).into(); - self - .imported_symbols - .insert(name, (source.clone(), "*".into(), loc.clone())); + self.imported_symbols.push(ImportedSymbol { + source: source.clone(), + local: name, + imported: "*".into(), + loc: loc.clone(), + }); } } else { // If this identifier is not constant, we cannot directly reference the imported @@ -805,10 +827,11 @@ impl<'a> Fold for Hoist<'a> { // If wrapped, mark the original symbol as exported. // Otherwise replace with an export identifier. if self.collect.should_wrap { - self.exported_symbols.entry(exported.clone()).or_insert(( - node.sym.clone(), - SourceLocation::from(&self.collect.source_map, node.span), - )); + self.exported_symbols.push(ExportedSymbol { + local: node.sym.clone(), + exported: exported.clone(), + loc: SourceLocation::from(&self.collect.source_map, node.span), + }); return node; } else { return self.get_export_ident(node.span, exported); @@ -893,8 +916,23 @@ impl<'a> Fold for Hoist<'a> { }; let ident = BindingIdent::from(self.get_export_ident(member.span, &key)); - if self.collect.static_cjs_exports { - self.export_decls.insert(ident.id.sym.clone()); + if self.collect.static_cjs_exports && self.export_decls.insert(ident.id.sym.clone()) { + self + .hoisted_imports + .push(ModuleItem::Stmt(Stmt::Decl(Decl::Var(VarDecl { + declare: false, + kind: VarDeclKind::Var, + span: node.span, + decls: vec![VarDeclarator { + definite: false, + span: node.span, + name: Pat::Ident(BindingIdent::from(Ident::new( + ident.id.sym.clone(), + DUMMY_SP, + ))), + init: None, + }], + })))); } return AssignExpr { @@ -999,13 +1037,16 @@ impl<'a> Hoist<'a> { &mut self, span: Span, source: &JsWord, - local: &JsWord, + imported: &JsWord, loc: SourceLocation, ) -> Ident { - let new_name = self.get_import_name(source, local); - self - .imported_symbols - .insert(new_name.clone(), (source.clone(), local.clone(), loc)); + let new_name = self.get_import_name(source, imported); + self.imported_symbols.push(ImportedSymbol { + source: source.clone(), + local: new_name.clone(), + imported: imported.clone(), + loc, + }); Ident::new(new_name, span) } @@ -1023,10 +1064,11 @@ impl<'a> Hoist<'a> { format!("${}$export${:x}", self.module_id, hash!(exported)).into() }; - self.exported_symbols.entry(exported.clone()).or_insert(( - new_name.clone(), - SourceLocation::from(&self.collect.source_map, span), - )); + self.exported_symbols.push(ExportedSymbol { + local: new_name.clone(), + exported: exported.clone(), + loc: SourceLocation::from(&self.collect.source_map, span), + }); let mut span = span; span.ctxt = SyntaxContext::empty(); @@ -1038,7 +1080,7 @@ impl<'a> Hoist<'a> { // a local variable referencing them so that we can safely re-assign the local variable // without affecting the original export. This is only possible in CommonJS since ESM // imports are constant (this is ensured by the diagnostic in fold_module above). - let mut non_const_bindings = HashSet::new(); + let mut non_const_bindings = vec![]; self .collect .get_non_const_binding_idents(&v.name, &mut non_const_bindings); @@ -1392,6 +1434,10 @@ impl Visit for Collect { return; } + if match_member_expr(node, vec!["module", "require"], &self.decls) { + return; + } + let is_static = match &*node.prop { Expr::Ident(_) => !node.computed, Expr::Lit(Lit::Str(_)) => true, @@ -1814,11 +1860,11 @@ impl Collect { } } - fn get_non_const_binding_idents(&self, node: &Pat, idents: &mut HashSet) { + fn get_non_const_binding_idents(&self, node: &Pat, idents: &mut Vec) { match node { Pat::Ident(ident) => { if self.non_const_bindings.contains_key(&id!(ident.id)) { - idents.insert(ident.id.clone()); + idents.push(ident.id.clone()); } } Pat::Object(object) => { @@ -1829,7 +1875,7 @@ impl Collect { } ObjectPatProp::Assign(assign) => { if self.non_const_bindings.contains_key(&id!(assign.key)) { - idents.insert(assign.key.clone()); + idents.push(assign.key.clone()); } } ObjectPatProp::Rest(rest) => { @@ -2042,8 +2088,8 @@ mod tests { macro_rules! assert_eq_imported_symbols { ($m: expr, $match: expr) => {{ let mut map = HashMap::new(); - for (key, val) in $m { - map.insert(key, (val.0, val.1)); + for sym in $m { + map.insert(sym.local, (sym.source, sym.imported)); } assert_eq!(map, $match); }}; @@ -2525,7 +2571,7 @@ mod tests { let $abc$var$test = { bar: 3 }; - console.log($abc$import$558d6cfb8af8a010$ba02ad2230917043, $abc$var$test.bar); + console.log($abc$import$70a00e0a8474f72a$6a5cdcad01c973fa, $abc$var$test.bar); "#} ); @@ -2540,7 +2586,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - console.log($abc$import$558d6cfb8af8a010$3705fc5f2281438d); + console.log($abc$import$70a00e0a8474f72a$d927737047eb3867); "#} ); @@ -2555,7 +2601,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - console.log($abc$import$558d6cfb8af8a010$9099ad97b570f7c, $abc$import$558d6cfb8af8a010$9099ad97b570f7c.bar); + console.log($abc$import$70a00e0a8474f72a$2e2bcd8739ae039, $abc$import$70a00e0a8474f72a$2e2bcd8739ae039.bar); "#} ); } @@ -2576,8 +2622,8 @@ mod tests { indoc! {r#" import "abc:other"; import "abc:bar"; - console.log($abc$import$558d6cfb8af8a010$9099ad97b570f7c); - console.log($abc$import$3705fc5f2281438d$9099ad97b570f7c); + console.log($abc$import$70a00e0a8474f72a$2e2bcd8739ae039); + console.log($abc$import$d927737047eb3867$2e2bcd8739ae039); "#} ); @@ -2597,10 +2643,10 @@ mod tests { indoc! {r#" import "abc:other"; import "abc:bar"; - console.log($abc$import$558d6cfb8af8a010$9099ad97b570f7c); + console.log($abc$import$70a00e0a8474f72a$2e2bcd8739ae039); import "abc:x"; - console.log($abc$import$10b1f2ceae7ab64e); - console.log($abc$import$3705fc5f2281438d$9099ad97b570f7c); + console.log($abc$import$d141bba7fdc215a3); + console.log($abc$import$d927737047eb3867$2e2bcd8739ae039); "#} ); } @@ -2619,7 +2665,7 @@ mod tests { indoc! {r#" const $abc$var$x = 4; import "abc:other"; - var $abc$require$bar = $abc$import$558d6cfb8af8a010$3705fc5f2281438d; + var $abc$require$bar = $abc$import$70a00e0a8474f72a$d927737047eb3867; const $abc$var$baz = 3; console.log($abc$require$bar); "#} @@ -2638,7 +2684,7 @@ mod tests { const $abc$var$x = 3; import "abc:other"; const $abc$var$bar = 2; - console.log($abc$import$558d6cfb8af8a010$3705fc5f2281438d); + console.log($abc$import$70a00e0a8474f72a$d927737047eb3867); "#} ); } @@ -2656,7 +2702,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - const { foo: $abc$var$foo , ...$abc$var$bar } = $abc$import$558d6cfb8af8a010; + const { foo: $abc$var$foo , ...$abc$var$bar } = $abc$import$70a00e0a8474f72a; console.log($abc$var$foo, $abc$var$bar); "#} ); @@ -2672,7 +2718,7 @@ mod tests { code, indoc! {r#" import "abc:x"; - const { x: { y: $abc$var$z } } = $abc$import$10b1f2ceae7ab64e; + const { x: { y: $abc$var$z } } = $abc$import$d141bba7fdc215a3; console.log($abc$var$z); "#} ); @@ -2688,7 +2734,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - console.log($abc$import$558d6cfb8af8a010[bar]); + console.log($abc$import$70a00e0a8474f72a[bar]); "#} ); @@ -2703,7 +2749,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - console.log($abc$import$558d6cfb8af8a010[bar], $abc$import$558d6cfb8af8a010.baz); + console.log($abc$import$70a00e0a8474f72a[bar], $abc$import$70a00e0a8474f72a.baz); "#} ); } @@ -2729,7 +2775,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - var $abc$require$foo = $abc$import$558d6cfb8af8a010$ba02ad2230917043; + var $abc$require$foo = $abc$import$70a00e0a8474f72a$6a5cdcad01c973fa; console.log($abc$require$foo); "#} ); @@ -2745,7 +2791,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - const $abc$var$foo = $abc$import$558d6cfb8af8a010[bar]; + const $abc$var$foo = $abc$import$70a00e0a8474f72a[bar]; console.log($abc$var$foo); "#} ); @@ -2761,7 +2807,7 @@ mod tests { code, indoc! {r#" import "abc:other"; - const { foo: $abc$var$foo } = $abc$import$558d6cfb8af8a010$ba02ad2230917043; + const { foo: $abc$var$foo } = $abc$import$70a00e0a8474f72a$6a5cdcad01c973fa; console.log($abc$var$foo); "#} ); @@ -2784,7 +2830,7 @@ mod tests { indoc! {r#" import "abc:other"; function $abc$var$x() { - const foo = $abc$import$558d6cfb8af8a010; + const foo = $abc$import$70a00e0a8474f72a; console.log(foo.bar); } import "abc:bar"; @@ -2811,7 +2857,7 @@ mod tests { import "abc:other"; var $abc$var$foo = (function() { if (Date.now() < 0) { - var bar = $abc$import$558d6cfb8af8a010; + var bar = $abc$import$70a00e0a8474f72a; } })(); "#} @@ -2835,7 +2881,7 @@ mod tests { indoc! {r#" import "abc:other"; function $abc$var$x() { - const foo = $abc$import$558d6cfb8af8a010$ba02ad2230917043; + const foo = $abc$import$70a00e0a8474f72a$6a5cdcad01c973fa; console.log(foo); } "#} @@ -2854,7 +2900,7 @@ mod tests { indoc! {r#" import "abc:other"; function $abc$var$x() { - console.log($abc$import$558d6cfb8af8a010$ba02ad2230917043); + console.log($abc$import$70a00e0a8474f72a$6a5cdcad01c973fa); } "#} ); @@ -2873,7 +2919,7 @@ mod tests { indoc! {r#" import "abc:other"; function $abc$var$x() { - const foo = $abc$import$558d6cfb8af8a010[test]; + const foo = $abc$import$70a00e0a8474f72a[test]; console.log(foo); } "#} @@ -2893,7 +2939,7 @@ mod tests { indoc! {r#" import "abc:other"; function $abc$var$x() { - const { foo: foo } = $abc$import$558d6cfb8af8a010; + const { foo: foo } = $abc$import$70a00e0a8474f72a; console.log(foo); } "#} @@ -2910,7 +2956,7 @@ mod tests { indoc! {r#" import "abc:a"; import "abc:b"; - let $abc$var$x = $abc$import$7ac649919d1c80a6 + $abc$import$a91ade93898ecc38; + let $abc$var$x = $abc$import$407448d2b89b1813 + $abc$import$8b22cf2602fb60ce; "#} ); @@ -2925,7 +2971,7 @@ mod tests { indoc! {r#" import "abc:a"; import "abc:b"; - let $abc$var$x = (!$abc$import$7ac649919d1c80a6, $abc$import$a91ade93898ecc38); + let $abc$var$x = (!$abc$import$407448d2b89b1813, $abc$import$8b22cf2602fb60ce); "#} ); @@ -2940,7 +2986,7 @@ mod tests { indoc! {r#" import "abc:a"; import "abc:b"; - let $abc$var$x = $abc$import$7ac649919d1c80a6 || $abc$import$a91ade93898ecc38; + let $abc$var$x = $abc$import$407448d2b89b1813 || $abc$import$8b22cf2602fb60ce; "#} ); @@ -2955,7 +3001,7 @@ mod tests { indoc! {r#" import "abc:a"; import "abc:b"; - let $abc$var$x = condition ? $abc$import$7ac649919d1c80a6 : $abc$import$a91ade93898ecc38; + let $abc$var$x = condition ? $abc$import$407448d2b89b1813 : $abc$import$8b22cf2602fb60ce; "#} ); @@ -2969,7 +3015,7 @@ mod tests { code, indoc! {r#" import "abc:a"; - if (condition) $abc$import$7ac649919d1c80a6; + if (condition) $abc$import$407448d2b89b1813; "#} ); @@ -2983,7 +3029,7 @@ mod tests { code, indoc! {r#" import "abc:y"; - for(let x = $abc$import$57bbd0ca114c72e; x < 5; x++){ + for(let x = $abc$import$4a5767248b18ef41; x < 5; x++){ } "#} ); @@ -3003,8 +3049,8 @@ mod tests { assert_eq!( code, indoc! {r#" - let $abc$export$10b1f2ceae7ab64e = 3; - let $abc$export$57bbd0ca114c72e = 4; + let $abc$export$d141bba7fdc215a3 = 3; + let $abc$export$4a5767248b18ef41 = 4; let $abc$var$z = 6; "#} ); @@ -3018,7 +3064,7 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$9099ad97b570f7c = 3; + var $abc$export$2e2bcd8739ae039 = 3; "#} ); @@ -3033,7 +3079,7 @@ mod tests { code, indoc! {r#" let $abc$var$x = 3; - var $abc$export$9099ad97b570f7c = $abc$var$x; + var $abc$export$2e2bcd8739ae039 = $abc$var$x; "#} ); @@ -3046,7 +3092,7 @@ mod tests { assert_eq!( code, indoc! {r#" - function $abc$export$9099ad97b570f7c() { + function $abc$export$2e2bcd8739ae039() { } "#} ); @@ -3060,7 +3106,24 @@ mod tests { assert_eq!( code, indoc! {r#" - class $abc$export$9099ad97b570f7c { + class $abc$export$2e2bcd8739ae039 { + } + "#} + ); + + let (_collect, code, hoist) = parse( + r#" + console.log(module); + export default class X {} + "#, + ); + + assert!(hoist.should_wrap); + assert_eq!( + code, + indoc! {r#" + console.log(module); + class X { } "#} ); @@ -3074,7 +3137,7 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$10b1f2ceae7ab64e = 2, $abc$export$57bbd0ca114c72e = 3; + var $abc$export$d141bba7fdc215a3 = 2, $abc$export$4a5767248b18ef41 = 3; "#} ); @@ -3089,9 +3152,9 @@ mod tests { assert_eq!( code, indoc! {r#" - var { x: $abc$export$10b1f2ceae7ab64e , ...$abc$export$57bbd0ca114c72e } = something; - var [$abc$export$e809c7c5e035fc81, ...$abc$export$51cf687b896afa97] = something; - var { x: $abc$export$10b1f2ceae7ab64e = 3 } = something; + var { x: $abc$export$d141bba7fdc215a3 , ...$abc$export$4a5767248b18ef41 } = something; + var [$abc$export$ffb5f4729a158638, ...$abc$export$9e5f44173e64f162] = something; + var { x: $abc$export$d141bba7fdc215a3 = 3 } = something; "#} ); @@ -3104,7 +3167,7 @@ mod tests { assert_eq!( code, indoc! {r#" - function $abc$export$fdd70aeca3bc8cbb() { + function $abc$export$e0969da9b8fb378d() { } "#} ); @@ -3118,7 +3181,7 @@ mod tests { assert_eq!( code, indoc! {r#" - class $abc$export$785fc6237f113e49 { + class $abc$export$1b16fc9eb974a84d { } "#} ); @@ -3161,8 +3224,8 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$ba02ad2230917043; - $abc$export$ba02ad2230917043 = 2; + var $abc$export$6a5cdcad01c973fa; + $abc$export$6a5cdcad01c973fa = 2; "#} ); @@ -3175,8 +3238,8 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$ba02ad2230917043; - $abc$export$ba02ad2230917043 = 2; + var $abc$export$6a5cdcad01c973fa; + $abc$export$6a5cdcad01c973fa = 2; "#} ); @@ -3191,9 +3254,9 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$ba02ad2230917043; + var $abc$export$6a5cdcad01c973fa; function $abc$var$init() { - $abc$export$ba02ad2230917043 = 2; + $abc$export$6a5cdcad01c973fa = 2; } "#} ); @@ -3207,8 +3270,8 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$ba02ad2230917043; - $abc$export$ba02ad2230917043 = 2; + var $abc$export$6a5cdcad01c973fa; + $abc$export$6a5cdcad01c973fa = 2; "#} ); @@ -3221,8 +3284,8 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$ba02ad2230917043; - $abc$export$ba02ad2230917043 = 2; + var $abc$export$6a5cdcad01c973fa; + $abc$export$6a5cdcad01c973fa = 2; "#} ); @@ -3236,9 +3299,9 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$ba02ad2230917043; - $abc$export$ba02ad2230917043 = 2; - console.log($abc$export$ba02ad2230917043); + var $abc$export$6a5cdcad01c973fa; + $abc$export$6a5cdcad01c973fa = 2; + console.log($abc$export$6a5cdcad01c973fa); "#} ); @@ -3252,9 +3315,9 @@ mod tests { assert_eq!( code, indoc! {r#" - var $abc$export$ba02ad2230917043; - $abc$export$ba02ad2230917043 = 2; - console.log($abc$export$ba02ad2230917043); + var $abc$export$6a5cdcad01c973fa; + $abc$export$6a5cdcad01c973fa = 2; + console.log($abc$export$6a5cdcad01c973fa); "#} ); } @@ -3415,13 +3478,13 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( @@ -3429,7 +3492,7 @@ mod tests { indoc! {r#" import "abc:other"; async function $abc$var$test() { - const x = await $abc$importAsync$558d6cfb8af8a010; + const x = await $abc$importAsync$70a00e0a8474f72a; console.log(x.foo); } "#} @@ -3446,13 +3509,13 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => (w!("other"), w!("*")) + w!("$abc$importAsync$70a00e0a8474f72a") => (w!("other"), w!("*")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( @@ -3460,7 +3523,7 @@ mod tests { indoc! {r#" import "abc:other"; async function $abc$var$test() { - const x = await $abc$importAsync$558d6cfb8af8a010; + const x = await $abc$importAsync$70a00e0a8474f72a; console.log(x[foo]); } "#} @@ -3477,13 +3540,13 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( @@ -3491,7 +3554,7 @@ mod tests { indoc! {r#" import "abc:other"; async function $abc$var$test() { - const { foo: foo } = await $abc$importAsync$558d6cfb8af8a010; + const { foo: foo } = await $abc$importAsync$70a00e0a8474f72a; console.log(foo); } "#} @@ -3508,13 +3571,13 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( @@ -3522,7 +3585,7 @@ mod tests { indoc! {r#" import "abc:other"; async function $abc$var$test() { - const { foo: bar } = await $abc$importAsync$558d6cfb8af8a010; + const { foo: bar } = await $abc$importAsync$70a00e0a8474f72a; console.log(bar); } "#} @@ -3536,20 +3599,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then((x)=>x.foo + $abc$importAsync$70a00e0a8474f72a.then((x)=>x.foo ); "#} ); @@ -3562,20 +3625,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => (w!("other"), w!("*")) + w!("$abc$importAsync$70a00e0a8474f72a") => (w!("other"), w!("*")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then((x)=>x + $abc$importAsync$70a00e0a8474f72a.then((x)=>x ); "#} ); @@ -3588,20 +3651,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then(({ foo: foo })=>foo + $abc$importAsync$70a00e0a8474f72a.then(({ foo: foo })=>foo ); "#} ); @@ -3614,20 +3677,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then(({ foo: bar })=>bar + $abc$importAsync$70a00e0a8474f72a.then(({ foo: bar })=>bar ); "#} ); @@ -3640,20 +3703,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then(function(x) { + $abc$importAsync$70a00e0a8474f72a.then(function(x) { return x.foo; }); "#} @@ -3667,20 +3730,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => (w!("other"), w!("*")) + w!("$abc$importAsync$70a00e0a8474f72a") => (w!("other"), w!("*")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then(function(x) { + $abc$importAsync$70a00e0a8474f72a.then(function(x) { return x; }); "#} @@ -3694,20 +3757,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then(function({ foo: foo }) { + $abc$importAsync$70a00e0a8474f72a.then(function({ foo: foo }) { }); "#} ); @@ -3720,20 +3783,20 @@ mod tests { assert_eq_imported_symbols!( hoist.imported_symbols, map! { - w!("$abc$importAsync$558d6cfb8af8a010$ba02ad2230917043") => (w!("other"), w!("foo")) + w!("$abc$importAsync$70a00e0a8474f72a$6a5cdcad01c973fa") => (w!("other"), w!("foo")) } ); assert_eq!( hoist.dynamic_imports, map! { - w!("$abc$importAsync$558d6cfb8af8a010") => w!("other") + w!("$abc$importAsync$70a00e0a8474f72a") => w!("other") } ); assert_eq!( code, indoc! {r#" import "abc:other"; - $abc$importAsync$558d6cfb8af8a010.then(function({ foo: bar }) { + $abc$importAsync$70a00e0a8474f72a.then(function({ foo: bar }) { }); "#} ); diff --git a/packages/transformers/js/core/src/lib.rs b/packages/transformers/js/core/src/lib.rs index 112cb43974b..09a0a472650 100644 --- a/packages/transformers/js/core/src/lib.rs +++ b/packages/transformers/js/core/src/lib.rs @@ -251,12 +251,10 @@ pub fn transform(config: Config) -> Result { }; } + let global_mark = Mark::fresh(Mark::root()); + let ignore_mark = Mark::fresh(Mark::root()); module = { let mut passes = chain!( - Optional::new( - react::react(source_map.clone(), Some(&comments), react_options), - config.is_jsx - ), // Decorators can use type information, so must run before the TypeScript pass. Optional::new( decorators::decorators(decorators::Config { @@ -266,15 +264,35 @@ pub fn transform(config: Config) -> Result { }), config.decorators ), - Optional::new(typescript::strip(), config.is_type_script) + Optional::new( + typescript::strip_with_jsx( + source_map.clone(), + typescript::Config { + pragma: Some(react_options.pragma.clone()), + pragma_frag: Some(react_options.pragma_frag.clone()), + ..Default::default() + }, + Some(&comments), + global_mark, + ), + config.is_type_script && config.is_jsx + ), + Optional::new(typescript::strip(), config.is_type_script && !config.is_jsx), + resolver_with_mark(global_mark), + Optional::new( + react::react( + source_map.clone(), + Some(&comments), + react_options, + global_mark + ), + config.is_jsx + ), ); module.fold_with(&mut passes) }; - let global_mark = Mark::fresh(Mark::root()); - let ignore_mark = Mark::fresh(Mark::root()); - let module = module.fold_with(&mut resolver_with_mark(global_mark)); let mut decls = collect_decls(&module); let mut preset_env_config = swc_ecma_preset_env::Config { @@ -307,7 +325,7 @@ pub fn transform(config: Config) -> Result { ), // Simplify expressions and remove dead branches so that we // don't include dependencies inside conditionals that are always false. - expr_simplifier(), + expr_simplifier(Default::default()), dead_branch_remover(), // Inline Node fs.readFileSync calls Optional::new( diff --git a/packages/transformers/js/core/src/modules.rs b/packages/transformers/js/core/src/modules.rs index c64e5baa986..f6aafaf28e4 100644 --- a/packages/transformers/js/core/src/modules.rs +++ b/packages/transformers/js/core/src/modules.rs @@ -6,6 +6,8 @@ use swc_ecma_preset_env::{Feature, Versions}; use swc_ecmascript::ast::*; use swc_ecmascript::visit::{Fold, FoldWith}; +use crate::fold_member_expr_skip_prop; + type IdentId = (JsWord, SyntaxContext); macro_rules! id { ($ident: expr) => { @@ -613,4 +615,6 @@ impl Fold for ESMFold { _ => node.fold_children_with(self), } } + + fold_member_expr_skip_prop! {} } diff --git a/packages/transformers/js/core/src/utils.rs b/packages/transformers/js/core/src/utils.rs index 34d22c05017..c2ec6dac2ae 100644 --- a/packages/transformers/js/core/src/utils.rs +++ b/packages/transformers/js/core/src/utils.rs @@ -114,6 +114,17 @@ pub fn match_require( None } + Expr::Member(member) => { + if match_member_expr(member, vec!["module", "require"], decls) { + if let Some(arg) = call.args.get(0) { + if let Expr::Lit(Lit::Str(str_)) = &*arg.expr { + return Some(str_.value.clone()); + } + } + } + + None + } _ => None, }, _ => None, @@ -173,12 +184,9 @@ impl SourceLocation { impl PartialOrd for SourceLocation { fn partial_cmp(&self, other: &SourceLocation) -> Option { - if self.start_line < other.start_line { - Some(Ordering::Less) - } else if self.start_line == other.start_line { - self.start_col.partial_cmp(&other.start_col) - } else { - Some(Ordering::Greater) + match self.start_line.cmp(&other.start_line) { + Ordering::Equal => self.start_col.partial_cmp(&other.start_col), + o => Some(o), } } } @@ -256,48 +264,66 @@ impl BailoutReason { match self { BailoutReason::NonTopLevelRequire => ( "Conditional or non-top-level `require()` call. This causes the resolved module and all dependendencies to be wrapped.", - "https://v2.parceljs.org/features/scope-hoisting/#avoid-conditional-require()" + "https://parceljs.org/features/scope-hoisting/#avoid-conditional-require()" ), BailoutReason::NonStaticDestructuring => ( "Non-static destructuring of `require` or dynamic `import()`. This causes all exports of the resolved module to be included.", - "https://v2.parceljs.org/features/scope-hoisting/#commonjs" + "https://parceljs.org/features/scope-hoisting/#commonjs" ), BailoutReason::TopLevelReturn => ( "Module contains a top-level `return` statement. This causes the module to be wrapped in a function and tree shaking to be disabled.", - "https://v2.parceljs.org/features/scope-hoisting/#avoid-top-level-return" + "https://parceljs.org/features/scope-hoisting/#avoid-top-level-return" ), BailoutReason::Eval => ( "Module contains usage of `eval`. This causes the module to be wrapped in a function and minification to be disabled.", - "https://v2.parceljs.org/features/scope-hoisting/#avoid-eval" + "https://parceljs.org/features/scope-hoisting/#avoid-eval" ), BailoutReason::NonStaticExports => ( "Non-static access of CommonJS `exports` object. This causes tree shaking to be disabled for the module.", - "https://v2.parceljs.org/features/scope-hoisting/#commonjs" + "https://parceljs.org/features/scope-hoisting/#commonjs" ), BailoutReason::FreeModule => ( "Unknown usage of CommonJS `module` object. This causes the module to be wrapped, and tree shaking to be disabled.", - "https://v2.parceljs.org/features/scope-hoisting/#commonjs" + "https://parceljs.org/features/scope-hoisting/#commonjs" ), BailoutReason::FreeExports => ( "Unknown usage of CommonJS `exports` object. This causes tree shaking to be disabled.", - "https://v2.parceljs.org/features/scope-hoisting/#commonjs" + "https://parceljs.org/features/scope-hoisting/#commonjs" ), BailoutReason::ExportsReassignment => ( "Module contains a reassignment of the CommonJS `exports` object. This causes the module to be wrapped and tree-shaking to be disabled.", - "https://v2.parceljs.org/features/scope-hoisting/#avoid-module-and-exports-re-assignment" + "https://parceljs.org/features/scope-hoisting/#avoid-module-and-exports-re-assignment" ), BailoutReason::ModuleReassignment => ( "Module contains a reassignment of the CommonJS `module` object. This causes the module to be wrapped and tree-shaking to be disabled.", - "https://v2.parceljs.org/features/scope-hoisting/#avoid-module-and-exports-re-assignment" + "https://parceljs.org/features/scope-hoisting/#avoid-module-and-exports-re-assignment" ), BailoutReason::NonStaticDynamicImport => ( "Unknown dynamic import usage. This causes tree shaking to be disabled for the resolved module.", - "https://v2.parceljs.org/features/scope-hoisting/#dynamic-imports" + "https://parceljs.org/features/scope-hoisting/#dynamic-imports" ), BailoutReason::NonStaticAccess => ( "Non-static access of an `import` or `require`. This causes tree shaking to be disabled for the resolved module.", - "https://v2.parceljs.org/features/scope-hoisting/#dynamic-member-accesses" + "https://parceljs.org/features/scope-hoisting/#dynamic-member-accesses" ), } } } + +#[macro_export] +macro_rules! fold_member_expr_skip_prop { + () => { + fn fold_member_expr( + &mut self, + mut node: swc_ecmascript::ast::MemberExpr, + ) -> swc_ecmascript::ast::MemberExpr { + node.obj = node.obj.fold_with(self); + + if node.computed { + node.prop = node.prop.fold_with(self); + } + + node + } + }; +} diff --git a/packages/transformers/js/native.js b/packages/transformers/js/native.js index d211ea527b2..ce1d82238c9 100644 --- a/packages/transformers/js/native.js +++ b/packages/transformers/js/native.js @@ -18,7 +18,7 @@ if (process.env.PARCEL_BUILD_ENV === 'production') { } else if (process.env.PARCEL_SWC_WASM) { const {transform} = require('./wasm/dist-node/parcel_js_swc_wasm.js'); - module.exports.transform = function(config) { + module.exports.transform = function (config) { let result = transform(config); return { ...result, @@ -28,6 +28,4 @@ if (process.env.PARCEL_BUILD_ENV === 'production') { }; } else if (require('fs').existsSync(require('path').join(__dirname, name))) { module.exports = require(`./${name}`); -} else { - module.exports = require(`self-published/${name}`); } diff --git a/packages/transformers/js/package.json b/packages/transformers/js/package.json index 818e7d8766b..d735524eddb 100644 --- a/packages/transformers/js/package.json +++ b/packages/transformers/js/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-js", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -19,7 +19,7 @@ "name": "parcel-swc" }, "engines": { - "parcel": "^2.0.0-beta.1", + "parcel": "^2.0.1", "node": ">= 12.0.0" }, "files": [ @@ -30,10 +30,10 @@ "*.node" ], "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "@parcel/utils": "^2.0.1", "@swc/helpers": "^0.2.11", "browserslist": "^4.6.6", "detect-libc": "^1.0.3", @@ -43,8 +43,7 @@ "semver": "^5.4.1" }, "devDependencies": { - "@napi-rs/cli": "1.0.4", - "self-published": "npm:@parcel/transformer-js@2.0.0-rc.0" + "@napi-rs/cli": "1.0.4" }, "scripts": { "build": "napi build --platform --cargo-cwd napi", diff --git a/packages/transformers/js/src/JSTransformer.js b/packages/transformers/js/src/JSTransformer.js index 4a3eee31836..cd16019b0e2 100644 --- a/packages/transformers/js/src/JSTransformer.js +++ b/packages/transformers/js/src/JSTransformer.js @@ -14,8 +14,8 @@ import {validateSchema, remapSourceLocation} from '@parcel/utils'; import {isMatch} from 'micromatch'; const JSX_EXTENSIONS = { - '.jsx': true, - '.tsx': true, + jsx: true, + tsx: true, }; const JSX_PRAGMA = { @@ -117,14 +117,12 @@ const SCRIPT_ERRORS = { 'web-worker': { message: 'Web workers cannot have imports or exports without the `type: "module"` option.', - hint: - "Add {type: 'module'} as a second argument to the Worker constructor.", + hint: "Add {type: 'module'} as a second argument to the Worker constructor.", }, 'service-worker': { message: 'Service workers cannot have imports or exports without the `type: "module"` option.', - hint: - "Add {type: 'module'} as a second argument to the navigator.serviceWorker.register() call.", + hint: "Add {type: 'module'} as a second argument to the navigator.serviceWorker.register() call.", }, }; @@ -222,12 +220,7 @@ export default (new Transformer({ } } - isJSX = Boolean( - compilerOptions?.jsx || - pragma || - JSX_EXTENSIONS[path.extname(config.searchPath)], - ); - + isJSX = Boolean(compilerOptions?.jsx || pragma); decorators = compilerOptions?.experimentalDecorators; } @@ -359,6 +352,15 @@ export default (new Transformer({ let supportsModuleWorkers = asset.env.shouldScopeHoist && asset.env.supports('worker-module', true); + let isJSX = Boolean(config?.isJSX); + if (asset.isSource) { + if (asset.type === 'ts') { + isJSX = false; + } else if (!isJSX) { + isJSX = Boolean(JSX_EXTENSIONS[asset.type]); + } + } + let { dependencies, code: compiledCode, @@ -380,7 +382,7 @@ export default (new Transformer({ is_worker: asset.env.isWorker(), env, is_type_script: asset.type === 'ts' || asset.type === 'tsx', - is_jsx: Boolean(config?.isJSX), + is_jsx: isJSX, jsx_pragma: config?.pragma, jsx_pragma_frag: config?.pragmaFrag, automatic_jsx_runtime: Boolean(config?.automaticJSXRuntime), @@ -674,9 +676,8 @@ export default (new Transformer({ asset.meta.id = asset.id; if (hoist_result) { asset.symbols.ensure(); - for (let symbol in hoist_result.exported_symbols) { - let [local, loc] = hoist_result.exported_symbols[symbol]; - asset.symbols.set(symbol, local, convertLoc(loc)); + for (let {exported, local, loc} of hoist_result.exported_symbols) { + asset.symbols.set(exported, local, convertLoc(loc)); } let deps = new Map( @@ -688,25 +689,29 @@ export default (new Transformer({ dep.symbols.ensure(); } - for (let name in hoist_result.imported_symbols) { - let [specifier, exported, loc] = hoist_result.imported_symbols[name]; - let dep = deps.get(specifier); + for (let { + source, + local, + imported, + loc, + } of hoist_result.imported_symbols) { + let dep = deps.get(source); if (!dep) continue; - dep.symbols.set(exported, name, convertLoc(loc)); + dep.symbols.set(imported, local, convertLoc(loc)); } - for (let [name, specifier, exported, loc] of hoist_result.re_exports) { - let dep = deps.get(specifier); + for (let {source, local, imported, loc} of hoist_result.re_exports) { + let dep = deps.get(source); if (!dep) continue; - if (name === '*' && exported === '*') { + if (local === '*' && imported === '*') { dep.symbols.set('*', '*', convertLoc(loc), true); } else { let reExportName = - dep.symbols.get(exported)?.local ?? - `$${asset.id}$re_export$${name}`; - asset.symbols.set(name, reExportName); - dep.symbols.set(exported, reExportName, convertLoc(loc), true); + dep.symbols.get(imported)?.local ?? + `$${asset.id}$re_export$${local}`; + asset.symbols.set(local, reExportName); + dep.symbols.set(imported, reExportName, convertLoc(loc), true); } } diff --git a/packages/transformers/js/src/esmodule-helpers.js b/packages/transformers/js/src/esmodule-helpers.js index 926de91781b..21b672e3afb 100644 --- a/packages/transformers/js/src/esmodule-helpers.js +++ b/packages/transformers/js/src/esmodule-helpers.js @@ -1,25 +1,20 @@ -exports.interopDefault = function(a) { +exports.interopDefault = function (a) { return a && a.__esModule ? a : {default: a}; }; -exports.defineInteropFlag = function(a) { +exports.defineInteropFlag = function (a) { Object.defineProperty(a, '__esModule', {value: true}); }; -exports.exportAll = function(source, dest) { - Object.keys(source).forEach(function(key) { - if (key === 'default' || key === '__esModule') { - return; - } - - // Skip duplicate re-exports when they have the same value. - if (key in dest && dest[key] === source[key]) { +exports.exportAll = function (source, dest) { + Object.keys(source).forEach(function (key) { + if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) { return; } Object.defineProperty(dest, key, { enumerable: true, - get: function() { + get: function () { return source[key]; }, }); @@ -28,7 +23,7 @@ exports.exportAll = function(source, dest) { return dest; }; -exports.export = function(dest, destName, get) { +exports.export = function (dest, destName, get) { Object.defineProperty(dest, destName, { enumerable: true, get: get, diff --git a/packages/transformers/json/package.json b/packages/transformers/json/package.json index 5bd643d1cb3..3e9e75ad7cb 100644 --- a/packages/transformers/json/package.json +++ b/packages/transformers/json/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-json", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/JSONTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", "json5": "^2.1.0" } } diff --git a/packages/transformers/jsonld/package.json b/packages/transformers/jsonld/package.json index 6ed9d73e5d1..b9f10664f6d 100644 --- a/packages/transformers/jsonld/package.json +++ b/packages/transformers/jsonld/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-jsonld", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,14 +17,14 @@ "source": "src/JSONLDTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "scripts": { "test": "yarn workspace @parcel/integration-tests test -g jsonld" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/types": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", + "@parcel/types": "^2.0.1", "json5": "^2.1.2" } } diff --git a/packages/transformers/less/package.json b/packages/transformers/less/package.json index 6390677f667..8a49c3187b3 100644 --- a/packages/transformers/less/package.json +++ b/packages/transformers/less/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-less", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/LessTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", "less": "^4.1.1" } } diff --git a/packages/transformers/mdx/package.json b/packages/transformers/mdx/package.json index 29e10c7a1ee..983c32ebf18 100644 --- a/packages/transformers/mdx/package.json +++ b/packages/transformers/mdx/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-mdx", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/MDXTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { "@mdx-js/mdx": "^1.6.22", - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" }, "peerDependencies": { "@mdx-js/react": "^1.6.22" diff --git a/packages/transformers/postcss/package.json b/packages/transformers/postcss/package.json index b58607bc838..02f3c265424 100644 --- a/packages/transformers/postcss/package.json +++ b/packages/transformers/postcss/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-postcss", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,12 +17,12 @@ "source": "src/PostCSSTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/hash": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/hash": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "clone": "^2.1.1", "css-modules-loader-core": "^1.1.0", "nullthrows": "^1.1.1", diff --git a/packages/transformers/postcss/src/loadConfig.js b/packages/transformers/postcss/src/loadConfig.js index c2dd54fb41f..48cce81b222 100644 --- a/packages/transformers/postcss/src/loadConfig.js +++ b/packages/transformers/postcss/src/loadConfig.js @@ -104,6 +104,10 @@ export async function load({ options: PluginOptions, logger: PluginLogger, |}): Promise { + if (!config.isSource) { + return; + } + let configFile: any = await config.getConfig( ['.postcssrc', '.postcssrc.json', '.postcssrc.js', 'postcss.config.js'], {packageKey: 'postcss'}, diff --git a/packages/transformers/posthtml/package.json b/packages/transformers/posthtml/package.json index b9180495d18..3a0ac1bde60 100644 --- a/packages/transformers/posthtml/package.json +++ b/packages/transformers/posthtml/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-posthtml", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/PostHTMLTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "nullthrows": "^1.1.1", "posthtml": "^0.16.5", "posthtml-parser": "^0.10.1", diff --git a/packages/transformers/posthtml/src/PostHTMLTransformer.js b/packages/transformers/posthtml/src/PostHTMLTransformer.js index 49d3b3f7606..fa7c11f9323 100644 --- a/packages/transformers/posthtml/src/PostHTMLTransformer.js +++ b/packages/transformers/posthtml/src/PostHTMLTransformer.js @@ -13,6 +13,10 @@ import loadPlugins from './loadPlugins'; export default (new Transformer({ async loadConfig({config, options, logger}) { + if (!config.isSource) { + return; + } + let configFile = await config.getConfig( ['.posthtmlrc', '.posthtmlrc.js', 'posthtml.config.js'], { @@ -88,6 +92,7 @@ export default (new Transformer({ program: parse(await asset.getCode(), { lowerCaseAttributeNames: true, sourceLocations: true, + xmlMode: asset.type === 'xhtml', }), }; }, @@ -123,9 +128,11 @@ export default (new Transformer({ return [asset]; }, - generate({ast}) { + generate({ast, asset}) { return { - content: render(ast.program), + content: render(ast.program, { + closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined, + }), }; }, }): Transformer); diff --git a/packages/transformers/pug/package.json b/packages/transformers/pug/package.json index d943fefffce..a9768d4bc3f 100644 --- a/packages/transformers/pug/package.json +++ b/packages/transformers/pug/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-pug", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/PugTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", "pug": "^3.0.2" } } diff --git a/packages/transformers/raw/package.json b/packages/transformers/raw/package.json index 9cc735a5583..d9c8843978d 100644 --- a/packages/transformers/raw/package.json +++ b/packages/transformers/raw/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-raw", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,9 +17,9 @@ "source": "src/RawTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/transformers/react-refresh-wrap/package.json b/packages/transformers/react-refresh-wrap/package.json index 3c7c009f948..4ecdbafd086 100644 --- a/packages/transformers/react-refresh-wrap/package.json +++ b/packages/transformers/react-refresh-wrap/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-react-refresh-wrap", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/ReactRefreshWrapTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "react-refresh": "^0.9.0" } } diff --git a/packages/transformers/react-refresh-wrap/src/helpers/helpers.js b/packages/transformers/react-refresh-wrap/src/helpers/helpers.js index 430a792a949..0c265276013 100644 --- a/packages/transformers/react-refresh-wrap/src/helpers/helpers.js +++ b/packages/transformers/react-refresh-wrap/src/helpers/helpers.js @@ -2,21 +2,21 @@ var Refresh = require('react-refresh/runtime'); function debounce(func, delay) { if (process.env.NODE_ENV === 'test') { - return function(args) { + return function (args) { func.call(null, args); }; } else { var timeout = undefined; - return function(args) { + return function (args) { clearTimeout(timeout); - timeout = setTimeout(function() { + timeout = setTimeout(function () { timeout = undefined; func.call(null, args); }, delay); }; } } -var enqueueUpdate = debounce(function() { +var enqueueUpdate = debounce(function () { Refresh.performReactRefresh(); }, 30); @@ -24,19 +24,19 @@ var enqueueUpdate = debounce(function() { // https://github.com/facebook/metro/blob/61de16bd1edd7e738dd0311c89555a644023ab2d/packages/metro/src/lib/polyfills/require.js // MIT License - Copyright (c) Facebook, Inc. and its affiliates. -module.exports.prelude = function(module) { - window.$RefreshReg$ = function(type, id) { +module.exports.prelude = function (module) { + window.$RefreshReg$ = function (type, id) { Refresh.register(type, module.id + ' ' + id); }; window.$RefreshSig$ = Refresh.createSignatureFunctionForTransform; }; -module.exports.postlude = function(module) { +module.exports.postlude = function (module) { if (isReactRefreshBoundary(module.exports)) { registerExportsForReactRefresh(module); if (module.hot) { - module.hot.dispose(function(data) { + module.hot.dispose(function (data) { if (Refresh.hasUnrecoverableErrors()) { window.location.reload(); } @@ -44,7 +44,7 @@ module.exports.postlude = function(module) { data.prevExports = module.exports; }); - module.hot.accept(function(getParents) { + module.hot.accept(function (getParents) { var prevExports = module.hot.data.prevExports; var nextExports = module.exports; // Since we just executed the code for it, it's possible diff --git a/packages/transformers/sass/package.json b/packages/transformers/sass/package.json index eabeb59c87e..282c6a4e896 100644 --- a/packages/transformers/sass/package.json +++ b/packages/transformers/sass/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-sass", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/SassTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", "sass": "^1.38.0" } } diff --git a/packages/transformers/sass/src/SassTransformer.js b/packages/transformers/sass/src/SassTransformer.js index 571dfea09e8..2b198b0fbec 100644 --- a/packages/transformers/sass/src/SassTransformer.js +++ b/packages/transformers/sass/src/SassTransformer.js @@ -174,7 +174,7 @@ function resolvePathImporter({asset, resolve, includePaths, options}) { } } - return function(rawUrl, prev, done) { + return function (rawUrl, prev, done) { const url = rawUrl.replace(/^file:\/\//, ''); resolvePath(url, prev) .then(resolved => { diff --git a/packages/transformers/stylus/package.json b/packages/transformers/stylus/package.json index 2a46d2ebb09..2cdd3bab137 100644 --- a/packages/transformers/stylus/package.json +++ b/packages/transformers/stylus/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-stylus", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/StylusTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", - "stylus": "^0.54.5" + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", + "stylus": "^0.55.0" } } diff --git a/packages/transformers/sugarss/package.json b/packages/transformers/sugarss/package.json index df761288d21..5c6f5b89f79 100644 --- a/packages/transformers/sugarss/package.json +++ b/packages/transformers/sugarss/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-sugarss", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/SugarssTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", "postcss": "^8.3.0", "sugarss": "^3.0.3" } diff --git a/packages/transformers/svg-react/package.json b/packages/transformers/svg-react/package.json index c78b53eb96e..07fd2c19319 100644 --- a/packages/transformers/svg-react/package.json +++ b/packages/transformers/svg-react/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-svg-react", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/SvgReactTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", "@svgr/core": "^5.5.0", "@svgr/plugin-jsx": "^5.5.0", "@svgr/plugin-svgo": "^5.5.0", diff --git a/packages/transformers/svg/package.json b/packages/transformers/svg/package.json index 6d83419813f..a07df8f9cb3 100644 --- a/packages/transformers/svg/package.json +++ b/packages/transformers/svg/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-svg", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/SVGTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/hash": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/hash": "^2.0.1", + "@parcel/plugin": "^2.0.1", "nullthrows": "^1.1.1", "posthtml": "^0.16.5", "posthtml-parser": "^0.10.1", diff --git a/packages/transformers/svg/src/dependencies.js b/packages/transformers/svg/src/dependencies.js index 4e7415c4a06..c83074ae0c1 100644 --- a/packages/transformers/svg/src/dependencies.js +++ b/packages/transformers/svg/src/dependencies.js @@ -55,7 +55,8 @@ const FUNC_IRI_ATTRS = new Set([ ]); // https://www.w3.org/TR/css3-values/#urls -const FUNC_IRI_RE = /^url\((?:((['"])(.*?)\2(\s+.*)?)|((?:\\[\s'"]|[^\s'"])+))\)$/; +const FUNC_IRI_RE = + /^url\((?:((['"])(.*?)\2(\s+.*)?)|((?:\\[\s'"]|[^\s'"])+))\)$/; const ESCAPE_RE = /\\(.|\n|\r|\u2028|\u2029)/; export function parseFuncIRI(value: string): ?[string, string] { let m = value.match(FUNC_IRI_RE); diff --git a/packages/transformers/toml/package.json b/packages/transformers/toml/package.json index 07695e6777c..34535139848 100644 --- a/packages/transformers/toml/package.json +++ b/packages/transformers/toml/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-toml", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/TOMLTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { "@iarna/toml": "^2.2.3", - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/transformers/typescript-tsc/package.json b/packages/transformers/typescript-tsc/package.json index 29d664ae605..0cadc107fe5 100644 --- a/packages/transformers/typescript-tsc/package.json +++ b/packages/transformers/typescript-tsc/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-typescript-tsc", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,12 @@ "source": "src/TSCTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/ts-utils": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "@parcel/ts-utils": "^2.0.1" }, "devDependencies": { "typescript": ">=3.0.0" diff --git a/packages/transformers/typescript-tsc/src/TSCTransformer.js b/packages/transformers/typescript-tsc/src/TSCTransformer.js index a32102c487b..ae44f5d126a 100644 --- a/packages/transformers/typescript-tsc/src/TSCTransformer.js +++ b/packages/transformers/typescript-tsc/src/TSCTransformer.js @@ -5,13 +5,14 @@ import type {TranspileOptions} from 'typescript'; import {Transformer} from '@parcel/plugin'; import {loadTSConfig} from '@parcel/ts-utils'; import typescript from 'typescript'; +import SourceMap from '@parcel/source-map'; export default (new Transformer({ loadConfig({config, options}) { return loadTSConfig(config, options); }, - async transform({asset, config}) { + async transform({asset, config, options}) { asset.type = 'js'; let code = await asset.getCode(); @@ -29,15 +30,29 @@ export default (new Transformer({ // Don't compile ES `import`s -- scope hoisting prefers them and they will // otherwise compiled to CJS via babel in the js transformer module: typescript.ModuleKind.ESNext, + sourceMap: !!asset.env.sourceMap, }, fileName: asset.filePath, // Should be relativePath? }: TranspileOptions), ); + let map; + let {outputText, sourceMapText} = transpiled; + if (sourceMapText != null) { + map = new SourceMap(options.projectRoot); + map.addVLQMap(JSON.parse(sourceMapText)); + + outputText = outputText.substring( + 0, + outputText.lastIndexOf('//# sourceMappingURL'), + ); + } + return [ { type: 'js', - content: transpiled.outputText, + content: outputText, + map, }, ]; }, diff --git a/packages/transformers/typescript-types/package.json b/packages/transformers/typescript-types/package.json index 3795d800e17..fca17275c7c 100644 --- a/packages/transformers/typescript-types/package.json +++ b/packages/transformers/typescript-types/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-typescript-types", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,12 +17,13 @@ "source": "src/TSTypesTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", - "@parcel/ts-utils": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "@parcel/ts-utils": "^2.0.1", "nullthrows": "^1.1.1" }, "devDependencies": { diff --git a/packages/transformers/typescript-types/src/TSModule.js b/packages/transformers/typescript-types/src/TSModule.js index a3f786de963..e71ca5a9e43 100644 --- a/packages/transformers/typescript-types/src/TSModule.js +++ b/packages/transformers/typescript-types/src/TSModule.js @@ -8,7 +8,7 @@ export type Export = export class TSModule { imports: Map; exports: Array; - bindings: Map; + bindings: Map>; names: Map; used: Set; @@ -37,7 +37,9 @@ export class TSModule { } addLocal(name: string, node: any) { - this.bindings.set(name, node); + const bindings = this.bindings.get(name) ?? new Set(); + bindings.add(node); + this.bindings.set(name, bindings); if (name !== 'default') { this.names.set(name, name); } diff --git a/packages/transformers/typescript-types/src/TSModuleGraph.js b/packages/transformers/typescript-types/src/TSModuleGraph.js index 18eeed88893..e522b19ec17 100644 --- a/packages/transformers/typescript-types/src/TSModuleGraph.js +++ b/packages/transformers/typescript-types/src/TSModuleGraph.js @@ -64,9 +64,11 @@ export class TSModuleGraph { return ts.visitEachChild(node, visit, context); }; - let node = module.bindings.get(name); - if (node) { - ts.visitEachChild(node, visit, context); + let bindings = module.bindings.get(name); + if (bindings) { + for (let node of bindings) { + ts.visitEachChild(node, visit, context); + } } } diff --git a/packages/transformers/vue/package.json b/packages/transformers/vue/package.json index 121a512c0d6..56da83788e3 100644 --- a/packages/transformers/vue/package.json +++ b/packages/transformers/vue/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-vue", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,13 +17,13 @@ "source": "src/VueTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/source-map": "2.0.0-rc.7", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/source-map": "^2.0.0", + "@parcel/utils": "^2.0.1", "@vue/compiler-sfc": "^3.0.0", "consolidate": "^0.16.0", "nullthrows": "^1.1.1", diff --git a/packages/transformers/vue/src/VueTransformer.js b/packages/transformers/vue/src/VueTransformer.js index c01b3d6ea8f..d7c8de30485 100644 --- a/packages/transformers/vue/src/VueTransformer.js +++ b/packages/transformers/vue/src/VueTransformer.js @@ -207,7 +207,7 @@ async function processPipeline({ await resolve(asset.filePath, template.src), ) ).toString(); - template.lang = extname(template.src); + template.lang = extname(template.src).slice(1); } let content = template.content; if (template.lang && !['htm', 'html'].includes(template.lang)) { @@ -267,7 +267,7 @@ ${ await resolve(asset.filePath, script.src), ) ).toString(); - script.lang = extname(script.src); + script.lang = extname(script.src).slice(1); } let type; switch (script.lang || 'js') { @@ -275,10 +275,16 @@ ${ case 'js': type = 'js'; break; + case 'jsx': + type = 'jsx'; + break; case 'typescript': case 'ts': type = 'ts'; break; + case 'tsx': + type = 'tsx'; + break; case 'coffeescript': case 'coffee': type = 'coffee'; @@ -317,7 +323,7 @@ ${ if (!style.module) { style.module = MODULE_BY_NAME_RE.test(style.src); } - style.lang = extname(style.src); + style.lang = extname(style.src).slice(1); } switch (style.lang) { case 'less': diff --git a/packages/transformers/webextension/package.json b/packages/transformers/webextension/package.json index 59082a3a444..39db394cad8 100644 --- a/packages/transformers/webextension/package.json +++ b/packages/transformers/webextension/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-webextension", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -16,12 +16,12 @@ "main": "lib/WebExtensionTransformer.js", "source": "src/WebExtensionTransformer.js", "engines": { - "parcel": "^2.0.0-alpha.1.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "content-security-policy-parser": "^0.3.0", "json-source-map": "^0.6.1" } diff --git a/packages/transformers/webextension/src/runtime/autoreload-bg.js b/packages/transformers/webextension/src/runtime/autoreload-bg.js index b92a44743e1..4ff6e751e07 100644 --- a/packages/transformers/webextension/src/runtime/autoreload-bg.js +++ b/packages/transformers/webextension/src/runtime/autoreload-bg.js @@ -1,6 +1,6 @@ /* global window */ var env = window.chrome || window.browser; -env.runtime.onMessage.addListener(function(msg) { +env.runtime.onMessage.addListener(function (msg) { if (msg.__parcel_hmr_reload__) { env.runtime.reload(); } diff --git a/packages/transformers/webextension/src/runtime/autoreload.js b/packages/transformers/webextension/src/runtime/autoreload.js index d9f5babdb83..79f7577b42e 100644 --- a/packages/transformers/webextension/src/runtime/autoreload.js +++ b/packages/transformers/webextension/src/runtime/autoreload.js @@ -1,5 +1,5 @@ /* global window */ -window.addEventListener('beforeunload', function() { +window.addEventListener('beforeunload', function () { (window.chrome || window.browser).runtime.sendMessage({ __parcel_hmr_reload__: true, }); diff --git a/packages/transformers/webmanifest/package.json b/packages/transformers/webmanifest/package.json index 2dac3d942a5..f914f78b711 100644 --- a/packages/transformers/webmanifest/package.json +++ b/packages/transformers/webmanifest/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-webmanifest", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -16,12 +16,12 @@ "main": "lib/WebManifestTransformer.js", "source": "src/WebManifestTransformer.js", "engines": { - "parcel": "^2.0.0-alpha.1.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "json-source-map": "^0.6.1" } } diff --git a/packages/transformers/worklet/package.json b/packages/transformers/worklet/package.json index 6a99fa480b1..d2c60a7b811 100644 --- a/packages/transformers/worklet/package.json +++ b/packages/transformers/worklet/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-worklet", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,9 +17,9 @@ "source": "src/WorkletTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0" + "@parcel/plugin": "^2.0.1" } } diff --git a/packages/transformers/xml/package.json b/packages/transformers/xml/package.json new file mode 100644 index 00000000000..f6a69711ab7 --- /dev/null +++ b/packages/transformers/xml/package.json @@ -0,0 +1,26 @@ +{ + "name": "@parcel/transformer-xml", + "version": "2.0.1", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "repository": { + "type": "git", + "url": "https://github.com/parcel-bundler/parcel.git" + }, + "main": "lib/XMLTransformer.js", + "source": "src/XMLTransformer.js", + "engines": { + "node": ">= 12.0.0", + "parcel": "^2.0.1" + }, + "dependencies": { + "@parcel/plugin": "^2.0.1", + "@xmldom/xmldom": "^0.7.5" + } +} diff --git a/packages/transformers/xml/src/XMLTransformer.js b/packages/transformers/xml/src/XMLTransformer.js new file mode 100644 index 00000000000..5d2b02b1d46 --- /dev/null +++ b/packages/transformers/xml/src/XMLTransformer.js @@ -0,0 +1,55 @@ +// @flow +import {Transformer} from '@parcel/plugin'; +import {DOMParser, XMLSerializer} from '@xmldom/xmldom'; +import * as atom from './atom'; +import * as rss from './rss'; + +const HANDLERS = { + 'http://www.w3.org/2005/Atom': atom, +}; + +const NON_NAMESPACED_HANDLERS = { + rss, +}; + +export default (new Transformer({ + async transform({asset}) { + let code = await asset.getCode(); + let parser = new DOMParser(); + let dom = parser.parseFromString(code, 'application/xml'); + + let parts = []; + let nonNamespacedHandlers = !dom.documentElement.namespaceURI + ? NON_NAMESPACED_HANDLERS[dom.documentElement.nodeName] || {} + : {}; + + walk(dom, node => { + if (node.nodeType !== 1) { + return; + } + + let handler = node.namespaceURI + ? HANDLERS[node.namespaceURI]?.[node.localName] + : nonNamespacedHandlers[node.nodeName]; + + if (handler) { + handler(node, asset, parts); + } + }); + + code = new XMLSerializer().serializeToString(dom); + asset.setCode(code); + + return [asset, ...parts]; + }, +}): Transformer); + +function walk(element, visit) { + visit(element); + + element = element.firstChild; + while (element) { + walk(element, visit); + element = element.nextSibling; + } +} diff --git a/packages/transformers/xml/src/atom.js b/packages/transformers/xml/src/atom.js new file mode 100644 index 00000000000..0961d324e8b --- /dev/null +++ b/packages/transformers/xml/src/atom.js @@ -0,0 +1,73 @@ +// @flow +import type {MutableAsset, TransformerResult} from '@parcel/types'; +import {XMLSerializer} from '@xmldom/xmldom'; +import {urlHandler} from './utils'; + +// Handlers for elements defined by the Atom spec. +// See https://datatracker.ietf.org/doc/html/rfc4287 + +export function link(element: Element, asset: MutableAsset) { + let href = element.getAttribute('href'); + if (href) { + href = asset.addURLDependency(href, { + needsStableName: true, + }); + + element.setAttribute('href', href); + } +} + +export const icon = urlHandler; +export const logo = urlHandler; + +export function content( + element: Element, + asset: MutableAsset, + parts: Array, +) { + let type = element.getAttribute('type'); + let contents; + switch (type) { + case 'html': + contents = element.textContent; + element.textContent = ''; + break; + case 'xhtml': { + let fragment = element.ownerDocument.createDocumentFragment(); + let child = element.firstChild; + while (child) { + element.removeChild(child); + fragment.appendChild(child.cloneNode(true)); + child = child.nextSibling; + } + contents = new XMLSerializer().serializeToString(fragment); + break; + } + default: + return; + } + + if (contents) { + let parcelKey = `${asset.id}:${parts.length}`; + let el = element.ownerDocument.createElementNS( + 'https://parceljs.org', + 'inline', + ); + el.setAttribute('key', parcelKey); + el.setAttribute('type', type); + element.appendChild(el); + + asset.addDependency({ + specifier: parcelKey, + specifierType: 'esm', + bundleBehavior: 'inline', + }); + + parts.push({ + type, + content: contents, + uniqueKey: parcelKey, + bundleBehavior: 'inline', + }); + } +} diff --git a/packages/transformers/xml/src/rss.js b/packages/transformers/xml/src/rss.js new file mode 100644 index 00000000000..6da8b96efdc --- /dev/null +++ b/packages/transformers/xml/src/rss.js @@ -0,0 +1,52 @@ +// @flow +import type {MutableAsset, TransformerResult} from '@parcel/types'; +import {urlHandler} from './utils'; + +// Handlers for elements defined by the RSS spec. +// See https://validator.w3.org/feed/docs/rss2.html + +export const link = urlHandler; +export const url = urlHandler; +export const comments = urlHandler; + +export function enclosure(element: Element, asset: MutableAsset) { + let url = element.getAttribute('url'); + if (url) { + url = asset.addURLDependency(url, {}); + element.setAttribute('url', url); + } +} + +export function description( + element: Element, + asset: MutableAsset, + parts: Array, +) { + let parcelKey = `${asset.id}:${parts.length}`; + + asset.addDependency({ + specifier: parcelKey, + specifierType: 'esm', + bundleBehavior: 'inline', + }); + + parts.push({ + type: 'html', + content: element.textContent, + uniqueKey: parcelKey, + bundleBehavior: 'inline', + }); + + let child = element.firstChild; + while (child) { + element.removeChild(child); + child = child.nextSibling; + } + + let el = element.ownerDocument.createElementNS( + 'https://parceljs.org', + 'inline', + ); + el.setAttribute('key', parcelKey); + element.appendChild(el); +} diff --git a/packages/transformers/xml/src/utils.js b/packages/transformers/xml/src/utils.js new file mode 100644 index 00000000000..c1083c9fff3 --- /dev/null +++ b/packages/transformers/xml/src/utils.js @@ -0,0 +1,8 @@ +// @flow +import type {MutableAsset} from '@parcel/types'; + +export function urlHandler(element: Element, asset: MutableAsset) { + element.textContent = asset.addURLDependency(element.textContent.trim(), { + needsStableName: true, + }); +} diff --git a/packages/transformers/yaml/package.json b/packages/transformers/yaml/package.json index acefaec94db..f140fa7df04 100644 --- a/packages/transformers/yaml/package.json +++ b/packages/transformers/yaml/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/transformer-yaml", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,10 +17,10 @@ "source": "src/YAMLTransformer.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", "js-yaml": "^3.10.0" } } diff --git a/packages/utils/babel-plugin-transform-runtime/package.json b/packages/utils/babel-plugin-transform-runtime/package.json index 954e617caf1..77285812db3 100644 --- a/packages/utils/babel-plugin-transform-runtime/package.json +++ b/packages/utils/babel-plugin-transform-runtime/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/babel-plugin-transform-runtime", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -23,6 +23,6 @@ }, "devDependencies": { "@babel/core": "^7.12.0", - "@parcel/babel-preset-env": "2.0.0-rc.0" + "@parcel/babel-preset-env": "^2.0.1" } } diff --git a/packages/utils/babel-plugin-transform-runtime/src/index.js b/packages/utils/babel-plugin-transform-runtime/src/index.js index 9e5d90b4fef..09e3015f662 100644 --- a/packages/utils/babel-plugin-transform-runtime/src/index.js +++ b/packages/utils/babel-plugin-transform-runtime/src/index.js @@ -1,6 +1,6 @@ const semver = require('semver'); -const pluginTransformRuntime = require('@babel/plugin-transform-runtime') - .default; +const pluginTransformRuntime = + require('@babel/plugin-transform-runtime').default; const COMPATIBLE_PARCEL_BABEL_TRANSFORMER_SEMVER = '^2.0.0-alpha.1.1'; diff --git a/packages/utils/babel-preset-env/package.json b/packages/utils/babel-preset-env/package.json index 6ce766af130..8170a22df15 100644 --- a/packages/utils/babel-preset-env/package.json +++ b/packages/utils/babel-preset-env/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/babel-preset-env", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/utils/babylon-walk/package.json b/packages/utils/babylon-walk/package.json index b3e736ef7c2..c7250afdfab 100755 --- a/packages/utils/babylon-walk/package.json +++ b/packages/utils/babylon-walk/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/babylon-walk", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -10,6 +10,11 @@ "url": "https://opencollective.com/parcel" }, "description": "Lightweight Babylon AST traversal", + "repository": { + "type": "git", + "url": "https://github.com/parcel-bundler/parcel.git", + "directory": "packages/utils/babylon-walk" + }, "main": "lib/index.js", "source": "src/index.js", "engines": { diff --git a/packages/utils/babylon-walk/src/index.js b/packages/utils/babylon-walk/src/index.js index f2b9097d212..8f82f484f97 100755 --- a/packages/utils/babylon-walk/src/index.js +++ b/packages/utils/babylon-walk/src/index.js @@ -106,9 +106,8 @@ export function recursive( ) { if (!node) return; - const visitors = explode<(any, T, recurse: (Node) => void) => void>( - _visitors, - ); + const visitors = + explode<(any, T, recurse: (Node) => void) => void>(_visitors); (function c(node) { if (!node) return; diff --git a/packages/utils/create-react-app/package.json b/packages/utils/create-react-app/package.json index 032f4063e9f..2013e0e09d7 100644 --- a/packages/utils/create-react-app/package.json +++ b/packages/utils/create-react-app/package.json @@ -1,10 +1,15 @@ { "name": "@parcel/create-react-app", - "version": "2.0.0-rc.0", + "version": "2.0.1", "bin": { "parcel-create-react-app": "src/bin.js" }, "main": "lib/bin.js", + "repository": { + "type": "git", + "url": "https://github.com/parcel-bundler/parcel.git", + "directory": "packages/utils/create-react-app" + }, "source": "src/bin.js", "files": [ "templates", @@ -26,6 +31,6 @@ "v8-compile-cache": "^2.0.0" }, "devDependencies": { - "@parcel/babel-register": "2.0.0-rc.0" + "@parcel/babel-register": "^2.0.1" } } diff --git a/packages/utils/events/package.json b/packages/utils/events/package.json index 1b2cb572a74..ff93eef8a46 100644 --- a/packages/utils/events/package.json +++ b/packages/utils/events/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/events", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/utils/fs-search/index.js b/packages/utils/fs-search/index.js index 55c88411063..b2b2fda0387 100644 --- a/packages/utils/fs-search/index.js +++ b/packages/utils/fs-search/index.js @@ -17,6 +17,4 @@ if (process.env.PARCEL_BUILD_ENV === 'production') { module.exports = require(name); } else if (require('fs').existsSync(require('path').join(__dirname, name))) { module.exports = require(name); -} else { - module.exports = require('self-published'); } diff --git a/packages/utils/fs-search/package.json b/packages/utils/fs-search/package.json index a2d2a5a66bb..eb02e839e94 100644 --- a/packages/utils/fs-search/package.json +++ b/packages/utils/fs-search/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/fs-search", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -31,7 +31,6 @@ "detect-libc": "^1.0.3" }, "devDependencies": { - "@napi-rs/cli": "1.0.4", - "self-published": "npm:@parcel/fs-search@2.0.0-rc.0" + "@napi-rs/cli": "1.0.4" } } diff --git a/packages/utils/fs-write-stream-atomic/package.json b/packages/utils/fs-write-stream-atomic/package.json index 38eaa6ef342..7a1eda5b6b7 100644 --- a/packages/utils/fs-write-stream-atomic/package.json +++ b/packages/utils/fs-write-stream-atomic/package.json @@ -1,8 +1,13 @@ { "name": "@parcel/fs-write-stream-atomic", - "version": "2.0.0-rc.0", + "version": "2.0.1", "description": "Like `fs.createWriteStream(...)`, but atomic.", "main": "index.js", + "repository": { + "type": "git", + "url": "https://github.com/parcel-bundler/parcel.git", + "directory": "packages/utils/fs-write-stream-atomic" + }, "directories": { "test": "test" }, diff --git a/packages/utils/fs-write-stream-atomic/test/basic.js b/packages/utils/fs-write-stream-atomic/test/basic.js index c1fcec29082..af3d6f438ba 100644 --- a/packages/utils/fs-write-stream-atomic/test/basic.js +++ b/packages/utils/fs-write-stream-atomic/test/basic.js @@ -4,13 +4,13 @@ var path = require('path'); var writeStream = require('../index.js'); var rename = fs.rename; -fs.rename = function(from, to, cb) { - setTimeout(function() { +fs.rename = function (from, to, cb) { + setTimeout(function () { rename(from, to, cb); }, 100); }; -test('basic', function(t) { +test('basic', function (t) { // open 10 write streams to the same file. // then write to each of them, and to the target // and verify at the end that each of them does their thing @@ -31,7 +31,7 @@ test('basic', function(t) { } function verifier(ev, num) { - return function() { + return function () { if (ev === 'close') { t.equal(this.__emittedFinish, true, num + '. closed only after finish'); } else { @@ -42,44 +42,45 @@ test('basic', function(t) { // make sure that one of the atomic streams won. var res = fs.readFileSync(target, 'utf8'); var lines = res.trim().split(/\n/); - lines.forEach(function(line, lineno) { + lines.forEach(function (line, lineno) { var first = lines[0].match(/\d+$/)[0]; var cur = line.match(/\d+$/)[0]; t.equal(cur, first, num + '. line ' + lineno + ' matches'); }); - var resExpr = /^first write \d+\nsecond write \d+\nthird write \d+\nfinal write \d+\n$/; + var resExpr = + /^first write \d+\nsecond write \d+\nthird write \d+\nfinal write \d+\n$/; t.similar(res, resExpr, num + '. content matches'); }; } // now write something to each stream. - streams.forEach(function(stream, i) { + streams.forEach(function (stream, i) { stream.write('first write ' + i + '\n'); }); // wait a sec for those writes to go out. - setTimeout(function() { + setTimeout(function () { // write something else to the target. fs.writeFileSync(target, 'brutality!\n'); // write some more stuff. - streams.forEach(function(stream, i) { + streams.forEach(function (stream, i) { stream.write('second write ' + i + '\n'); }); - setTimeout(function() { + setTimeout(function () { // Oops! Deleted the file! fs.unlinkSync(target); // write some more stuff. - streams.forEach(function(stream, i) { + streams.forEach(function (stream, i) { stream.write('third write ' + i + '\n'); }); - setTimeout(function() { + setTimeout(function () { fs.writeFileSync(target, 'brutality TWO!\n'); - streams.forEach(function(stream, i) { + streams.forEach(function (stream, i) { stream.end('final write ' + i + '\n'); }); }, 50); @@ -87,12 +88,12 @@ test('basic', function(t) { }, 50); }); -test('cleanup', function(t) { +test('cleanup', function (t) { fs.readdirSync(__dirname) - .filter(function(f) { + .filter(function (f) { return f.match(/^test.txt/); }) - .forEach(function(file) { + .forEach(function (file) { fs.unlinkSync(path.resolve(__dirname, file)); }); t.end(); diff --git a/packages/utils/fs-write-stream-atomic/test/chown.js b/packages/utils/fs-write-stream-atomic/test/chown.js index 6e2e0bdc4e4..8aea481f4e7 100644 --- a/packages/utils/fs-write-stream-atomic/test/chown.js +++ b/packages/utils/fs-write-stream-atomic/test/chown.js @@ -7,42 +7,42 @@ var writeStream = require('../index.js'); var target = path.resolve(__dirname, 'test-chown'); -test('chown works', function(t) { +test('chown works', function (t) { t.plan(1); var stream = writeStream(target, { chown: {uid: process.getuid(), gid: process.getgid()}, }); var hadError = false; - stream.on('error', function(er) { + stream.on('error', function (er) { hadError = true; console.log('#', er); }); - stream.on('close', function() { + stream.on('close', function () { t.is(hadError, false, 'no errors before close'); }); stream.end(); }); -test('chown fails', function(t) { +test('chown fails', function (t) { t.plan(1); - fs.chown = function(file, uid, gid, cb) { + fs.chown = function (file, uid, gid, cb) { cb(new Error('TEST BREAK')); }; var stream = writeStream(target, { chown: {uid: process.getuid(), gid: process.getgid()}, }); var hadError = false; - stream.on('error', function(er) { + stream.on('error', function (er) { hadError = true; console.log('#', er); }); - stream.on('close', function() { + stream.on('close', function () { t.is(hadError, true, 'error before close'); }); stream.end(); }); -test('cleanup', function(t) { +test('cleanup', function (t) { rimraf.sync(target); t.end(); }); diff --git a/packages/utils/fs-write-stream-atomic/test/rename-eperm.js b/packages/utils/fs-write-stream-atomic/test/rename-eperm.js index 7e799369a20..32ce1f6933c 100644 --- a/packages/utils/fs-write-stream-atomic/test/rename-eperm.js +++ b/packages/utils/fs-write-stream-atomic/test/rename-eperm.js @@ -9,18 +9,18 @@ var target = path.resolve(__dirname, 'test-rename-eperm1'); var target2 = path.resolve(__dirname, 'test-rename-eperm2'); var target3 = path.resolve(__dirname, 'test-rename-eperm3'); -test('rename eperm none existing file', function(t) { +test('rename eperm none existing file', function (t) { t.plan(2); var _rename = fs.rename; - fs.existsSync = function(src) { + fs.existsSync = function (src) { return true; }; - fs.rename = function(src, dest, cb) { + fs.rename = function (src, dest, cb) { // simulate a failure during rename where the file // is renamed successfully but the process encounters // an EPERM error and the target file does not exist - _rename(src, dest, function(e) { + _rename(src, dest, function (e) { var err = new Error('TEST BREAK'); err.syscall = 'rename'; err.code = 'EPERM'; @@ -31,14 +31,14 @@ test('rename eperm none existing file', function(t) { var stream = writeStream(target, {isWin: true}); var hadError = false; var calledFinish = false; - stream.on('error', function(er) { + stream.on('error', function (er) { hadError = true; console.log('#', er); }); - stream.on('finish', function() { + stream.on('finish', function () { calledFinish = true; }); - stream.on('close', function() { + stream.on('close', function () { t.is(hadError, true, 'error was caught'); t.is(calledFinish, false, 'finish was called before close'); }); @@ -46,25 +46,25 @@ test('rename eperm none existing file', function(t) { }); // test existing file with diff. content -test('rename eperm existing file different content', function(t) { +test('rename eperm existing file different content', function (t) { t.plan(2); var _rename = fs.rename; - fs.existsSync = function(src) { + fs.existsSync = function (src) { return true; }; - fs.rename = function(src, dest, cb) { + fs.rename = function (src, dest, cb) { // simulate a failure during rename where the file // is renamed successfully but the process encounters // an EPERM error and the target file that has another content than the // destination - _rename(src, dest, function(e) { - fs.writeFile(src, 'dest', function(writeErr) { + _rename(src, dest, function (e) { + fs.writeFile(src, 'dest', function (writeErr) { if (writeErr) { return console.log('WRITEERR: ' + writeErr); } - fs.writeFile(target2, 'target', function(writeErr) { + fs.writeFile(target2, 'target', function (writeErr) { if (writeErr) { return console.log('WRITEERR: ' + writeErr); } @@ -81,14 +81,14 @@ test('rename eperm existing file different content', function(t) { var stream = writeStream(target2, {isWin: true}); var hadError = false; var calledFinish = false; - stream.on('error', function(er) { + stream.on('error', function (er) { hadError = true; console.log('#', er); }); - stream.on('finish', function() { + stream.on('finish', function () { calledFinish = true; }); - stream.on('close', function() { + stream.on('close', function () { t.is(hadError, true, 'error was caught'); t.is(calledFinish, false, 'finish was called before close'); }); @@ -97,25 +97,25 @@ test('rename eperm existing file different content', function(t) { // test existing file with the same content // test existing file with diff. content -test('rename eperm existing file different content', function(t) { +test('rename eperm existing file different content', function (t) { t.plan(2); var _rename = fs.rename; - fs.existsSync = function(src) { + fs.existsSync = function (src) { return true; }; - fs.rename = function(src, dest, cb) { + fs.rename = function (src, dest, cb) { // simulate a failure during rename where the file // is renamed successfully but the process encounters // an EPERM error and the target file that has the same content than the // destination - _rename(src, dest, function(e) { - fs.writeFile(src, 'target2', function(writeErr) { + _rename(src, dest, function (e) { + fs.writeFile(src, 'target2', function (writeErr) { if (writeErr) { return console.log('WRITEERR: ' + writeErr); } - fs.writeFile(target3, 'target2', function(writeErr) { + fs.writeFile(target3, 'target2', function (writeErr) { if (writeErr) { return console.log('WRITEERR: ' + writeErr); } @@ -132,21 +132,21 @@ test('rename eperm existing file different content', function(t) { var stream = writeStream(target3, {isWin: true}); var hadError = false; var calledFinish = false; - stream.on('error', function(er) { + stream.on('error', function (er) { hadError = true; console.log('#', er); }); - stream.on('finish', function() { + stream.on('finish', function () { calledFinish = true; }); - stream.on('close', function() { + stream.on('close', function () { t.is(hadError, false, 'error was caught'); t.is(calledFinish, true, 'finish was called before close'); }); stream.end(); }); -test('cleanup', function(t) { +test('cleanup', function (t) { rimraf.sync(target); rimraf.sync(target2); rimraf.sync(target3); diff --git a/packages/utils/fs-write-stream-atomic/test/rename-fail.js b/packages/utils/fs-write-stream-atomic/test/rename-fail.js index cbe8c535f8a..f4a4c0af6cc 100644 --- a/packages/utils/fs-write-stream-atomic/test/rename-fail.js +++ b/packages/utils/fs-write-stream-atomic/test/rename-fail.js @@ -7,24 +7,24 @@ var writeStream = require('../index.js'); var target = path.resolve(__dirname, 'test-rename'); -test('rename fails', function(t) { +test('rename fails', function (t) { t.plan(1); - fs.rename = function(src, dest, cb) { + fs.rename = function (src, dest, cb) { cb(new Error('TEST BREAK')); }; var stream = writeStream(target); var hadError = false; - stream.on('error', function(er) { + stream.on('error', function (er) { hadError = true; console.log('#', er); }); - stream.on('close', function() { + stream.on('close', function () { t.is(hadError, true, 'error before close'); }); stream.end(); }); -test('cleanup', function(t) { +test('cleanup', function (t) { rimraf.sync(target); t.end(); }); diff --git a/packages/utils/fs-write-stream-atomic/test/slow-close.js b/packages/utils/fs-write-stream-atomic/test/slow-close.js index d51548a66e1..ec9e0832def 100644 --- a/packages/utils/fs-write-stream-atomic/test/slow-close.js +++ b/packages/utils/fs-write-stream-atomic/test/slow-close.js @@ -7,7 +7,7 @@ var writeStream = require('../index.js'); var target = path.resolve(__dirname, 'test-chown'); -test('slow close', function(t) { +test('slow close', function (t) { t.plan(2); // The goal here is to simulate the "file close" step happening so slowly // that the whole close/rename process could finish before the file is @@ -17,10 +17,10 @@ test('slow close', function(t) { // turn, could break other layers that tried to read the new file. var realEmit = fs.WriteStream.prototype.emit; var reallyClosed = false; - fs.WriteStream.prototype.emit = function(event) { + fs.WriteStream.prototype.emit = function (event) { if (event !== 'close') return realEmit.apply(this, arguments); setTimeout( - function() { + function () { reallyClosed = true; realEmit.call(this, 'close'); }.bind(this), @@ -28,16 +28,16 @@ test('slow close', function(t) { ); }; var stream = writeStream(target); - stream.on('finish', function() { + stream.on('finish', function () { t.is(reallyClosed, true, "didn't finish before target was closed"); }); - stream.on('close', function() { + stream.on('close', function () { t.is(reallyClosed, true, "didn't close before target was closed"); }); stream.end(); }); -test('cleanup', function(t) { +test('cleanup', function (t) { rimraf.sync(target); t.end(); }); diff --git a/packages/utils/fs-write-stream-atomic/test/thread-id.js b/packages/utils/fs-write-stream-atomic/test/thread-id.js index 977b3468441..850fafe770d 100644 --- a/packages/utils/fs-write-stream-atomic/test/thread-id.js +++ b/packages/utils/fs-write-stream-atomic/test/thread-id.js @@ -9,25 +9,25 @@ try { Worker = require('worker_threads').Worker; } catch (e) {} -test('the main process has thread -1', function(t) { +test('the main process has thread -1', function (t) { t.equal(threadId, -1); t.end(); }); if (Worker != null) { - test('workers have positive integer threadIds', function(t) { + test('workers have positive integer threadIds', function (t) { t.plan(2); var w1 = new Worker( path.join(__dirname, '../fixtures/thread-id-test-worker.js'), ); - w1.once('message', function(message) { + w1.once('message', function (message) { t.equal(message, 1); }); var w2 = new Worker( path.join(__dirname, '../fixtures/thread-id-test-worker.js'), ); - w2.once('message', function(message) { + w2.once('message', function (message) { t.equal(message, 2); }); }); diff --git a/packages/utils/fs-write-stream-atomic/test/toolong.js b/packages/utils/fs-write-stream-atomic/test/toolong.js index 1f15232908c..40cf5e8a435 100644 --- a/packages/utils/fs-write-stream-atomic/test/toolong.js +++ b/packages/utils/fs-write-stream-atomic/test/toolong.js @@ -12,11 +12,11 @@ function repeat(times, string) { var target = path.resolve(__dirname, repeat(1000, 'test')); -test('name too long', function(t) { +test('name too long', function (t) { t.plan(2); var stream = writeStream(target); var hadError = false; - stream.on('error', function(er) { + stream.on('error', function (er) { if (!hadError) { t.is( er.code, @@ -26,7 +26,7 @@ test('name too long', function(t) { hadError = true; } }); - stream.on('close', function() { + stream.on('close', function () { t.ok(hadError, 'got error before close'); }); stream.end(); diff --git a/packages/utils/hash/index.js b/packages/utils/hash/index.js index 8a62a4dbcb3..7d873c47a22 100644 --- a/packages/utils/hash/index.js +++ b/packages/utils/hash/index.js @@ -17,9 +17,6 @@ if (process.env.PARCEL_BUILD_ENV === 'production') { module.exports = require(name); } else if (require('fs').existsSync(require('path').join(__dirname, name))) { module.exports = require(name); -} else { - // This has to be published first... - // module.exports = require('self-published'); } module.exports.init = Promise.resolve(); diff --git a/packages/utils/hash/package.json b/packages/utils/hash/package.json index 087f44a7dd4..0180541720d 100644 --- a/packages/utils/hash/package.json +++ b/packages/utils/hash/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/hash", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "main": "index.js", "browser": "browser.js", diff --git a/packages/utils/node-libs-browser/package.json b/packages/utils/node-libs-browser/package.json index 974594230a4..2fbd939b0b7 100755 --- a/packages/utils/node-libs-browser/package.json +++ b/packages/utils/node-libs-browser/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/node-libs-browser", - "version": "2.0.0-rc.0", + "version": "2.0.1", "author": "Tobias Koppers @sokra", "description": "The node core libs for in browser usage.", "license": "MIT", diff --git a/packages/utils/node-resolver-core/package.json b/packages/utils/node-resolver-core/package.json index ff8b9502b3c..0c81d8c77b2 100644 --- a/packages/utils/node-resolver-core/package.json +++ b/packages/utils/node-resolver-core/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/node-resolver-core", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -19,11 +19,10 @@ "node": ">= 12.0.0" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/node-libs-browser": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", - "micromatch": "^3.0.4", - "nullthrows": "^1.1.1", - "querystring": "^0.2.0" + "@parcel/diagnostic": "^2.0.1", + "@parcel/node-libs-browser": "^2.0.1", + "@parcel/utils": "^2.0.1", + "micromatch": "^4.0.4", + "nullthrows": "^1.1.1" } } diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index 107011841c9..9d5bdb4c359 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -6,7 +6,6 @@ import type { ResolveResult, Environment, SpecifierType, - QueryParameters, } from '@parcel/types'; import type {FileSystem} from '@parcel/fs'; @@ -27,10 +26,8 @@ import ThrowableDiagnostic, { import micromatch from 'micromatch'; import builtins, {empty} from './builtins'; import nullthrows from 'nullthrows'; -// $FlowFixMe this is untyped import _Module from 'module'; import {fileURLToPath} from 'url'; -import {parse as parseQueryString} from 'querystring'; const EMPTY_SHIM = require.resolve('./_empty'); @@ -61,7 +58,7 @@ type Module = {| moduleDir?: FilePath, filePath?: FilePath, code?: string, - query?: QueryParameters, + query?: URLSearchParams, |}; type ResolverContext = {| @@ -420,7 +417,7 @@ export default class NodeResolver { filename: string, dir: string, specifierType: SpecifierType, - ): Promise { + ): Promise { let url; switch (filename[0]) { case '/': { @@ -526,7 +523,7 @@ export default class NodeResolver { return { filePath, - query: url.search ? parseQueryString(url.search.slice(1)) : undefined, + query: url.search ? new URLSearchParams(url.search) : undefined, }; } else { // CommonJS specifier. Query params are not supported. @@ -1086,6 +1083,10 @@ export default class NodeResolver { for (let key in aliases) { let val = aliases[key]; if (typeof val === 'string' && isGlob(key)) { + // https://github.com/micromatch/picomatch/issues/77 + if (filename.startsWith('./')) { + filename = filename.slice(2); + } let re = micromatch.makeRe(key, {capture: true}); if (re.test(filename)) { alias = filename.replace(re, val); @@ -1169,13 +1170,21 @@ export default class NodeResolver { case 'boolean': return pkg.sideEffects; case 'string': { - let sideEffects = pkg.sideEffects; - invariant(typeof sideEffects === 'string'); - return micromatch.isMatch( - path.relative(pkg.pkgdir, filePath), - sideEffects, - {matchBase: true}, - ); + let glob = pkg.sideEffects; + invariant(typeof glob === 'string'); + + let relative = path.relative(pkg.pkgdir, filePath); + if (!glob.includes('/')) { + glob = `**/${glob}`; + } + + // Trim off "./" to make micromatch behave correctly, + // `path.relative` never returns a leading "./" + if (glob.startsWith('./')) { + glob = glob.substr(2); + } + + return micromatch.isMatch(relative, glob, {dot: true}); } case 'object': return pkg.sideEffects.some(sideEffects => diff --git a/packages/utils/node-resolver-core/src/builtins.js b/packages/utils/node-resolver-core/src/builtins.js index 394997ae7ca..9bc5b16470d 100644 --- a/packages/utils/node-resolver-core/src/builtins.js +++ b/packages/utils/node-resolver-core/src/builtins.js @@ -1,6 +1,6 @@ -// @flow -import polyfills from '@parcel/node-libs-browser'; +// @flow strict-local // $FlowFixMe this is untyped +import polyfills from '@parcel/node-libs-browser'; import {builtinModules} from 'module'; export const empty: string = require.resolve('./_empty.js'); diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/a/index.js b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/a/index.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/b/index.js b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/b/index.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/package.json b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/package.json new file mode 100644 index 00000000000..f748689fc82 --- /dev/null +++ b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/package.json @@ -0,0 +1,8 @@ +{ + "name": "side-effects-false-glob", + "sideEffects": [ + "a/*.js", + "./sub/*.js", + "*.json" + ] +} diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/a/index.js b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/a/index.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/b/index.js b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/b/index.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/index.js b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/index.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/index.json b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/index.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/packages/utils/node-resolver-core/test/fixture/node_modules/side-effects-false-glob/sub/index.json @@ -0,0 +1 @@ +{} diff --git a/packages/utils/node-resolver-core/test/resolver.js b/packages/utils/node-resolver-core/test/resolver.js index 9746ae63d55..dce617a5e9d 100644 --- a/packages/utils/node-resolver-core/test/resolver.js +++ b/packages/utils/node-resolver-core/test/resolver.js @@ -35,10 +35,10 @@ const BROWSER_ENV = new Environment( DEFAULT_OPTIONS, ); -describe('resolver', function() { +describe('resolver', function () { let resolver; - beforeEach(async function() { + beforeEach(async function () { await overlayFS.mkdirp(rootDir); await ncp(rootDir, rootDir); @@ -74,8 +74,8 @@ describe('resolver', function() { configCache.clear(); }); - describe('file paths', function() { - it('should resolve a relative path with an extension', async function() { + describe('file paths', function () { + it('should resolve a relative path with an extension', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './bar.js', @@ -85,7 +85,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve a relative path without an extension', async function() { + it('should resolve a relative path without an extension', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './bar', @@ -95,7 +95,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve an absolute path from the root module', async function() { + it('should resolve an absolute path from the root module', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '/bar', @@ -105,7 +105,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve an absolute path from a node_modules folder', async function() { + it('should resolve an absolute path from a node_modules folder', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '/bar', @@ -115,7 +115,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve a tilde path from the root module', async function() { + it('should resolve a tilde path from the root module', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '~/bar', @@ -125,7 +125,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve a tilde path from the root module without a slash', async function() { + it('should resolve a tilde path from the root module without a slash', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '~bar', @@ -135,7 +135,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve a tilde path from a node_modules folder', async function() { + it('should resolve a tilde path from a node_modules folder', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '~/bar', @@ -148,7 +148,7 @@ describe('resolver', function() { ); }); - it('should resolve an index file in a directory', async function() { + it('should resolve an index file in a directory', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './nested', @@ -161,7 +161,7 @@ describe('resolver', function() { ); }); - it('should not resolve an index file in a directory for URL specifiers', async function() { + it('should not resolve an index file in a directory for URL specifiers', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './nested', @@ -173,7 +173,7 @@ describe('resolver', function() { ]); }); - it('should resolve a file with a question mark with CommonJS specifiers', async function() { + it('should resolve a file with a question mark with CommonJS specifiers', async function () { // Windows filenames cannot contain question marks. if (process.platform === 'win32') { return; @@ -190,7 +190,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'a?b.js')); }); - it('should not resolve a file with a question mark with ESM specifiers', async function() { + it('should not resolve a file with a question mark with ESM specifiers', async function () { // Windows filenames cannot contain question marks. if (process.platform === 'win32') { return; @@ -209,7 +209,7 @@ describe('resolver', function() { ]); }); - it('should resolve a file with an encoded question mark with ESM specifiers', async function() { + it('should resolve a file with an encoded question mark with ESM specifiers', async function () { // Windows filenames cannot contain question marks. if (process.platform === 'win32') { return; @@ -226,7 +226,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'a?b.js')); }); - it('should not support percent encoding in CommonJS specifiers', async function() { + it('should not support percent encoding in CommonJS specifiers', async function () { // Windows filenames cannot contain question marks. if (process.platform === 'win32') { return; @@ -248,7 +248,7 @@ describe('resolver', function() { ]); }); - it('should support query params for ESM specifiers', async function() { + it('should support query params for ESM specifiers', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './nested?foo=bar', @@ -259,10 +259,10 @@ describe('resolver', function() { nullthrows(resolved).filePath, path.join(rootDir, 'nested', 'index.js'), ); - assert.deepEqual(nullthrows(resolved).query, {foo: 'bar'}); + assert.deepEqual(nullthrows(resolved).query?.toString(), 'foo=bar'); }); - it('should not support query params for CommonJS specifiers', async function() { + it('should not support query params for CommonJS specifiers', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './nested?foo=bar', @@ -275,8 +275,8 @@ describe('resolver', function() { }); }); - describe('builtins', function() { - it('should resolve node builtin modules', async function() { + describe('builtins', function () { + it('should resolve node builtin modules', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'zlib', @@ -308,7 +308,7 @@ describe('resolver', function() { }); }); - it('Should be able to handle node: prefixes', async function() { + it('Should be able to handle node: prefixes', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'node:zlib', @@ -340,7 +340,7 @@ describe('resolver', function() { }); }); - it('should resolve unimplemented node builtin modules to an empty file', async function() { + it('should resolve unimplemented node builtin modules to an empty file', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'fs', @@ -372,7 +372,7 @@ describe('resolver', function() { }); }); - it('should error when resolving node builtin modules with --target=node', async function() { + it('should error when resolving node builtin modules with --target=node', async function () { let resolved = await resolver.resolve({ env: NODE_ENV, filename: 'zlib', @@ -382,7 +382,7 @@ describe('resolver', function() { assert.deepEqual(resolved, {isExcluded: true}); }); - it('should exclude the electron module in electron environments', async function() { + it('should exclude the electron module in electron environments', async function () { let resolved = await resolver.resolve({ env: new Environment( createEnvironment({ @@ -401,8 +401,8 @@ describe('resolver', function() { }); }); - describe('node_modules', function() { - it('should resolve a node_modules index.js', async function() { + describe('node_modules', function () { + it('should resolve a node_modules index.js', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'foo', @@ -434,7 +434,7 @@ describe('resolver', function() { }); }); - it('should resolve a node_modules package.main', async function() { + it('should resolve a node_modules package.main', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-main', @@ -466,7 +466,7 @@ describe('resolver', function() { }); }); - it('should resolve a node_modules package.module', async function() { + it('should resolve a node_modules package.module', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-module', @@ -503,7 +503,7 @@ describe('resolver', function() { }); }); - it('should resolve a node_modules package.browser main field', async function() { + it('should resolve a node_modules package.browser main field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-browser', @@ -540,7 +540,7 @@ describe('resolver', function() { }); }); - it('should not resolve a node_modules package.browser main field with --target=node', async function() { + it('should not resolve a node_modules package.browser main field with --target=node', async function () { let resolved = await resolver.resolve({ env: NODE_INCLUDE_ENV, filename: 'package-browser', @@ -577,7 +577,7 @@ describe('resolver', function() { }); }); - it('should fall back to index.js when it cannot find package.main', async function() { + it('should fall back to index.js when it cannot find package.main', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-fallback', @@ -651,7 +651,7 @@ describe('resolver', function() { }); }); - it('should resolve a node_module package.main pointing to a directory', async function() { + it('should resolve a node_module package.main pointing to a directory', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-main-directory', @@ -719,7 +719,7 @@ describe('resolver', function() { }); }); - it('should resolve a file inside a node_modules folder', async function() { + it('should resolve a file inside a node_modules folder', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'foo/nested/baz', @@ -751,7 +751,7 @@ describe('resolver', function() { }); }); - it('should resolve a scoped module', async function() { + it('should resolve a scoped module', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '@scope/pkg', @@ -783,7 +783,7 @@ describe('resolver', function() { }); }); - it('should resolve a file inside a scoped module', async function() { + it('should resolve a file inside a scoped module', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '@scope/pkg/foo/bar', @@ -815,8 +815,8 @@ describe('resolver', function() { }); }); - describe('sideEffects: false', function() { - it('should determine sideEffects correctly (file)', async function() { + describe('sideEffects: false', function () { + it('should determine sideEffects correctly (file)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'side-effects-false/src/index.js', @@ -856,7 +856,7 @@ describe('resolver', function() { }); }); - it('should determine sideEffects correctly (extensionless file)', async function() { + it('should determine sideEffects correctly (extensionless file)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'side-effects-false/src/index', @@ -896,7 +896,7 @@ describe('resolver', function() { }); }); - it('should determine sideEffects correctly (sub folder)', async function() { + it('should determine sideEffects correctly (sub folder)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'side-effects-false/src/', @@ -955,7 +955,7 @@ describe('resolver', function() { }); }); - it('should determine sideEffects correctly (main field)', async function() { + it('should determine sideEffects correctly (main field)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'side-effects-false/src/', @@ -1015,7 +1015,100 @@ describe('resolver', function() { }); }); - it('should not resolve a node module for URL dependencies', async function() { + describe('sideEffects: globs', function () { + it('should determine sideEffects correctly (matched)', async function () { + let resolved = await resolver.resolve({ + env: BROWSER_ENV, + filename: 'side-effects-false-glob/a/index', + specifierType: 'esm', + parent: path.join(rootDir, 'foo.js'), + }); + assert.deepEqual( + {filePath: resolved?.filePath, sideEffects: resolved?.sideEffects}, + { + filePath: path.resolve( + rootDir, + 'node_modules/side-effects-false-glob/a/index.js', + ), + sideEffects: undefined, + }, + ); + }); + it('should determine sideEffects correctly (unmatched)', async function () { + let resolved = await resolver.resolve({ + env: BROWSER_ENV, + filename: 'side-effects-false-glob/b/index.js', + specifierType: 'esm', + parent: path.join(rootDir, 'foo.js'), + }); + assert.deepEqual( + {filePath: resolved?.filePath, sideEffects: resolved?.sideEffects}, + { + filePath: path.resolve( + rootDir, + 'node_modules/side-effects-false-glob/b/index.js', + ), + sideEffects: false, + }, + ); + }); + it('should determine sideEffects correctly (matched dotslash)', async function () { + let resolved = await resolver.resolve({ + env: BROWSER_ENV, + filename: 'side-effects-false-glob/sub/index.js', + specifierType: 'esm', + parent: path.join(rootDir, 'foo.js'), + }); + assert.deepEqual( + {filePath: resolved?.filePath, sideEffects: resolved?.sideEffects}, + { + filePath: path.resolve( + rootDir, + 'node_modules/side-effects-false-glob/sub/index.js', + ), + sideEffects: undefined, + }, + ); + }); + it('should determine sideEffects correctly (unmatched, prefix in subdir)', async function () { + let resolved = await resolver.resolve({ + env: BROWSER_ENV, + filename: 'side-effects-false-glob/sub/a/index.js', + specifierType: 'esm', + parent: path.join(rootDir, 'foo.js'), + }); + assert.deepEqual( + {filePath: resolved?.filePath, sideEffects: resolved?.sideEffects}, + { + filePath: path.resolve( + rootDir, + 'node_modules/side-effects-false-glob/sub/a/index.js', + ), + sideEffects: false, + }, + ); + }); + it('should determine sideEffects correctly (only name)', async function () { + let resolved = await resolver.resolve({ + env: BROWSER_ENV, + filename: 'side-effects-false-glob/sub/index.json', + specifierType: 'esm', + parent: path.join(rootDir, 'foo.js'), + }); + assert.deepEqual( + {filePath: resolved?.filePath, sideEffects: resolved?.sideEffects}, + { + filePath: path.resolve( + rootDir, + 'node_modules/side-effects-false-glob/sub/index.json', + ), + sideEffects: undefined, + }, + ); + }); + }); + + it('should not resolve a node module for URL dependencies', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '@scope/pkg', @@ -1027,7 +1120,7 @@ describe('resolver', function() { ]); }); - it('should resolve a node module for URL dependencies with the npm: prefix', async function() { + it('should resolve a node module for URL dependencies with the npm: prefix', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'npm:@scope/pkg', @@ -1040,7 +1133,7 @@ describe('resolver', function() { ); }); - it('should support query params for bare ESM specifiers', async function() { + it('should support query params for bare ESM specifiers', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '@scope/pkg?foo=2', @@ -1051,10 +1144,10 @@ describe('resolver', function() { nullthrows(resolved).filePath, path.resolve(rootDir, 'node_modules/@scope/pkg/index.js'), ); - assert.deepEqual(nullthrows(resolved).query, {foo: '2'}); + assert.deepEqual(nullthrows(resolved).query?.toString(), 'foo=2'); }); - it('should not support query params for bare CommonJS specifiers', async function() { + it('should not support query params for bare CommonJS specifiers', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '@scope/pkg?foo=2', @@ -1069,7 +1162,7 @@ describe('resolver', function() { ]); }); - it('should support query params for npm: specifiers', async function() { + it('should support query params for npm: specifiers', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'npm:@scope/pkg?foo=2', @@ -1080,12 +1173,12 @@ describe('resolver', function() { nullthrows(resolved).filePath, path.resolve(rootDir, 'node_modules/@scope/pkg/index.js'), ); - assert.deepEqual(nullthrows(resolved).query, {foo: '2'}); + assert.deepEqual(nullthrows(resolved).query?.toString(), 'foo=2'); }); }); - describe('aliases', function() { - it('should alias the main file using the package.browser field', async function() { + describe('aliases', function () { + it('should alias the main file using the package.browser field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-browser-alias', @@ -1127,7 +1220,7 @@ describe('resolver', function() { }); }); - it('should alias a sub-file using the package.browser field', async function() { + it('should alias a sub-file using the package.browser field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-browser-alias/foo', @@ -1169,7 +1262,7 @@ describe('resolver', function() { }); }); - it('should alias a relative file using the package.browser field', async function() { + it('should alias a relative file using the package.browser field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './foo', @@ -1226,7 +1319,7 @@ describe('resolver', function() { }); }); - it('should not alias using the package.browser field with --target=node', async function() { + it('should not alias using the package.browser field with --target=node', async function () { let resolved = await resolver.resolve({ env: NODE_INCLUDE_ENV, filename: 'package-browser-alias/foo', @@ -1268,7 +1361,7 @@ describe('resolver', function() { }); }); - it('should alias a deep nested relative file using the package.browser field', async function() { + it('should alias a deep nested relative file using the package.browser field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './nested', @@ -1325,7 +1418,7 @@ describe('resolver', function() { }); }); - it('should alias a sub-file using the package.alias field', async function() { + it('should alias a sub-file using the package.alias field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-alias/foo', @@ -1357,7 +1450,7 @@ describe('resolver', function() { }); }); - it('should alias a relative file using the package.alias field', async function() { + it('should alias a relative file using the package.alias field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './foo', @@ -1404,7 +1497,7 @@ describe('resolver', function() { }); }); - it('should alias a glob using the package.alias field', async function() { + it('should alias a glob using the package.alias field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './lib/test', @@ -1463,7 +1556,7 @@ describe('resolver', function() { }); }); - it('should apply a module alias using the package.alias field in the root package', async function() { + it('should apply a module alias using the package.alias field in the root package', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliased', @@ -1495,7 +1588,7 @@ describe('resolver', function() { }); }); - it('should apply a global module alias using the package.alias field in the root package', async function() { + it('should apply a global module alias using the package.alias field in the root package', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliased', @@ -1538,7 +1631,7 @@ describe('resolver', function() { }); }); - it('should apply a global module alias to a sub-file in a package', async function() { + it('should apply a global module alias to a sub-file in a package', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliased/bar', @@ -1581,7 +1674,7 @@ describe('resolver', function() { }); }); - it('should apply a module alias pointing to a file using the package.alias field', async function() { + it('should apply a module alias pointing to a file using the package.alias field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliased-file', @@ -1610,7 +1703,7 @@ describe('resolver', function() { }); }); - it('should apply a global module alias pointing to a file using the package.alias field', async function() { + it('should apply a global module alias pointing to a file using the package.alias field', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliased-file', @@ -1647,7 +1740,7 @@ describe('resolver', function() { }); }); - it('should apply an alias for a virtual module folder (relative to project dir)', async function() { + it('should apply an alias for a virtual module folder (relative to project dir)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliasedfolder/test.js', @@ -1676,7 +1769,7 @@ describe('resolver', function() { }); }); - it('should apply an alias for a virtual module folder only (relative to project dir)', async function() { + it('should apply an alias for a virtual module folder only (relative to project dir)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliasedfolder', @@ -1714,7 +1807,7 @@ describe('resolver', function() { }); }); - it('should apply an alias for a virtual module folder (relative to root dir)', async function() { + it('should apply an alias for a virtual module folder (relative to root dir)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliasedabsolute/test.js', @@ -1743,7 +1836,7 @@ describe('resolver', function() { }); }); - it('should apply an alias for a virtual module folder only (relative to root dir)', async function() { + it('should apply an alias for a virtual module folder only (relative to root dir)', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'aliasedabsolute', @@ -1781,7 +1874,7 @@ describe('resolver', function() { }); }); - it('should apply an alias for a virtual module folder sub-path', async function() { + it('should apply an alias for a virtual module folder sub-path', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'foo/bar', @@ -1810,7 +1903,7 @@ describe('resolver', function() { }); }); - it('should apply an alias for a virtual module folder glob sub-path', async function() { + it('should apply an alias for a virtual module folder glob sub-path', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'glob/bar/test', @@ -1839,7 +1932,7 @@ describe('resolver', function() { }); }); - it('should apply an alias for a virtual module', async function() { + it('should apply an alias for a virtual module', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'something', @@ -1868,7 +1961,7 @@ describe('resolver', function() { }); }); - it('should apply a global alias for a virtual module', async function() { + it('should apply a global alias for a virtual module', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'something', @@ -1905,7 +1998,7 @@ describe('resolver', function() { }); }); - it('should resolve to an empty file when package.browser resolves to false', async function() { + it('should resolve to an empty file when package.browser resolves to false', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-browser-exclude', @@ -1942,7 +2035,7 @@ describe('resolver', function() { }); }); - it('should resolve to an empty file when package.alias resolves to false', async function() { + it('should resolve to an empty file when package.alias resolves to false', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-alias-exclude', @@ -1980,8 +2073,8 @@ describe('resolver', function() { }); }); - describe('source field', function() { - it('should use the source field when symlinked', async function() { + describe('source field', function () { + it('should use the source field when symlinked', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'source', @@ -2013,7 +2106,7 @@ describe('resolver', function() { }); }); - it('should not use the source field when not symlinked', async function() { + it('should not use the source field when not symlinked', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'source-not-symlinked', @@ -2055,7 +2148,7 @@ describe('resolver', function() { }); }); - it('should use the source field as an alias when symlinked', async function() { + it('should use the source field as an alias when symlinked', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'source-alias/dist', @@ -2087,7 +2180,7 @@ describe('resolver', function() { }); }); - it('should use the source field as a glob alias when symlinked', async function() { + it('should use the source field as a glob alias when symlinked', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'source-alias-glob', @@ -2131,8 +2224,8 @@ describe('resolver', function() { }); }); - describe('symlinks', function() { - it('should resolve symlinked files to their realpath', async function() { + describe('symlinks', function () { + it('should resolve symlinked files to their realpath', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './baz.js', @@ -2142,7 +2235,7 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve symlinked directories to their realpath', async function() { + it('should resolve symlinked directories to their realpath', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './symlinked-nested', @@ -2156,8 +2249,8 @@ describe('resolver', function() { }); }); - describe('error handling', function() { - it('should return diagnostics when package.module does not exist', async function() { + describe('error handling', function () { + it('should return diagnostics when package.module does not exist', async function () { let result = await resolver.resolve({ env: BROWSER_ENV, filename: 'package-module-fallback', @@ -2171,7 +2264,7 @@ describe('resolver', function() { ); }); - it('should throw when a relative path cannot be resolved', async function() { + it('should throw when a relative path cannot be resolved', async function () { let result = await resolver.resolve({ env: BROWSER_ENV, filename: './xyz.js', @@ -2185,7 +2278,7 @@ describe('resolver', function() { ); }); - it('should throw when a node_module cannot be resolved', async function() { + it('should throw when a node_module cannot be resolved', async function () { assert.strictEqual( null, await resolver.resolve({ @@ -2197,7 +2290,7 @@ describe('resolver', function() { ); }); - it('should throw when a subfile of a node_module cannot be resolved', async function() { + it('should throw when a subfile of a node_module cannot be resolved', async function () { assert.strictEqual( null, await resolver.resolve({ @@ -2209,7 +2302,7 @@ describe('resolver', function() { ); }); - it('should error when a library is missing an external dependency', async function() { + it('should error when a library is missing an external dependency', async function () { let result = await resolver.resolve({ env: new Environment( createEnvironment({ @@ -2231,7 +2324,7 @@ describe('resolver', function() { ); }); - it('should not error when external dependencies are declared', async function() { + it('should not error when external dependencies are declared', async function () { let result = await resolver.resolve({ env: new Environment( createEnvironment({ @@ -2250,7 +2343,7 @@ describe('resolver', function() { assert.deepEqual(result, {isExcluded: true}); }); - it('should not error when external dependencies are declared in peerDependencies', async function() { + it('should not error when external dependencies are declared in peerDependencies', async function () { let result = await resolver.resolve({ env: new Environment( createEnvironment({ @@ -2269,7 +2362,7 @@ describe('resolver', function() { assert.deepEqual(result, {isExcluded: true}); }); - it('should not error on missing dependencies for environment builtins', async function() { + it('should not error on missing dependencies for environment builtins', async function () { let result = await resolver.resolve({ env: new Environment( createEnvironment({ @@ -2289,8 +2382,8 @@ describe('resolver', function() { }); }); - describe('urls', function() { - it('should ignore protocol relative urls', async function() { + describe('urls', function () { + it('should ignore protocol relative urls', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '//example.com/foo.png', @@ -2300,7 +2393,7 @@ describe('resolver', function() { assert.deepEqual(resolved, {isExcluded: true}); }); - it('should ignore hash urls', async function() { + it('should ignore hash urls', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: '#hash', @@ -2310,7 +2403,7 @@ describe('resolver', function() { assert.deepEqual(resolved, {isExcluded: true}); }); - it('should ignore http: urls', async function() { + it('should ignore http: urls', async function () { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: 'http://example.com/foo.png', diff --git a/packages/utils/service-worker/package.json b/packages/utils/service-worker/package.json index 9826a67ce88..6dc82dc8034 100644 --- a/packages/utils/service-worker/package.json +++ b/packages/utils/service-worker/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/service-worker", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -18,6 +18,6 @@ "sideEffects": false, "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" } } diff --git a/packages/utils/ts-utils/package.json b/packages/utils/ts-utils/package.json index ba5a07a620e..a0c9b1092a2 100644 --- a/packages/utils/ts-utils/package.json +++ b/packages/utils/ts-utils/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/ts-utils", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/utils/ts-utils/src/FSHost.js b/packages/utils/ts-utils/src/FSHost.js index 14be34e2618..288412598ff 100644 --- a/packages/utils/ts-utils/src/FSHost.js +++ b/packages/utils/ts-utils/src/FSHost.js @@ -53,9 +53,10 @@ export class FSHost { } } - getAccessibleFileSystemEntries( - dirPath: FilePath, - ): {|directories: Array, files: Array|} { + getAccessibleFileSystemEntries(dirPath: FilePath): {| + directories: Array, + files: Array, + |} { try { let entries = this.fs.readdirSync(dirPath || '.').sort(); let files = []; diff --git a/packages/utils/ts-utils/src/LanguageServiceHost.js b/packages/utils/ts-utils/src/LanguageServiceHost.js index 5f64c943fcc..7ed7d2a8933 100644 --- a/packages/utils/ts-utils/src/LanguageServiceHost.js +++ b/packages/utils/ts-utils/src/LanguageServiceHost.js @@ -14,8 +14,10 @@ import {FSHost} from './FSHost'; // having its methods as properties with arrow functions. These should probably // be methods instead. // $FlowFixMe[method-unbinding] -export class LanguageServiceHost extends FSHost - implements ILanguageServiceHost { +export class LanguageServiceHost + extends FSHost + implements ILanguageServiceHost +{ config: ParsedCommandLine; files: {|[key: FilePath]: {|version: number|}|}; diff --git a/packages/validators/eslint/package.json b/packages/validators/eslint/package.json index ea01d148690..1d6d285ff07 100644 --- a/packages/validators/eslint/package.json +++ b/packages/validators/eslint/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/validator-eslint", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,11 +17,11 @@ "source": "src/EslintValidator.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0", + "@parcel/plugin": "^2.0.1", + "@parcel/utils": "^2.0.1", "chalk": "^4.1.0" }, "devDependencies": { diff --git a/packages/validators/typescript/package.json b/packages/validators/typescript/package.json index e7c654cc007..3d0bfaf4eb7 100644 --- a/packages/validators/typescript/package.json +++ b/packages/validators/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@parcel/validator-typescript", - "version": "2.0.0-rc.0", + "version": "2.0.1", "license": "MIT", "publishConfig": { "access": "public" @@ -17,14 +17,14 @@ "source": "src/TypeScriptValidator.js", "engines": { "node": ">= 12.0.0", - "parcel": "^2.0.0-beta.1" + "parcel": "^2.0.1" }, "dependencies": { - "@parcel/diagnostic": "2.0.0-rc.0", - "@parcel/plugin": "2.0.0-rc.0", - "@parcel/ts-utils": "2.0.0-rc.0", - "@parcel/types": "2.0.0-rc.0", - "@parcel/utils": "2.0.0-rc.0" + "@parcel/diagnostic": "^2.0.1", + "@parcel/plugin": "^2.0.1", + "@parcel/ts-utils": "^2.0.1", + "@parcel/types": "^2.0.1", + "@parcel/utils": "^2.0.1" }, "devDependencies": { "typescript": ">=3.0.0" diff --git a/packages/validators/typescript/src/TypeScriptValidator.js b/packages/validators/typescript/src/TypeScriptValidator.js index 7d40ff3ba16..623536705e7 100644 --- a/packages/validators/typescript/src/TypeScriptValidator.js +++ b/packages/validators/typescript/src/TypeScriptValidator.js @@ -20,7 +20,7 @@ let langServiceCache: { host: LanguageServiceHost, service: LanguageService, |}, - ..., + ... } = {}; type TSValidatorConfig = {| diff --git a/scripts/build-native.js b/scripts/build-native.js index e4a8058bc8b..080b7d35c1e 100644 --- a/scripts/build-native.js +++ b/scripts/build-native.js @@ -34,9 +34,8 @@ async function build() { shell: true, }); - yarn.on('error', reject); - yarn.on('close', resolve); - }); + yarn.on('close', code => (code === 0 ? resolve() : reject())); + }).catch(() => process.exit(1)); } } diff --git a/scripts/update-engines.js b/scripts/update-engines.js new file mode 100644 index 00000000000..4a5cee78022 --- /dev/null +++ b/scripts/update-engines.js @@ -0,0 +1,29 @@ +const fs = require('fs'); +const path = require('path'); +const exec = require('child_process').execSync; + +let packages = JSON.parse( + exec( + `${path.join(__dirname, '..', 'node_modules', '.bin', 'lerna')} ls --json`, + ), +); +let packageVersions = new Map( + packages.map(pkg => [ + pkg.name, + {version: pkg.version, location: pkg.location}, + ]), +); +let coreVersion = packageVersions.get('@parcel/core').version; +let coreRange = + coreVersion.includes('nightly') || process.argv.includes('--exact') + ? coreVersion + : `^${coreVersion}`; + +for (let [, {location}] of packageVersions) { + let pkgPath = path.join(location, 'package.json'); + let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + if (pkg.engines?.parcel != null) { + pkg.engines.parcel = coreRange; + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); + } +} diff --git a/scripts/validate-readme-toc.js b/scripts/validate-readme-toc.js deleted file mode 100644 index f2a3581eea6..00000000000 --- a/scripts/validate-readme-toc.js +++ /dev/null @@ -1,19 +0,0 @@ -// TODO: remove deep import once API is exposed (It is merged to master but not published yet) -const transform = require('doctoc/lib/transform'); -const {readFileSync} = require('fs'); -const path = require('path'); - -const README_PATH = path.join(__dirname, '../README.md'); - -(function() { - let content = readFileSync(README_PATH, 'utf8'); - let result = transform(content); - - if (content !== result.data) { - // eslint-disable-next-line no-console - console.error( - 'Looks like the README table of contents needs to be updated. Please run `yarn update-readme-toc` and commit the README file.' - ); - process.exit(1); - } -})(); diff --git a/yarn.lock b/yarn.lock index c4176549c41..2014826e0bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1904,6 +1904,18 @@ toml "^3.0.0" tslib "^2.1.0" +"@napi-rs/triples@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@napi-rs/triples/-/triples-1.0.3.tgz#76d6d0c3f4d16013c61e45dfca5ff1e6c31ae53c" + integrity sha512-jDJTpta+P4p1NZTFVLHJ/TLFVYVcOqv6l8xwOeBKNPMgY/zDYH/YH7SJbvrr/h1RcS9GzbPcLKGzpuK9cV56UA== + +"@node-rs/helper@^1.0.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@node-rs/helper/-/helper-1.2.1.tgz#e079b05f21ff4329d82c4e1f71c0290e4ecdc70c" + integrity sha512-R5wEmm8nbuQU0YGGmYVjEc0OHtYsuXdpRG+Ut/3wZ9XAvQWyThN08bTh2cBJgoZxHQUPtvRfeQuxcAgLuiBISg== + dependencies: + "@napi-rs/triples" "^1.0.3" + "@nodelib/fs.scandir@2.1.3": version "2.1.3" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b" @@ -2121,29 +2133,21 @@ dependencies: "@octokit/openapi-types" "^6.2.0" -"@parcel/source-map@2.0.0-rc.6": - version "2.0.0-rc.6" - resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.0.0-rc.6.tgz#9b0e84ba4bca9fe8aee484941e48345c79c4121c" - integrity sha512-qtXLd9dbxWx/ybe1dduAzAGzb7iTSQv3imNZo7pVyEtSaCcphg+rTmY8/Fg3MQqqu7of/2+tEqNAGMz8nOJyUA== - dependencies: - detect-libc "^1.0.3" - globby "^11.0.3" - -"@parcel/source-map@2.0.0-rc.7": - version "2.0.0-rc.7" - resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.0.0-rc.7.tgz#73e3251c2169abf733f28b5d6649eb440e39995f" - integrity sha512-LFTvZz8wSOfQAHtczr2PVMBa2gSBeWTivJf4TPQ7neHqECIgAL2GvuCGhETZqU1OYXlnzuxdsiWvDKQtrLiWgA== +"@parcel/source-map@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.0.0.tgz#41cf004109bbf277ceaf096a58838ff6a59af774" + integrity sha512-njoUJpj2646NebfHp5zKJeYD1KwhsfQIoU9TnCTHmF9fGOaPbClmeq12G6/4ZqGASftRq+YhhukFBi/ncWKGvw== dependencies: detect-libc "^1.0.3" globby "^11.0.3" -"@parcel/watcher@2.0.0-alpha.10": - version "2.0.0-alpha.10" - resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.0.0-alpha.10.tgz#99266189f5193512dbdf6b0faca20400c519a16e" - integrity sha512-8uA7Tmx/1XvmUdGzksg0+oN7uj24pXFFnKJqZr3L3mgYjdrL7CMs3PRIHv1k3LUz/hNRsb/p3qxztSkWz1IGZA== +"@parcel/watcher@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.0.0.tgz#ebe992a4838b35c3da9a568eb95a71cb26ddf551" + integrity sha512-ByalKmRRXNNAhwZ0X1r0XeIhh1jG8zgdlvjgHk9ZV3YxiersEGNQkwew+RfqJbIL4gOJfvC2ey6lg5kaeRainw== dependencies: - node-addon-api "^3.0.2" - node-gyp-build "^4.2.3" + node-addon-api "^3.2.1" + node-gyp-build "^4.3.0" "@sinonjs/commons@^1", "@sinonjs/commons@^1.3.0", "@sinonjs/commons@^1.4.0", "@sinonjs/commons@^1.7.0": version "1.7.0" @@ -2263,29 +2267,91 @@ deepmerge "^4.2.2" svgo "^1.2.2" +"@swc/core-android-arm64@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-android-arm64/-/core-android-arm64-1.2.106.tgz#86fb16a40d112502051252dfa29c8482b341ce36" + integrity sha512-F5T6kP3yV9S0/oXyco305QaAyE6rLNsNSdR0QI4CtACwKadiPwTOptwNIDCiTNLNgWlWLQmIRkPpxg+G4doT6Q== + +"@swc/core-darwin-arm64@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.106.tgz#02a9ce94fee6d7f8a81a94233e4c455d55273fed" + integrity sha512-bgKzzYLFnc+mv2mDS/DLwzBvx5DCC9ZCKYY46b4dAnBfasr+SMHj+v/WI84HtilbjLBMUfYZ2hgYKls3CebIIQ== + +"@swc/core-darwin-x64@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.2.106.tgz#72448061266e9fb44427898bd13154ec3b63ebba" + integrity sha512-I5Uhit5RqbXaMIV2+v9jL+MIQeR3lT1DqVwzxZs1bTARclAheFZQpTmg+h6QmichjCiUT74SXQb6Apc/vqYKog== + +"@swc/core-freebsd-x64@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.106.tgz#070ec3ab798009ac14a18c692ede1542b5640ef1" + integrity sha512-ZSK3vgzbA2Pkpw2LgHlAkUdx4okIpdXXTbLXuc5jkZMw1KhRWpeQaDlwbrN7XVynAYjkj2qgGQ7wv1tD43vQig== + +"@swc/core-linux-arm-gnueabihf@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.106.tgz#a94a29bfe81425c6f90a27d5977e58cb469db0a0" + integrity sha512-WZh6XV8cQ9Fh3IQNX9z87Tv68+sLtfnT51ghMQxceRhfvc5gIaYW+PCppezDDdlPJnWXhybGWNPAl5SHppWb2g== + +"@swc/core-linux-arm64-gnu@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.106.tgz#6ec685cd37ab3655dbc8eb07a38df6d9532ac32c" + integrity sha512-OSI9VUWPsRrCbUlRQ4KdYqdwV63VYBC5ahSNq+72DXhtRwVbLSFuF7MNsnXgUSMHidxbc0No3/bPPamshqHdsQ== + +"@swc/core-linux-arm64-musl@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.106.tgz#805841ab7bcca134a2712fb1084c09338ef61168" + integrity sha512-de8AAUOP8D2/tZIpQ399xw+pGGKlR1+l5Jmy4lW7ixarEI4xKkBSF4bS9eXtC1jckmenzrLPiK/5sSbQSf6BWQ== + +"@swc/core-linux-x64-gnu@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.106.tgz#d403dfce5d31dafd5d87491ce80ed603545e4864" + integrity sha512-QzFC7+lBSuVBmX5tS2pdM+74voiJcGgIMJ+x9pcjUu3GkDl3ow6WC6ta2WUzlgGopCGNp6IdZaFemKRzjLr3lw== + +"@swc/core-linux-x64-musl@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.106.tgz#0fce602e60cf1c9d9e72d33083dda18b963b3b6d" + integrity sha512-QZ1gFqNiCJefkNMihbmYc7nr5stERyjoQpWgAIN6dzrgMUzRHXHGDRl/p1qsXW2VKos+okSdLwPFEmRT94H+1A== + +"@swc/core-win32-arm64-msvc@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.106.tgz#c0e6f5b38a6eac8a5ce438492f23c4ffc47f326f" + integrity sha512-MbuQwk+s43bfBNnAZTKnoQlfo4UPSOsy6t9F15yU4P3rVUuFtcxdZg6CpDnUqNPbojILXujp8z4SSigRYh5cgg== + +"@swc/core-win32-ia32-msvc@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.106.tgz#5cf4a824a5bc3cfa6346733a3407e423c1920020" + integrity sha512-BFxWpcPxsG2LLQZ+8K8ma45rbTckjpPbnvOOhybQ0hEhLgoVzMVPp3RIUGmC+RMZe6DkGSaEQf/Rjn2cbMdQhw== + +"@swc/core-win32-x64-msvc@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.106.tgz#237d699d25944538fda57dd879478f2cc7835827" + integrity sha512-Emn5akqApGXzPsA7ntSXEohL0AH0WjQMHy6mT3MS9Yil42yTJ96dJGf68ejKVptxwg7Iz798mT+J9r1JbAFBgg== + +"@swc/core@^1.2.106": + version "1.2.106" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.2.106.tgz#d1ae8d5745b6b37fcc5c076e433eb31312c81372" + integrity sha512-9uw8gqU+lsk7KROAcSNhsrnBgNiC5H4MIaps5LlnnEevJmKu/o1ws22tXc2qjJg+F4/V1ynUbh8E0rYlmo1XGw== + dependencies: + "@node-rs/helper" "^1.0.0" + optionalDependencies: + "@swc/core-android-arm64" "^1.2.106" + "@swc/core-darwin-arm64" "^1.2.106" + "@swc/core-darwin-x64" "^1.2.106" + "@swc/core-freebsd-x64" "^1.2.106" + "@swc/core-linux-arm-gnueabihf" "^1.2.106" + "@swc/core-linux-arm64-gnu" "^1.2.106" + "@swc/core-linux-arm64-musl" "^1.2.106" + "@swc/core-linux-x64-gnu" "^1.2.106" + "@swc/core-linux-x64-musl" "^1.2.106" + "@swc/core-win32-arm64-msvc" "^1.2.106" + "@swc/core-win32-ia32-msvc" "^1.2.106" + "@swc/core-win32-x64-msvc" "^1.2.106" + "@swc/helpers@^0.2.11": version "0.2.11" resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.2.11.tgz#34c842dcd8182810b4ab72d0d1fc34b553909e2e" integrity sha512-0FFPZrCwRDLsbJDKzs1Oo+TAqfAyxnZWZoTF6rUrfWQCYpwuKFj7tAEt/wa830fqCPE5Uk6qIo9KMkPe7Qgukg== -"@textlint/ast-node-types@^4.0.3": - version "4.2.5" - resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-4.2.5.tgz#ae13981bc8711c98313a6ac1c361194d6bf2d39b" - integrity sha512-+rEx4jLOeZpUcdvll7jEg/7hNbwYvHWFy4IGW/tk2JdbyB3SJVyIP6arAwzTH/sp/pO9jftfyZnRj4//sLbLvQ== - -"@textlint/markdown-to-ast@~6.0.9": - version "6.0.9" - resolved "https://registry.yarnpkg.com/@textlint/markdown-to-ast/-/markdown-to-ast-6.0.9.tgz#e7c89e5ad15d17dcd8e5a62758358936827658fa" - integrity sha512-hfAWBvTeUGh5t5kTn2U3uP3qOSM1BSrxzl1jF3nn0ywfZXpRBZr5yRjXnl4DzIYawCtZOshmRi/tI3/x4TE1jQ== - dependencies: - "@textlint/ast-node-types" "^4.0.3" - debug "^2.1.3" - remark-frontmatter "^1.2.0" - remark-parse "^5.0.0" - structured-source "^3.0.2" - traverse "^0.6.6" - unified "^6.1.6" - "@trysound/sax@0.1.1": version "0.1.1" resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.1.1.tgz#3348564048e7a2d7398c935d466c0414ebb6a669" @@ -2459,6 +2525,11 @@ resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.4.tgz#6dc50f593bdfdeaa6183d1dbc15e2d45e7c6b8b3" integrity sha512-Swfbz31AaMX48CpFl+YmIrqOH9MgJMTrltG9e26A4ZxYx9LjGuMV+41WnxFzS3Bc9nbrc6sDPM37G6nIT8NJSg== +"@xmldom/xmldom@^0.7.5": + version "0.7.5" + resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.7.5.tgz#09fa51e356d07d0be200642b0e4f91d8e6dd408d" + integrity sha512-V3BIhmY36fXZ1OtVcI9W+FxQqxVLsPKcNjWigIaa81dLC9IolJl5Mt4Cvhmr0flUnjSpTdrbMTSbXqYqV5dT6A== + "@zkochan/cmd-shim@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@zkochan/cmd-shim/-/cmd-shim-3.1.0.tgz#2ab8ed81f5bb5452a85f25758eb9b8681982fd2e" @@ -2578,13 +2649,6 @@ amdefine@>=0.0.4: resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" integrity sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU= -anchor-markdown-header@^0.5.5: - version "0.5.7" - resolved "https://registry.yarnpkg.com/anchor-markdown-header/-/anchor-markdown-header-0.5.7.tgz#045063d76e6a1f9cd327a57a0126aa0fdec371a7" - integrity sha1-BFBj125qH5zTJ6V6ASaqD97Dcac= - dependencies: - emoji-regex "~6.1.0" - ansi-colors@4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" @@ -2621,10 +2685,10 @@ ansi-gray@^0.1.1: dependencies: ansi-wrap "0.1.0" -ansi-html@^0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" - integrity sha1-gTWEAhliqenm/QOflA0S9WynhZ4= +ansi-html-community@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/ansi-html-community/-/ansi-html-community-0.0.8.tgz#69fbc4d6ccbe383f9736934ae34c3f8290f1bf41" + integrity sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw== ansi-regex@^2.0.0: version "2.1.1" @@ -3205,11 +3269,6 @@ boolbase@^1.0.0, boolbase@~1.0.0: resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= -boundary@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/boundary/-/boundary-1.0.1.tgz#4d67dc2602c0cc16dd9bce7ebf87e948290f5812" - integrity sha1-TWfcJgLAzBbdm85+v4fpSCkPWBI= - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -3519,9 +3578,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001219: - version "1.0.30001228" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz#bfdc5942cd3326fa51ee0b42fbef4da9d492a7fa" - integrity sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A== + version "1.0.30001272" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001272.tgz#8e9790ff995e9eb6e1f4c45cd07ddaa87cddbb14" + integrity sha512-DV1j9Oot5dydyH1v28g25KoVm7l8MTxazwuiH3utWiAS6iL/9Nh//TGwqFEeqqN8nnWYQ8HHhUq+o4QPt9kvYw== caseless@~0.12.0: version "0.12.0" @@ -3847,7 +3906,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0, color-convert@^1.9.1: +color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -3871,10 +3930,10 @@ color-name@^1.0.0, color-name@^1.1.4, color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -color-string@^1.5.4: - version "1.5.4" - resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.4.tgz#dd51cd25cfee953d138fe4002372cc3d0e504cb6" - integrity sha512-57yF5yt8Xa3czSEW1jfQDE79Idk0+AkN/4KWad6tbdxUmAs3MvjxlWSWD4deYytcRfoZ9nhKyFl1kj5tBvidbw== +color-string@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.6.0.tgz#c3915f61fe267672cb7e1e064c9d692219f6c312" + integrity sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA== dependencies: color-name "^1.0.0" simple-swizzle "^0.2.2" @@ -3884,20 +3943,15 @@ color-support@^1.1.3: resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== -color@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/color/-/color-3.1.3.tgz#ca67fb4e7b97d611dcde39eceed422067d91596e" - integrity sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ== +color@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/color/-/color-4.0.1.tgz#21df44cd10245a91b1ccf5ba031609b0e10e7d67" + integrity sha512-rpZjOKN5O7naJxkH2Rx1sZzzBgaiWECc6BYXjeCE6kF0kcASJYbUq02u7JqIHwCb/j3NhV+QhRL2683aICeGZA== dependencies: - color-convert "^1.9.1" - color-string "^1.5.4" - -colord@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/colord/-/colord-2.0.1.tgz#1e7fb1f9fa1cf74f42c58cb9c20320bab8435aa0" - integrity sha512-vm5YpaWamD0Ov6TSG0GGmUIwstrWcfKQV/h2CmbR7PbNu41+qdB5PW9lpzhjedrpm08uuYvcXi0Oel1RLZIJuA== + color-convert "^2.0.1" + color-string "^1.6.0" -colord@^2.6: +colord@^2.0.1, colord@^2.6: version "2.7.0" resolved "https://registry.yarnpkg.com/colord/-/colord-2.7.0.tgz#706ea36fe0cd651b585eb142fe64b6480185270e" integrity sha512-pZJBqsHz+pYyw3zpX6ZRXWoCHM1/cvFikY9TV8G3zcejCaKE0lhankoj8iScyrrePA8C7yJ5FStfA9zbcOnw7Q== @@ -4219,18 +4273,7 @@ cosmiconfig@^6.0.0: path-type "^4.0.0" yaml "^1.7.2" -cosmiconfig@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3" - integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.2.1" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.10.0" - -cosmiconfig@^7.0.1: +cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== @@ -4326,11 +4369,6 @@ crypto-random-string@^1.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= -css-color-names@^0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0" - integrity sha1-gIrcLnnPhHOAabZGyyDsJ762KeA= - css-color-names@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-1.0.1.tgz#6ff7ee81a823ad46e020fa2fd6ab40a887e2ba67" @@ -4360,13 +4398,6 @@ css-parse@1.7.x: resolved "https://registry.yarnpkg.com/css-parse/-/css-parse-1.7.0.tgz#321f6cf73782a6ff751111390fc05e2c657d8c9b" integrity sha1-Mh9s9zeCpv91ERE5D8BeLGV9jJs= -css-parse@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/css-parse/-/css-parse-2.0.0.tgz#a468ee667c16d81ccf05c58c38d2a97c780dbfd4" - integrity sha1-pGjuZnwW2BzPBcWMONKpfHgNv9Q= - dependencies: - css "^2.0.0" - css-select-base-adapter@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz#3b2ff4972cc362ab88561507a95408a1432135d7" @@ -4428,15 +4459,14 @@ css-what@^5.0.0: resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.0.1.tgz#3efa820131f4669a8ac2408f9c32e7c7de9f4cad" integrity sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg== -css@^2.0.0: - version "2.2.4" - resolved "https://registry.yarnpkg.com/css/-/css-2.2.4.tgz#c646755c73971f2bba6a601e2cf2fd71b1298929" - integrity sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw== +css@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/css/-/css-3.0.0.tgz#4447a4d58fdd03367c516ca9f64ae365cee4aa5d" + integrity sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ== dependencies: - inherits "^2.0.3" + inherits "^2.0.4" source-map "^0.6.1" - source-map-resolve "^0.5.2" - urix "^0.1.0" + source-map-resolve "^0.6.0" cssesc@^0.1.0: version "0.1.0" @@ -4448,41 +4478,6 @@ cssesc@^3.0.0: resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== -cssnano-preset-default@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/cssnano-preset-default/-/cssnano-preset-default-5.1.2.tgz#5d4877a91769823c5da6bcebd54996ecdf8aca12" - integrity sha512-spilp8LRw0sacuxiN9A/dyyPr6G/WISKMBKcBD4NMoPV0ENx4DeuWvIIrSx9PII2nJIDCO3kywkqTPreECBVOg== - dependencies: - css-declaration-sorter "^6.0.3" - cssnano-utils "^2.0.1" - postcss-calc "^8.0.0" - postcss-colormin "^5.2.0" - postcss-convert-values "^5.0.1" - postcss-discard-comments "^5.0.1" - postcss-discard-duplicates "^5.0.1" - postcss-discard-empty "^5.0.1" - postcss-discard-overridden "^5.0.1" - postcss-merge-longhand "^5.0.2" - postcss-merge-rules "^5.0.2" - postcss-minify-font-values "^5.0.1" - postcss-minify-gradients "^5.0.1" - postcss-minify-params "^5.0.1" - postcss-minify-selectors "^5.1.0" - postcss-normalize-charset "^5.0.1" - postcss-normalize-display-values "^5.0.1" - postcss-normalize-positions "^5.0.1" - postcss-normalize-repeat-style "^5.0.1" - postcss-normalize-string "^5.0.1" - postcss-normalize-timing-functions "^5.0.1" - postcss-normalize-unicode "^5.0.1" - postcss-normalize-url "^5.0.1" - postcss-normalize-whitespace "^5.0.1" - postcss-ordered-values "^5.0.1" - postcss-reduce-initial "^5.0.1" - postcss-reduce-transforms "^5.0.1" - postcss-svgo "^5.0.2" - postcss-unique-selectors "^5.0.1" - cssnano-preset-default@^5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/cssnano-preset-default/-/cssnano-preset-default-5.1.4.tgz#359943bf00c5c8e05489f12dd25f3006f2c1cbd2" @@ -4523,16 +4518,7 @@ cssnano-utils@^2.0.1: resolved "https://registry.yarnpkg.com/cssnano-utils/-/cssnano-utils-2.0.1.tgz#8660aa2b37ed869d2e2f22918196a9a8b6498ce2" integrity sha512-i8vLRZTnEH9ubIyfdZCAdIdgnHAUeQeByEeQ2I7oTilvP9oHO6RScpeq3GsFUVqeB8uZgOQ9pw8utofNn32hhQ== -cssnano@^5.0.5: - version "5.0.5" - resolved "https://registry.yarnpkg.com/cssnano/-/cssnano-5.0.5.tgz#6b8787123bf4cd5a220a2fa6cb5bc036b0854b48" - integrity sha512-L2VtPXnq6rmcMC9vkBOP131sZu3ccRQI27ejKZdmQiPDpUlFkUbpXHgKN+cibeO1U4PItxVZp1zTIn5dHsXoyg== - dependencies: - cosmiconfig "^7.0.0" - cssnano-preset-default "^5.1.2" - is-resolvable "^1.1.0" - -cssnano@^5.0.8: +cssnano@^5.0.5, cssnano@^5.0.8: version "5.0.8" resolved "https://registry.yarnpkg.com/cssnano/-/cssnano-5.0.8.tgz#39ad166256980fcc64faa08c9bb18bb5789ecfa9" integrity sha512-Lda7geZU0Yu+RZi2SGpjYuQz4HI4/1Y+BhdD0jL7NXAQ5larCzVn+PUGuZbDMYz904AXXCOgO5L1teSvgu7aFg== @@ -4720,7 +4706,7 @@ debug@*, debug@4.3.1, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: dependencies: ms "2.1.2" -debug@2.6.9, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: +debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -4930,18 +4916,6 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -doctoc@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/doctoc/-/doctoc-1.4.0.tgz#3115aa61d0a92f0abb0672036918ea904f5b9e02" - integrity sha512-8IAq3KdMkxhXCUF+xdZxdJxwuz8N2j25sMgqiu4U4JWluN9tRKMlAalxGASszQjlZaBprdD2YfXpL3VPWUD4eg== - dependencies: - "@textlint/markdown-to-ast" "~6.0.9" - anchor-markdown-header "^0.5.5" - htmlparser2 "~3.9.2" - minimist "~1.2.0" - underscore "~1.8.3" - update-section "^0.3.0" - doctrine@1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" @@ -4991,7 +4965,7 @@ domain-browser@^3.5.0: resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-3.5.0.tgz#3a11f5df52fd9d60d7f1c79a62fde2d158c42b09" integrity sha512-zrzUu6auyZWRexjCEPJnfWc30Hupxh2lJZOJAF3qa2bCuD4O/55t0FvQt3ZMhEw++gjNkwdkOVZh8yA32w/Vfw== -domelementtype@1, domelementtype@^1.3.0: +domelementtype@1: version "1.3.1" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.1.tgz#d048c44b37b0d10a7f2a3d5fee3f4333d790481f" integrity sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w== @@ -5008,13 +4982,6 @@ domexception@^1.0.1: dependencies: webidl-conversions "^4.0.2" -domhandler@^2.3.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.2.tgz#8805097e933d65e85546f726d60f5eb88b44f803" - integrity sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA== - dependencies: - domelementtype "1" - domhandler@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-3.3.0.tgz#6db7ea46e4617eb15cf875df68b2b8524ce0037a" @@ -5022,21 +4989,14 @@ domhandler@^3.3.0: dependencies: domelementtype "^2.0.1" -domhandler@^4.0.0, domhandler@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.2.0.tgz#f9768a5f034be60a89a27c2e4d0f74eba0d8b059" - integrity sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA== - dependencies: - domelementtype "^2.2.0" - -domhandler@^4.2.2: +domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.2.2.tgz#e825d721d19a86b8c201a35264e226c678ee755f" integrity sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w== dependencies: domelementtype "^2.2.0" -domutils@^1.5.1, domutils@^1.7.0: +domutils@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a" integrity sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg== @@ -5044,16 +5004,7 @@ domutils@^1.5.1, domutils@^1.7.0: dom-serializer "0" domelementtype "1" -domutils@^2.4.2, domutils@^2.5.2, domutils@^2.6.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.7.0.tgz#8ebaf0c41ebafcf55b0b72ec31c56323712c5442" - integrity sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - -domutils@^2.8.0: +domutils@^2.4.2, domutils@^2.5.2, domutils@^2.6.0, domutils@^2.8.0: version "2.8.0" resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== @@ -5169,11 +5120,6 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emoji-regex@~6.1.0: - version "6.1.3" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.1.3.tgz#ec79a3969b02d2ecf2b72254279bf99bc7a83932" - integrity sha1-7HmjlpsC0uzytyJUJ5v5m8eoOTI= - emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -5214,11 +5160,6 @@ enquirer@^2.3.5: dependencies: ansi-colors "^3.2.1" -entities@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56" - integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w== - entities@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4" @@ -5342,10 +5283,113 @@ es6-weak-map@^2.0.1: es6-iterator "^2.0.3" es6-symbol "^3.1.1" -esbuild@^0.8.11: - version "0.8.29" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.8.29.tgz#cc20fb752e0905a3546d68ae1be58f9b97044c39" - integrity sha512-UDsEoeXuctVgG2hEts1Hwq2jYDGqV7nksEHEZaiCy2v+lXF5ButX4ErPAJAFi5ZNKKW+6Pom93pArV7hki6HnQ== +esbuild-android-arm64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.13.12.tgz#e1f199dc05405cdc6670c00fb6c793822bf8ae4c" + integrity sha512-TSVZVrb4EIXz6KaYjXfTzPyyRpXV5zgYIADXtQsIenjZ78myvDGaPi11o4ZSaHIwFHsuwkB6ne5SZRBwAQ7maw== + +esbuild-darwin-64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.13.12.tgz#f5c59e622955c01f050e5a7ac9c1d41db714b94d" + integrity sha512-c51C+N+UHySoV2lgfWSwwmlnLnL0JWj/LzuZt9Ltk9ub1s2Y8cr6SQV5W3mqVH1egUceew6KZ8GyI4nwu+fhsw== + +esbuild-darwin-arm64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.12.tgz#8abae74c2956a8aa568fc52c78829338c4a4b988" + integrity sha512-JvAMtshP45Hd8A8wOzjkY1xAnTKTYuP/QUaKp5eUQGX+76GIie3fCdUUr2ZEKdvpSImNqxiZSIMziEiGB5oUmQ== + +esbuild-freebsd-64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.12.tgz#6ad2ab8c0364ee7dd2d6e324d876a8e60ae75d12" + integrity sha512-r6On/Skv9f0ZjTu6PW5o7pdXr8aOgtFOEURJZYf1XAJs0IQ+gW+o1DzXjVkIoT+n1cm3N/t1KRJfX71MPg/ZUA== + +esbuild-freebsd-arm64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.12.tgz#6f38155f4c300ac4c8adde1fde3cc6a4440a8294" + integrity sha512-F6LmI2Q1gii073kmBE3NOTt/6zLL5zvZsxNLF8PMAwdHc+iBhD1vzfI8uQZMJA1IgXa3ocr3L3DJH9fLGXy6Yw== + +esbuild-linux-32@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.13.12.tgz#b1d15e330188a8c21de75c3f0058628a3eefade7" + integrity sha512-U1UZwG3UIwF7/V4tCVAo/nkBV9ag5KJiJTt+gaCmLVWH3bPLX7y+fNlhIWZy8raTMnXhMKfaTvWZ9TtmXzvkuQ== + +esbuild-linux-64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.13.12.tgz#25bd64b66162b02348e32d8f12e4c9ee61f1d070" + integrity sha512-YpXSwtu2NxN3N4ifJxEdsgd6Q5d8LYqskrAwjmoCT6yQnEHJSF5uWcxv783HWN7lnGpJi9KUtDvYsnMdyGw71Q== + +esbuild-linux-arm64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.12.tgz#ba582298457cc5c9ac823a275de117620c06537f" + integrity sha512-sgDNb8kb3BVodtAlcFGgwk+43KFCYjnFOaOfJibXnnIojNWuJHpL6aQJ4mumzNWw8Rt1xEtDQyuGK9f+Y24jGA== + +esbuild-linux-arm@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.13.12.tgz#6bc81c957bff22725688cc6359c29a25765be09b" + integrity sha512-SyiT/JKxU6J+DY2qUiSLZJqCAftIt3uoGejZ0HDnUM2MGJqEGSGh7p1ecVL2gna3PxS4P+j6WAehCwgkBPXNIw== + +esbuild-linux-mips64le@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.12.tgz#ef3c4aba3e585d847cbade5945a8b4a5c62c7ce2" + integrity sha512-qQJHlZBG+QwVIA8AbTEtbvF084QgDi4DaUsUnA+EolY1bxrG+UyOuGflM2ZritGhfS/k7THFjJbjH2wIeoKA2g== + +esbuild-linux-ppc64le@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.12.tgz#a21fb64e80c38bef06122e48283990fc6db578e1" + integrity sha512-2dSnm1ldL7Lppwlo04CGQUpwNn5hGqXI38OzaoPOkRsBRWFBozyGxTFSee/zHFS+Pdh3b28JJbRK3owrrRgWNw== + +esbuild-netbsd-64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.12.tgz#1ea7fc8cfce88a20a4047b867ef184049a6641ae" + integrity sha512-D4raxr02dcRiQNbxOLzpqBzcJNFAdsDNxjUbKkDMZBkL54Z0vZh4LRndycdZAMcIdizC/l/Yp/ZsBdAFxc5nbA== + +esbuild-openbsd-64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.12.tgz#adde32f2f1b05dc4bd4fc544d6ea5a4379f9ca4d" + integrity sha512-KuLCmYMb2kh05QuPJ+va60bKIH5wHL8ypDkmpy47lzwmdxNsuySeCMHuTv5o2Af1RUn5KLO5ZxaZeq4GEY7DaQ== + +esbuild-sunos-64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.13.12.tgz#a7ecaf52b7364fbee76dc8aa707fa3e1cff3342c" + integrity sha512-jBsF+e0woK3miKI8ufGWKG3o3rY9DpHvCVRn5eburMIIE+2c+y3IZ1srsthKyKI6kkXLvV4Cf/E7w56kLipMXw== + +esbuild-windows-32@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.13.12.tgz#a8756033dc905c4b7bea19be69f7ee68809f8770" + integrity sha512-L9m4lLFQrFeR7F+eLZXG82SbXZfUhyfu6CexZEil6vm+lc7GDCE0Q8DiNutkpzjv1+RAbIGVva9muItQ7HVTkQ== + +esbuild-windows-64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.13.12.tgz#ae694aa66ca078acb8509b2da31197ed1f40f798" + integrity sha512-k4tX4uJlSbSkfs78W5d9+I9gpd+7N95W7H2bgOMFPsYREVJs31+Q2gLLHlsnlY95zBoPQMIzHooUIsixQIBjaQ== + +esbuild-windows-arm64@0.13.12: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.12.tgz#782c5a8bd6d717ea55aaafe648f9926ca36a4a88" + integrity sha512-2tTv/BpYRIvuwHpp2M960nG7uvL+d78LFW/ikPItO+2GfK51CswIKSetSpDii+cjz8e9iSPgs+BU4o8nWICBwQ== + +esbuild@^0.13.0: + version "0.13.12" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.13.12.tgz#9cac641594bf03cf34145258c093d743ebbde7ca" + integrity sha512-vTKKUt+yoz61U/BbrnmlG9XIjwpdIxmHB8DlPR0AAW6OdS+nBQBci6LUHU2q9WbBobMEIQxxDpKbkmOGYvxsow== + optionalDependencies: + esbuild-android-arm64 "0.13.12" + esbuild-darwin-64 "0.13.12" + esbuild-darwin-arm64 "0.13.12" + esbuild-freebsd-64 "0.13.12" + esbuild-freebsd-arm64 "0.13.12" + esbuild-linux-32 "0.13.12" + esbuild-linux-64 "0.13.12" + esbuild-linux-arm "0.13.12" + esbuild-linux-arm64 "0.13.12" + esbuild-linux-mips64le "0.13.12" + esbuild-linux-ppc64le "0.13.12" + esbuild-netbsd-64 "0.13.12" + esbuild-openbsd-64 "0.13.12" + esbuild-sunos-64 "0.13.12" + esbuild-windows-32 "0.13.12" + esbuild-windows-64 "0.13.12" + esbuild-windows-arm64 "0.13.12" escalade@^3.1.1: version "3.1.1" @@ -5650,15 +5694,10 @@ eventemitter3@^4.0.0: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.0.tgz#d65176163887ee59f386d64c82610b696a4a74eb" integrity sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg== -events@^1.0.2: - version "1.1.1" - resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" - integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ= - -events@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59" - integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg== +events@^3.1.0, events@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: version "1.0.3" @@ -5696,6 +5735,11 @@ execa@^4.0.1: signal-exit "^3.0.2" strip-final-newline "^2.0.0" +exif-reader@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/exif-reader/-/exif-reader-1.0.3.tgz#8eb63f878aeb49ec89bd5b7be10e393db78c3c2e" + integrity sha512-tWMBj1+9jUSibgR/kv/GQ/fkR0biaN9GEZ5iPdf7jFeH//d2bSzgPoaWf1OfMv4MXFD4upwvpCCyeMvSyLWSfA== + expand-brackets@^2.1.4: version "2.1.4" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" @@ -5865,7 +5909,7 @@ fastq@^1.6.0: dependencies: reusify "^1.0.0" -fault@^1.0.0, fault@^1.0.1: +fault@^1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/fault/-/fault-1.0.4.tgz#eafcfc0a6d214fc94601e170df29954a4f842f13" integrity sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA== @@ -6090,10 +6134,10 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469" integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== -flow-bin@0.160.1: - version "0.160.1" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.160.1.tgz#ae24ad6def1f05ae37789b6cc332b58975d29de0" - integrity sha512-LvQ9lB/vwW+lPjYIyACcGQCSLvL9f9hOM9jJJtfHQRrIgIShWqjvyv5V24M57HSxh0+6dBbVDYhUiZjjeArf7A== +flow-bin@0.161.0: + version "0.161.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.161.0.tgz#1c03ea4a9e3036a8bc639f050bd8dc6f5288e8bb" + integrity sha512-5BKQi+sjOXz67Kbc1teiBwd5e0Da6suW7S5oUCm9VclnzSZ3nlfNZUdrkvgJ5S4w5KDBDToEL7rREpn8rKF1zg== flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: version "1.1.1" @@ -6657,13 +6701,13 @@ glslify-bundle@^5.1.1: murmurhash-js "^1.0.0" shallow-copy "0.0.1" -glslify-deps@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/glslify-deps/-/glslify-deps-1.3.1.tgz#dfa6962322454a91ecc4de25b5e710415b0c89ad" - integrity sha512-Ogm179MCazwIRyEqs3g3EOY4Y3XIAa0yl8J5RE9rJC6QH1w8weVOp2RZu0mvnYy/2xIas1w166YR2eZdDkWQxg== +glslify-deps@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/glslify-deps/-/glslify-deps-1.3.2.tgz#c09ee945352bfc07ac2d8a1cc9e3de776328c72b" + integrity sha512-7S7IkHWygJRjcawveXQjRXLO2FTjijPDYC7QfZyAQanY+yGLCFHYnPtsGT9bdyHiwPTw/5a1m1M9hamT2aBpag== dependencies: "@choojs/findup" "^0.2.0" - events "^1.0.2" + events "^3.2.0" glsl-resolve "0.0.1" glsl-tokenizer "^2.0.0" graceful-fs "^4.1.2" @@ -6950,11 +6994,6 @@ he@1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -hex-color-regex@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e" - integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ== - highlight.js@~10.4.0: version "10.4.1" resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.4.1.tgz#d48fbcf4a9971c4361b3f95f302747afe19dbad0" @@ -6988,16 +7027,6 @@ hosted-git-info@^4.0.1: dependencies: lru-cache "^6.0.0" -hsl-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/hsl-regex/-/hsl-regex-1.0.0.tgz#d49330c789ed819e276a4c0d272dffa30b18fe6e" - integrity sha1-1JMwx4ntgZ4nakwNJy3/owsY/m4= - -hsla-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/hsla-regex/-/hsla-regex-1.0.0.tgz#c1ce7a3168c8c6614033a4b5f7877f3b225f9c38" - integrity sha1-wc56MWjIxmFAM6S194d/OyJfnDg= - html-encoding-sniffer@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz#e70d84b94da53aa375e11fe3a351be6642ca46f8" @@ -7062,18 +7091,6 @@ htmlparser2@^7.1.1: domutils "^2.8.0" entities "^3.0.1" -htmlparser2@~3.9.2: - version "3.9.2" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" - integrity sha1-G9+HrMoPP55T+k/M6w9LTLsAszg= - dependencies: - domelementtype "^1.3.0" - domhandler "^2.3.0" - domutils "^1.5.1" - entities "^1.1.1" - inherits "^2.0.1" - readable-stream "^2.0.2" - http-cache-semantics@^3.8.1: version "3.8.1" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2" @@ -7467,7 +7484,7 @@ is-boolean-object@^1.1.0: dependencies: call-bind "^1.0.2" -is-buffer@^1.1.4, is-buffer@^1.1.5, is-buffer@~1.1.1: +is-buffer@^1.1.5, is-buffer@~1.1.1: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== @@ -7489,18 +7506,6 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-color-stop@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-color-stop/-/is-color-stop-1.1.0.tgz#cfff471aee4dd5c9e158598fbe12967b5cdad345" - integrity sha1-z/9HGu5N1cnhWFmPvhKWe1za00U= - dependencies: - css-color-names "^0.0.4" - hex-color-regex "^1.1.0" - hsl-regex "^1.0.0" - hsla-regex "^1.0.0" - rgb-regex "^1.0.1" - rgba-regex "^1.0.0" - is-core-module@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" @@ -8772,13 +8777,13 @@ micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: snapdragon "^0.8.1" to-regex "^3.0.2" -micromatch@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" - integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q== +micromatch@^4.0.2, micromatch@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" + integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== dependencies: braces "^3.0.1" - picomatch "^2.0.5" + picomatch "^2.2.3" miller-rabin@^4.0.0: version "4.0.1" @@ -8876,7 +8881,7 @@ minimist-options@^3.0.1: arrify "^1.0.1" is-plain-obj "^1.1.0" -minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5, minimist@~1.2.0: +minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== @@ -8932,12 +8937,12 @@ mkdirp-promise@^5.0.1: dependencies: mkdirp "*" -mkdirp@*, mkdirp@^1.0.4: +mkdirp@*, mkdirp@^1.0.4, mkdirp@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== -mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1, mkdirp@~0.5.x: +mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== @@ -9181,11 +9186,16 @@ node-addon-api@^1.7.1: resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.1.tgz#cf813cd69bb8d9100f6bdca6755fc268f54ac492" integrity sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ== -node-addon-api@^3.0.2, node-addon-api@^3.2.0: +node-addon-api@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== +node-addon-api@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.2.0.tgz#117cbb5a959dff0992e1c586ae0393573e4d2a87" + integrity sha512-eazsqzwG2lskuzBqCGPi7Ac2UgOoMz8JVOXVhTvvPDYhthvNpefx8jWD8Np7Gv+2Sz0FlPWZk0nJV0z598Wn8Q== + node-elm-compiler@^5.0.5: version "5.0.5" resolved "https://registry.yarnpkg.com/node-elm-compiler/-/node-elm-compiler-5.0.5.tgz#a47c027d766d0fba53ea0f19c8e2e82992e9c87d" @@ -9215,10 +9225,10 @@ node-forge@^0.10.0: resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3" integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA== -node-gyp-build@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.2.3.tgz#ce6277f853835f718829efb47db20f3e4d9c4739" - integrity sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg== +node-gyp-build@^4.2.3, node-gyp-build@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" + integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== node-gyp@^5.0.2: version "5.0.7" @@ -9292,11 +9302,6 @@ normalize-url@^3.3.0: resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559" integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg== -normalize-url@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" - integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== - normalize-url@^6.0.1: version "6.1.0" resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" @@ -9809,18 +9814,6 @@ parse-asn1@^5.0.0: pbkdf2 "^3.0.3" safe-buffer "^5.1.1" -parse-entities@^1.1.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/parse-entities/-/parse-entities-1.2.2.tgz#c31bf0f653b6661354f8973559cb86dd1d5edf50" - integrity sha512-NzfpbxW/NPrzZ/yYSoQxyqUZMZXIdCfE0OIN4ESsnptHJECoUk3FZktxNuzQf4tjt5UEopnxpYJbvYuxIFDdsg== - dependencies: - character-entities "^1.0.0" - character-entities-legacy "^1.0.0" - character-reference-invalid "^1.0.0" - is-alphanumerical "^1.0.0" - is-decimal "^1.0.0" - is-hexadecimal "^1.0.0" - parse-entities@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/parse-entities/-/parse-entities-2.0.0.tgz#53c6eb5b9314a1f4ec99fa0fdf7ce01ecda0cbe8" @@ -10045,10 +10038,10 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1: - version "2.2.2" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" - integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3: + version "2.3.0" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" + integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== pify@^2.0.0, pify@^2.3.0: version "2.3.0" @@ -10213,15 +10206,6 @@ postcss-minify-font-values@^5.0.1: dependencies: postcss-value-parser "^4.1.0" -postcss-minify-gradients@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/postcss-minify-gradients/-/postcss-minify-gradients-5.0.1.tgz#2dc79fd1a1afcb72a9e727bc549ce860f93565d2" - integrity sha512-odOwBFAIn2wIv+XYRpoN2hUV3pPQlgbJ10XeXPq8UY2N+9ZG42xu45lTn/g9zZ+d70NKSQD6EOi6UiCMu3FN7g== - dependencies: - cssnano-utils "^2.0.1" - is-color-stop "^1.1.0" - postcss-value-parser "^4.1.0" - postcss-minify-gradients@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/postcss-minify-gradients/-/postcss-minify-gradients-5.0.2.tgz#7c175c108f06a5629925d698b3c4cf7bd3864ee5" @@ -10380,15 +10364,6 @@ postcss-normalize-unicode@^5.0.1: browserslist "^4.16.0" postcss-value-parser "^4.1.0" -postcss-normalize-url@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/postcss-normalize-url/-/postcss-normalize-url-5.0.1.tgz#ffa9fe545935d8b57becbbb7934dd5e245513183" - integrity sha512-hkbG0j58Z1M830/CJ73VsP7gvlG1yF+4y7Fd1w4tD2c7CaA2Psll+pQ6eQhth9y9EaqZSLzamff/D0MZBMbYSg== - dependencies: - is-absolute-url "^3.0.3" - normalize-url "^4.5.0" - postcss-value-parser "^4.1.0" - postcss-normalize-url@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/postcss-normalize-url/-/postcss-normalize-url-5.0.2.tgz#ddcdfb7cede1270740cf3e4dfc6008bd96abc763" @@ -10405,14 +10380,6 @@ postcss-normalize-whitespace@^5.0.1: dependencies: postcss-value-parser "^4.1.0" -postcss-ordered-values@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/postcss-ordered-values/-/postcss-ordered-values-5.0.1.tgz#79ef6e2bd267ccad3fc0c4f4a586dfd01c131f64" - integrity sha512-6mkCF5BQ25HvEcDfrMHCLLFHlraBSlOXFnQMHYhSpDO/5jSR1k8LdEXOkv+7+uzW6o6tBYea1Km0wQSRkPJkwA== - dependencies: - cssnano-utils "^2.0.1" - postcss-value-parser "^4.1.0" - postcss-ordered-values@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/postcss-ordered-values/-/postcss-ordered-values-5.0.2.tgz#1f351426977be00e0f765b3164ad753dac8ed044" @@ -10512,16 +10479,7 @@ postcss@^7.0.14, postcss@^7.0.17, postcss@^7.0.32, postcss@^7.0.5, postcss@^7.0. source-map "^0.6.1" supports-color "^6.1.0" -postcss@^8.1.6, postcss@^8.2.1, postcss@^8.3.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.0.tgz#b1a713f6172ca427e3f05ef1303de8b65683325f" - integrity sha512-+ogXpdAjWGa+fdYY5BQ96V/6tAo+TdSSIMP5huJBIygdWwKtVoB5JWZ7yUd4xZ8r+8Kvvx4nyg/PQ071H4UtcQ== - dependencies: - colorette "^1.2.2" - nanoid "^3.1.23" - source-map-js "^0.6.2" - -postcss@^8.3.6: +postcss@^8.1.6, postcss@^8.2.1, postcss@^8.3.0, postcss@^8.3.6: version "8.3.6" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.6.tgz#2730dd76a97969f37f53b9a6096197be311cc4ea" integrity sha512-wG1cc/JhRgdqB6WHEuyLTedf3KIRuD0hG6ldkFEZNCjRxiC+3i6kkWUUbiJQayP28iwG35cEmAbe98585BYV0A== @@ -10574,25 +10532,11 @@ posthtml-parser@^0.7.1, posthtml-parser@^0.7.2: dependencies: htmlparser2 "^6.0.0" -posthtml-parser@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/posthtml-parser/-/posthtml-parser-0.9.0.tgz#8e7d817eb6c27885b9c7395007371d4363a5867d" - integrity sha512-Ybw75S+aNJuXCoCUBF2drLRip18cwbT4IBKAT6Xx7VU6FxjuDIV5VofPZRQzgwzGsASZ++5JpRhK3vagPZ4JIQ== - dependencies: - htmlparser2 "^6.0.0" - posthtml-render@^1.3.1, posthtml-render@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/posthtml-render/-/posthtml-render-1.4.0.tgz#40114070c45881cacb93347dae3eff53afbcff13" integrity sha512-W1779iVHGfq0Fvh2PROhCe2QhB8mEErgqzo1wpIt36tCgChafP+hbXIhLDOM8ePJrZcFs0vkNEtdibEWVqChqw== -posthtml-render@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/posthtml-render/-/posthtml-render-2.0.6.tgz#f39035b133f1cea1a879cba3982a7eaa1fc06c34" - integrity sha512-AvjM4yfEtjhbpZdtLOWfnezgojEtgeejSxrjTAvfr5phXjPcZQyB5QiOvYeU+rrTF0u+eqqlJrs8HS3nrPexGQ== - dependencies: - is-json "^2.0.1" - posthtml-render@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/posthtml-render/-/posthtml-render-3.0.0.tgz#97be44931496f495b4f07b99e903cc70ad6a3205" @@ -10608,15 +10552,7 @@ posthtml@^0.15.1: posthtml-parser "^0.7.2" posthtml-render "^1.3.1" -posthtml@^0.16.4: - version "0.16.4" - resolved "https://registry.yarnpkg.com/posthtml/-/posthtml-0.16.4.tgz#4f9b326357a39a820376fb065aa55bb1d313c97a" - integrity sha512-32VVeMtkoUrWI84etFPBBhOOJS19WAJDxJMLYi3dKma2sPtDDpO2CrR5dV8rVMPwZoAeVYxIdpaE4aqY12ibOA== - dependencies: - posthtml-parser "^0.9.0" - posthtml-render "^2.0.6" - -posthtml@^0.16.5: +posthtml@^0.16.4, posthtml@^0.16.5: version "0.16.5" resolved "https://registry.yarnpkg.com/posthtml/-/posthtml-0.16.5.tgz#d32f5cf32436516d49e0884b2367d0a1424136f6" integrity sha512-1qOuPsywVlvymhTFIBniDXwUDwvlDri5KUQuBqjmCc8Jj4b/HDSVWU//P6rTWke5rzrk+vj7mms2w8e1vD0nnw== @@ -10629,10 +10565,10 @@ preact@^10.5.9: resolved "https://registry.yarnpkg.com/preact/-/preact-10.5.9.tgz#8caba9288b4db1d593be2317467f8735e43cda0b" integrity sha512-X4m+4VMVINl/JFQKALOCwa3p8vhMAhBvle0hJ/W44w/WWfNb2TA7RNicDV3K2dNVs57f61GviEnVLiwN+fxiIg== -prebuild-install@^6.1.2: - version "6.1.3" - resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.1.3.tgz#8ea1f9d7386a0b30f7ef20247e36f8b2b82825a2" - integrity sha512-iqqSR84tNYQUQHRXalSKdIaM8Ov1QxOVuBNWI7+BzZWv6Ih9k75wOnH1rGQ9WWTaaLkTpxWKIciOF0KyfM74+Q== +prebuild-install@^6.1.4: + version "6.1.4" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.1.4.tgz#ae3c0142ad611d58570b89af4986088a4937e00f" + integrity sha512-Z4vpywnK1lBg+zdPCVCsKq0xO66eEV9rWo2zrROGGiRS4JtueBOdlB1FnY8lcy7JsUud/Q3ijUxyWN26Ika0vQ== dependencies: detect-libc "^1.0.3" expand-template "^2.0.3" @@ -10658,16 +10594,16 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prettier@1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== - prettier@2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== +prettier@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c" + integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA== + pretty-hrtime@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" @@ -10956,7 +10892,7 @@ querystring-es3@^0.2.1: resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" integrity sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM= -querystring@0.2.0, querystring@^0.2.0: +querystring@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= @@ -11383,14 +11319,6 @@ remark-footnotes@2.0.0: resolved "https://registry.yarnpkg.com/remark-footnotes/-/remark-footnotes-2.0.0.tgz#9001c4c2ffebba55695d2dd80ffb8b82f7e6303f" integrity sha512-3Clt8ZMH75Ayjp9q4CorNeyjwIxHFcTkaektplKGl2A1jNGEUey8cKL0ZC5vJwfcD5GFGsNLImLG/NGzWIzoMQ== -remark-frontmatter@^1.2.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/remark-frontmatter/-/remark-frontmatter-1.3.2.tgz#91d9684319cd1b96cc3d9d901f10a978f39c752d" - integrity sha512-2eayxITZ8rezsXdgcXnYB3iLivohm2V/ZT4Ne8uhua6A4pk6GdLE2ZzJnbnINtD1HRLaTdB7RwF9sgUbMptJZA== - dependencies: - fault "^1.0.1" - xtend "^4.0.1" - remark-mdx@1.6.22: version "1.6.22" resolved "https://registry.yarnpkg.com/remark-mdx/-/remark-mdx-1.6.22.tgz#06a8dab07dcfdd57f3373af7f86bd0e992108bbd" @@ -11427,27 +11355,6 @@ remark-parse@8.0.3: vfile-location "^3.0.0" xtend "^4.0.1" -remark-parse@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-5.0.0.tgz#4c077f9e499044d1d5c13f80d7a98cf7b9285d95" - integrity sha512-b3iXszZLH1TLoyUzrATcTQUZrwNl1rE70rVdSruJFlDaJ9z5aMkhrG43Pp68OgfHndL/ADz6V69Zow8cTQu+JA== - dependencies: - collapse-white-space "^1.0.2" - is-alphabetical "^1.0.0" - is-decimal "^1.0.0" - is-whitespace-character "^1.0.0" - is-word-character "^1.0.0" - markdown-escapes "^1.0.0" - parse-entities "^1.1.0" - repeat-string "^1.5.4" - state-toggle "^1.0.0" - trim "0.0.1" - trim-trailing-lines "^1.0.0" - unherit "^1.0.4" - unist-util-remove-position "^1.0.0" - vfile-location "^2.0.0" - xtend "^4.0.1" - remark-squeeze-paragraphs@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/remark-squeeze-paragraphs/-/remark-squeeze-paragraphs-4.0.0.tgz#76eb0e085295131c84748c8e43810159c5653ead" @@ -11656,16 +11563,6 @@ reusify@^1.0.0: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rgb-regex@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/rgb-regex/-/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1" - integrity sha1-wODWiC3w4jviVKR16O3UGRX+rrE= - -rgba-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3" - integrity sha1-QzdOLiyglosO8VI0YLfXMP8i7rM= - rimraf@2.6.3, rimraf@~2.6.2: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" @@ -11773,30 +11670,6 @@ scheduler@^0.18.0: loose-envify "^1.1.0" object-assign "^4.1.1" -"self-published@npm:@parcel/fs-search@2.0.0-rc.0": - version "2.0.0-rc.0" - resolved "https://registry.yarnpkg.com/@parcel/fs-search/-/fs-search-2.0.0-rc.0.tgz#c0a26cec8a703d1490ab7e8d323b9d2191212d19" - integrity sha512-x/gdmnxWIhuP6kVUe3u8fiY5JBCmALHNJIPNDGdoVada1CEEHF+DJtQG7LT+LIcPFeAqXT6qx05HrgO94KLaUQ== - dependencies: - detect-libc "^1.0.3" - -"self-published@npm:@parcel/transformer-js@2.0.0-rc.0": - version "2.0.0-rc.0" - resolved "https://registry.yarnpkg.com/@parcel/transformer-js/-/transformer-js-2.0.0-rc.0.tgz#92437bca0c48289ea7044c98f583b6a9d5028e90" - integrity sha512-zmp2ha7fnIBCG7d56MBneXjZxhOBcJLXpO+3rpiwGoic2fQdcNk702QHGBmfqnZW4u/pebGZpolj/wUqtP0bcQ== - dependencies: - "@parcel/diagnostic" "2.0.0-rc.0" - "@parcel/plugin" "2.0.0-rc.0" - "@parcel/source-map" "2.0.0-rc.6" - "@parcel/utils" "2.0.0-rc.0" - "@swc/helpers" "^0.2.11" - browserslist "^4.6.6" - detect-libc "^1.0.3" - micromatch "^4.0.2" - nullthrows "^1.1.1" - regenerator-runtime "^0.13.7" - semver "^5.4.1" - semver-compare@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" @@ -11892,15 +11765,15 @@ shallow-copy@0.0.1: resolved "https://registry.yarnpkg.com/shallow-copy/-/shallow-copy-0.0.1.tgz#415f42702d73d810330292cc5ee86eae1a11a170" integrity sha1-QV9CcC1z2BAzApLMXuhurhoRoXA= -sharp@^0.28.3: - version "0.28.3" - resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.28.3.tgz#ecd74cefd020bee4891bb137c9850ee2ce277a8b" - integrity sha512-21GEP45Rmr7q2qcmdnjDkNP04Ooh5v0laGS5FDpojOO84D1DJwUijLiSq8XNNM6e8aGXYtoYRh3sVNdm8NodMA== +sharp@^0.29.1: + version "0.29.2" + resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.29.2.tgz#e8c003cd9cb321585b32dbda6eed3baa7d6f2308" + integrity sha512-XWRdiYLIJ3tDUejRyG24KERnJzMfIoyiJBntd2S6/uj3NEeNgRFRLgiBlvPxMa8aml14dKKD98yHinSNKp1xzQ== dependencies: - color "^3.1.3" + color "^4.0.1" detect-libc "^1.0.3" - node-addon-api "^3.2.0" - prebuild-install "^6.1.2" + node-addon-api "^4.2.0" + prebuild-install "^6.1.4" semver "^7.3.5" simple-get "^3.1.0" tar-fs "^2.1.1" @@ -12097,7 +11970,7 @@ source-map-js@^0.6.2: resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e" integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug== -source-map-resolve@^0.5.0, source-map-resolve@^0.5.2: +source-map-resolve@^0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== @@ -12108,6 +11981,14 @@ source-map-resolve@^0.5.0, source-map-resolve@^0.5.2: source-map-url "^0.4.0" urix "^0.1.0" +source-map-resolve@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2" + integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + source-map-support@^0.5.16, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" @@ -12508,13 +12389,6 @@ strong-log-transformer@^2.0.0: minimist "^1.2.0" through "^2.3.4" -structured-source@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/structured-source/-/structured-source-3.0.2.tgz#dd802425e0f53dc4a6e7aca3752901a1ccda7af5" - integrity sha1-3YAkJeD1PcSm56yjdSkBoczaevU= - dependencies: - boundary "^1.0.1" - style-to-object@0.3.0, style-to-object@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/style-to-object/-/style-to-object-0.3.0.tgz#b1b790d205991cc783801967214979ee19a76e46" @@ -12542,18 +12416,18 @@ stylus@0.54.5: sax "0.5.x" source-map "0.1.x" -stylus@^0.54.5: - version "0.54.7" - resolved "https://registry.yarnpkg.com/stylus/-/stylus-0.54.7.tgz#c6ce4793965ee538bcebe50f31537bfc04d88cd2" - integrity sha512-Yw3WMTzVwevT6ZTrLCYNHAFmanMxdylelL3hkWNgPMeTCpMwpV3nXjpOHuBXtFv7aiO2xRuQS6OoAdgkNcSNug== +stylus@^0.55.0: + version "0.55.0" + resolved "https://registry.yarnpkg.com/stylus/-/stylus-0.55.0.tgz#bd404a36dd93fa87744a9dd2d2b1b8450345e5fc" + integrity sha512-MuzIIVRSbc8XxHH7FjkvWqkIcr1BvoMZoR/oFuAJDlh7VSaNJzrB4uJ38GRQa+mWjLXODAMzeDe0xi9GYbGwnw== dependencies: - css-parse "~2.0.0" + css "^3.0.0" debug "~3.1.0" - glob "^7.1.3" - mkdirp "~0.5.x" + glob "^7.1.6" + mkdirp "~1.0.4" safer-buffer "^2.1.2" sax "~1.2.4" - semver "^6.0.0" + semver "^6.3.0" source-map "^0.7.3" sugarss@^3.0.3: @@ -12783,16 +12657,7 @@ terminal-link@^2.1.1: ansi-escapes "^4.2.1" supports-hyperlinks "^2.0.0" -terser@^5.2.0, terser@^5.2.1: - version "5.7.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.0.tgz#a761eeec206bc87b605ab13029876ead938ae693" - integrity sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g== - dependencies: - commander "^2.20.0" - source-map "~0.7.2" - source-map-support "~0.5.19" - -terser@^5.7.2: +terser@^5.2.0, terser@^5.2.1, terser@^5.7.2: version "5.7.2" resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.2.tgz#d4d95ed4f8bf735cb933e802f2a1829abf545e3f" integrity sha512-0Omye+RD4X7X69O0eql3lC4Heh/5iLj3ggxR/B5ketZLOtLiOqukUgjw3q4PDnNQbsrkKr3UMypqStQG3XKRvw== @@ -12991,11 +12856,6 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" -traverse@^0.6.6: - version "0.6.6" - resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" - integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= - trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" @@ -13200,11 +13060,6 @@ uncss@^0.17.3: postcss-selector-parser "6.0.2" request "^2.88.0" -underscore@~1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" - integrity sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI= - undertaker-registry@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/undertaker-registry/-/undertaker-registry-1.0.1.tgz#5e4bda308e4a8a2ae584f9b9a4359a499825cc50" @@ -13268,18 +13123,6 @@ unified@9.2.0: trough "^1.0.0" vfile "^4.0.0" -unified@^6.1.6: - version "6.2.0" - resolved "https://registry.yarnpkg.com/unified/-/unified-6.2.0.tgz#7fbd630f719126d67d40c644b7e3f617035f6dba" - integrity sha512-1k+KPhlVtqmG99RaTbAv/usu85fcSRu3wY8X+vnsEhIxNP5VbVIDiXnLqyKIG+UMdyTg0ZX9EI6k2AfjJkHPtA== - dependencies: - bail "^1.0.0" - extend "^3.0.0" - is-plain-obj "^1.1.0" - trough "^1.0.0" - vfile "^2.0.0" - x-is-string "^0.1.0" - union-value@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" @@ -13339,11 +13182,6 @@ unist-util-generated@^1.0.0: resolved "https://registry.yarnpkg.com/unist-util-generated/-/unist-util-generated-1.1.6.tgz#5ab51f689e2992a472beb1b35f2ce7ff2f324d4b" integrity sha512-cln2Mm1/CZzN5ttGK7vkoGw+RZ8VcUH6BtGbq98DDtRGquAAOXig1mrBQYelOwMXYS8rK+vZDyyojSjp7JX+Lg== -unist-util-is@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-3.0.0.tgz#d9e84381c2468e82629e4a5be9d7d05a2dd324cd" - integrity sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A== - unist-util-is@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-4.0.1.tgz#ae3e39b9ad1b138c8e3b9d2f4658ad0031be4610" @@ -13354,13 +13192,6 @@ unist-util-position@^3.0.0: resolved "https://registry.yarnpkg.com/unist-util-position/-/unist-util-position-3.0.4.tgz#5872be7aec38629b971fdb758051f78817b0040a" integrity sha512-tWvIbV8goayTjobxDIr4zVTyG+Q7ragMSMeKC3xnPl9xzIc0+she8mxXLM3JVNDDsfARPbCd3XdzkyLdo7fF3g== -unist-util-remove-position@^1.0.0: - version "1.1.4" - resolved "https://registry.yarnpkg.com/unist-util-remove-position/-/unist-util-remove-position-1.1.4.tgz#ec037348b6102c897703eee6d0294ca4755a2020" - integrity sha512-tLqd653ArxJIPnKII6LMZwH+mb5q+n/GtXQZo6S6csPRs5zB0u79Yw8ouR3wTw8wxvdJFhpP6Y7jorWdCgLO0A== - dependencies: - unist-util-visit "^1.1.0" - unist-util-remove-position@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/unist-util-remove-position/-/unist-util-remove-position-2.0.1.tgz#5d19ca79fdba712301999b2b73553ca8f3b352cc" @@ -13375,11 +13206,6 @@ unist-util-remove@^2.0.0: dependencies: unist-util-is "^4.0.0" -unist-util-stringify-position@^1.0.0, unist-util-stringify-position@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz#3f37fcf351279dcbca7480ab5889bb8a832ee1c6" - integrity sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ== - unist-util-stringify-position@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/unist-util-stringify-position/-/unist-util-stringify-position-2.0.2.tgz#5a3866e7138d55974b640ec69a94bc19e0f3fa12" @@ -13387,13 +13213,6 @@ unist-util-stringify-position@^2.0.0: dependencies: "@types/unist" "^2.0.2" -unist-util-visit-parents@^2.0.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz#25e43e55312166f3348cae6743588781d112c1e9" - integrity sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g== - dependencies: - unist-util-is "^3.0.0" - unist-util-visit-parents@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-3.0.1.tgz#666883dc8684c6eec04a7e9781cdcd8b4888319f" @@ -13411,13 +13230,6 @@ unist-util-visit@2.0.3, unist-util-visit@^2.0.0: unist-util-is "^4.0.0" unist-util-visit-parents "^3.0.0" -unist-util-visit@^1.1.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-1.4.1.tgz#4724aaa8486e6ee6e26d7ff3c8685960d560b1e3" - integrity sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw== - dependencies: - unist-util-visit-parents "^2.0.0" - universal-user-agent@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16" @@ -13465,11 +13277,6 @@ upath@^1.1.1, upath@^1.2.0: resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894" integrity sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg== -update-section@^0.3.0: - version "0.3.3" - resolved "https://registry.yarnpkg.com/update-section/-/update-section-0.3.3.tgz#458f17820d37820dc60e20b86d94391b00123158" - integrity sha1-RY8Xgg03gg3GDiC4bZQ5GwASMVg= - uri-js@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" @@ -13600,23 +13407,11 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" -vfile-location@^2.0.0: - version "2.0.6" - resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-2.0.6.tgz#8a274f39411b8719ea5728802e10d9e0dff1519e" - integrity sha512-sSFdyCP3G6Ka0CEmN83A2YCMKIieHx0EDaj5IDP4g1pa5ZJ4FJDvpO0WODLxo4LUX4oe52gmSCK7Jw4SBghqxA== - vfile-location@^3.0.0, vfile-location@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-3.2.0.tgz#d8e41fbcbd406063669ebf6c33d56ae8721d0f3c" integrity sha512-aLEIZKv/oxuCDZ8lkJGhuhztf/BW4M+iHdCwglA/eWc+vtuRFJj8EtgceYFX4LRjOhCAAiNHsKGssC6onJ+jbA== -vfile-message@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-1.1.1.tgz#5833ae078a1dfa2d96e9647886cd32993ab313e1" - integrity sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA== - dependencies: - unist-util-stringify-position "^1.1.1" - vfile-message@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-2.0.2.tgz#75ba05090ec758fa8420f2c11ce049bcddd8cf3e" @@ -13625,16 +13420,6 @@ vfile-message@^2.0.0: "@types/unist" "^2.0.0" unist-util-stringify-position "^2.0.0" -vfile@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/vfile/-/vfile-2.3.0.tgz#e62d8e72b20e83c324bc6c67278ee272488bf84a" - integrity sha512-ASt4mBUHcTpMKD/l5Q+WJXNtshlWxOogYyGYYrg4lt/vuRjC1EFQtlAofL5VmtVNIZJzWYFJjzGWZ0Gw8pzW1w== - dependencies: - is-buffer "^1.1.4" - replace-ext "1.0.0" - unist-util-stringify-position "^1.0.0" - vfile-message "^1.0.0" - vfile@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/vfile/-/vfile-4.0.2.tgz#71af004d4a710b0e6be99c894655bc56126d5d56" @@ -14245,11 +14030,6 @@ ws@^7.0.0: resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.0.tgz#a5dd76a24197940d4a8bb9e0e152bb4503764da7" integrity sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ== -x-is-string@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/x-is-string/-/x-is-string-0.1.0.tgz#474b50865af3a49a9c4657f05acd145458f77d82" - integrity sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI= - xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" @@ -14305,12 +14085,7 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml@^1.10.0, yaml@^1.7.2: - version "1.10.0" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" - integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== - -yaml@^1.10.2: +yaml@^1.10.0, yaml@^1.10.2, yaml@^1.7.2: version "1.10.2" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==