From ba57b6501632703d68923b214b0c0f6d47a34b1f Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 9 May 2021 17:13:29 -0700 Subject: [PATCH] Rewrite JS transformer and scope hoisting in Rust (#6230) --- .../fs-search/.cargo => .cargo}/config.toml | 0 .github/workflows/nightly-release.yml | 56 +- .github/workflows/tag-release.yml | 56 +- .gitignore | 1 - .prettierrc | 1 + Cargo.lock | 1474 ++++++- Cargo.toml | 4 +- azure-pipelines-template.yml | 4 +- gulpfile.js | 2 + lerna.json | 2 +- package.json | 6 +- packages/configs/default/index.json | 1 - packages/configs/default/package.json | 3 +- packages/core/core/src/Transformation.js | 102 +- packages/core/core/src/UncommittedAsset.js | 9 + packages/core/core/src/Validation.js | 2 + packages/core/core/src/assetUtils.js | 10 +- packages/core/core/src/loadDotEnv.js | 12 +- packages/core/core/src/loadParcelPlugin.js | 16 +- packages/core/core/src/public/Asset.js | 6 +- packages/core/core/src/public/Config.js | 1 + .../core/src/requests/ParcelConfigRequest.js | 8 +- .../core/core/src/requests/TargetRequest.js | 8 +- packages/core/core/src/resolveOptions.js | 19 +- packages/core/core/test/test-utils.js | 2 +- packages/core/fs/src/MemoryFS.js | 8 +- packages/core/fs/src/OverlayFS.js | 8 +- packages/core/fs/src/find.js | 10 +- packages/core/fs/src/types.js | 6 +- packages/core/integration-tests/test/babel.js | 265 +- packages/core/integration-tests/test/cache.js | 69 +- packages/core/integration-tests/test/fs.js | 52 +- .../test/integration/babel-custom/.babelrc | 3 + .../test/integration/babel-custom/index.js | 14 + .../test/integration/babel-custom/jsx.js | 4 + .../node_modules/babel-plugin-dummy/index.js | 13 + .../babel-plugin-dummy/package.json | 4 + .../integration/babel-custom/package.json | 6 + .../test/integration/babel-custom/ts.ts | 18 + .../test/integration/babel-custom/tsx.tsx | 8 + .../test/integration/babel-custom/yarn.lock | 0 .../test/integration/babel-env-name/yarn.lock | 0 .../test/integration/env-computed/index.js | 3 + .../integration/env-hasOwnProperty/index.js | 1 + .../formats/commonjs-async/index.js | 2 +- .../formats/commonjs-async/package.json | 7 +- .../formats/commonjs-entry-re-export/b.js | 2 +- .../formats/commonjs-external/multiple.js | 3 +- .../formats/commonjs-external/namespace.js | 3 +- .../formats/commonjs-require/package.json | 7 +- .../integration/formats/esm-browser/index.js | 2 +- .../formats/esm-export-shadow/a.mjs | 6 + .../formats/esm-export-shadow/package.json | 8 + .../formats/esm-export-shadow/yarn.lock | 0 .../formats/esm-import-shadow/a.mjs | 11 + .../node_modules/b/index.mjs | 7 + .../formats/esm-import-shadow/package.json | 8 + .../formats/esm-import-shadow/yarn.lock | 0 .../test/integration/fs-outside-root/index.js | 2 +- .../integration/js-runtime-dedup/async1.js | 3 + .../integration/js-runtime-dedup/async2.js | 3 + .../integration/js-runtime-dedup/index.js | 3 + .../integration/js-runtime-dedup/shared.js | 1 + .../test/integration/mdx/package.json | 5 + .../multi-asset-transformer/.babelrc | 3 + .../multi-asset-transformer/.parcelrc | 6 + .../multi-asset-transformer/index.js | 1 + .../parcel-transformer-test/index.js | 8 + .../parcel-transformer-test/package.json | 4 + .../multi-asset-transformer/yarn.lock | 0 .../parcel-packager-config/index.js | 1 + .../commonjs/export-non-object/index.js | 1 + .../commonjs/export-non-object/other.js | 1 + .../interop-require-commonjs-wrapped/a.js | 2 + .../interop-require-commonjs-wrapped/b.js | 2 + .../module-exports-default-assignment/a.js | 2 + .../module-exports-default-assignment/b.js | 6 + .../index.js | 4 + .../mutated-non-static-require/index.js | 5 + .../mutated-non-static-require/other.js | 1 + .../commonjs/require-local-assign/b.js | 1 + .../commonjs/require-local-assign/basic.js | 5 + .../require-local-assign/destructure.js | 5 + .../require-local-assign/in-function.js | 9 + .../commonjs/require-local-assign/member.js | 5 + .../scope-hoisting/commonjs/require-new/a.js | 1 + .../scope-hoisting/commonjs/require-new/b.js | 5 + .../commonjs/require-non-const-export/b.js | 4 + .../require-non-const-export/destructure.js | 5 + .../commonjs/require-non-const-export/live.js | 5 + .../require-non-const-export/member.js | 6 + .../commonjs/tree-shaking-string/.terserrc | 3 + .../commonjs/tree-shaking/.terserrc | 3 + .../commonjs/wrap-default-interop/async.js | 5 + .../commonjs/wrap-default-interop/index.js | 5 + .../commonjs/wrap-default-interop/run-cjs.js | 6 + .../wrap-default-interop/run-interop.js | 2 + .../commonjs/wrap-default-interop/shared.js | 1 + .../commonjs/wrap-expressions/a.js | 1 + .../commonjs/wrap-expressions/b.js | 11 + .../commonjs/wrap-expressions/require.js | 2 + .../commonjs/wrap-typeof-require/a.js | 2 + .../commonjs/wrap-typeof-require/b.js | 7 + .../commonjs/wrap-typeof-require/c.js | 1 + .../scope-hoisting/es6/circular-wrap/a.mjs | 2 + .../scope-hoisting/es6/circular-wrap/b.mjs | 2 + .../scope-hoisting/es6/circular-wrap/c.mjs | 2 + .../scope-hoisting/es6/circular-wrap/d.mjs | 2 + .../es6/circular-wrap/index.mjs | 2 + .../scope-hoisting/es6/double-esmodule/foo.js | 3 + .../es6/double-esmodule/index.js | 3 + .../es6/export-default-live/a.js | 4 + .../es6/export-default-live/b.js | 6 + .../es6/import-local-assign/b.js | 2 + .../es6/import-local-assign/default.js | 2 + .../import-local-assign/destructure-assign.js | 2 + .../es6/import-local-assign/multiple.js | 3 + .../es6/import-local-assign/named.js | 2 + .../es6/import-local-assign/namespace.js | 2 + .../es6/re-export-namespace-order/index.js | 2 +- .../es6/shared-bundle-reexport/shared/a.js | 1332 +++--- .../async1.js | 1 + .../async2.js | 1 + .../index.js | 1 + .../package.json | 5 + .../v.js | 1 + .../es6/shared-bundle-side-effect-order/a.js | 2 + .../es6/shared-bundle-side-effect-order/b.js | 2 + .../shared-bundle-side-effect-order/index.js | 1 + .../shared-bundle-side-effect-order/run1.js | 2 + .../shared-bundle-side-effect-order/run2.js | 2 + .../shared1.js | 2 + .../shared2.js | 2 + .../.terserrc | 3 + .../es6/tree-shaking-cross-bundle/.terserrc | 3 + .../es6/tree-shaking-dynamic-import/.terserrc | 3 + .../scope-hoisting/es6/tree-shaking/.terserrc | 3 + .../service-worker-import-meta-url/missing.js | 2 +- .../test/integration/svg/package.json | 5 + .../core/integration-tests/test/javascript.js | 112 +- .../core/integration-tests/test/monorepos.js | 26 +- .../integration-tests/test/output-formats.js | 511 +-- .../core/integration-tests/test/plugin.js | 13 + .../core/integration-tests/test/postcss.js | 11 +- .../core/integration-tests/test/posthtml.js | 11 +- .../integration-tests/test/scope-hoisting.js | 761 +++- .../core/integration-tests/test/server.js | 2 +- .../core/integration-tests/test/sourcemaps.js | 2 +- .../integration-tests/test/transpilation.js | 214 + .../core/integration-tests/test/typescript.js | 4 +- .../package-manager/src/NodePackageManager.js | 20 +- .../core/package-manager/src/NodeResolver.js | 6 +- .../package-manager/src/NodeResolverBase.js | 8 +- .../package-manager/src/NodeResolverSync.js | 6 +- .../package-manager/src/installPackage.js | 74 +- packages/core/package-manager/src/utils.js | 3 +- .../test/NodePackageManager.test.js | 2 +- packages/core/parcel/src/cli.js | 4 - packages/core/register/src/register.js | 2 +- packages/core/test-utils/src/utils.js | 114 +- packages/core/utils/src/alternatives.js | 8 +- packages/core/utils/src/config.js | 25 +- packages/core/utils/src/countLines.js | 7 +- packages/core/workers/src/WorkerFarm.js | 10 +- .../htmlnano/src/HTMLNanoOptimizer.js | 1 + .../optimizers/terser/src/TerserOptimizer.js | 1 + packages/packagers/css/src/CSSPackager.js | 3 +- packages/packagers/js/package.json | 8 +- packages/packagers/js/src/CJSOutputFormat.js | 154 + packages/packagers/js/src/DevPackager.js | 198 + packages/packagers/js/src/ESMOutputFormat.js | 93 + .../packagers/js/src/GlobalOutputFormat.js | 21 + packages/packagers/js/src/JSPackager.js | 281 -- .../packagers/js/src/ScopeHoistingPackager.js | 1046 +++++ .../js/src/{prelude.js => dev-prelude.js} | 2 +- packages/packagers/js/src/helpers.js | 75 + packages/packagers/js/src/index.js | 82 + .../reporters/cli/test/CLIReporter.test.js | 2 +- packages/reporters/dev-server/src/Server.js | 11 +- packages/runtimes/js/src/JSRuntime.js | 34 +- .../react-refresh/src/ReactRefreshRuntime.js | 1 + packages/shared/scope-hoisting/.eslintrc.json | 15 - packages/shared/scope-hoisting/package.json | 35 - packages/shared/scope-hoisting/src/concat.js | 425 -- .../scope-hoisting/src/formats/commonjs.js | 391 -- .../scope-hoisting/src/formats/esmodule.js | 215 - .../scope-hoisting/src/formats/global.js | 166 - .../scope-hoisting/src/formats/index.js | 17 - .../shared/scope-hoisting/src/generate.js | 47 - packages/shared/scope-hoisting/src/helpers.js | 45 - packages/shared/scope-hoisting/src/hoist.js | 1288 ------ packages/shared/scope-hoisting/src/index.js | 5 - packages/shared/scope-hoisting/src/link.js | 1091 ----- packages/shared/scope-hoisting/src/prelude.js | 38 - packages/shared/scope-hoisting/src/renamer.js | 37 - packages/shared/scope-hoisting/src/types.js | 49 - packages/shared/scope-hoisting/src/utils.js | 365 -- packages/transformers/babel/package.json | 2 + .../babel/src/BabelTransformer.js | 32 +- packages/transformers/babel/src/babel7.js | 10 + packages/transformers/babel/src/config.js | 132 +- packages/transformers/babel/src/jsx.js | 65 +- packages/transformers/js/.gitignore | 3 + packages/transformers/js/Cargo.toml | 30 + .../transformers/js}/build.rs | 0 packages/transformers/js/hoist.md | 538 +++ packages/transformers/js/package.json | 33 +- packages/transformers/js/src/JSTransformer.js | 533 ++- .../transformers/js/src/decl_collector.rs | 111 + .../js/src/dependency_collector.rs | 674 +++ packages/transformers/js/src/env_replacer.rs | 107 + packages/transformers/js/src/fs.rs | 337 ++ .../transformers/js/src/global_replacer.rs | 195 + packages/transformers/js/src/hoist.rs | 3770 +++++++++++++++++ packages/transformers/js/src/lib.rs | 446 ++ packages/transformers/js/src/modules.rs | 597 +++ packages/transformers/js/src/native.js | 24 + packages/transformers/js/src/utils.rs | 107 + .../js/src/visitors/dependencies.js | 527 --- packages/transformers/js/src/visitors/fs.js | 321 -- .../transformers/js/src/visitors/globals.js | 98 - .../transformers/js/src/visitors/modules.js | 426 -- .../transformers/js/src/visitors/process.js | 66 - .../transformers/js/src/visitors/utils.js | 89 - .../react-refresh-babel/package.json | 26 - .../src/ReactRefreshBabelTransformer.js | 36 - .../react-refresh-wrap/package.json | 6 +- .../src/ReactRefreshWrapTransformer.js | 74 +- .../utils}/fs-search/.gitignore | 0 .../utils}/fs-search/Cargo.toml | 0 packages/utils/fs-search/build.rs | 5 + .../utils}/fs-search/index.js | 9 +- .../utils}/fs-search/package.json | 4 + .../utils}/fs-search/src/lib.rs | 8 +- .../node-resolver-core/src/NodeResolver.js | 8 +- scripts/build-native.js | 19 +- scripts/link-native.js | 3 - yarn.lock | 64 +- 238 files changed, 13366 insertions(+), 8308 deletions(-) rename {native-packages/fs-search/.cargo => .cargo}/config.toml (100%) create mode 100644 packages/core/integration-tests/test/integration/babel-custom/.babelrc create mode 100644 packages/core/integration-tests/test/integration/babel-custom/index.js create mode 100644 packages/core/integration-tests/test/integration/babel-custom/jsx.js create mode 100644 packages/core/integration-tests/test/integration/babel-custom/node_modules/babel-plugin-dummy/index.js create mode 100644 packages/core/integration-tests/test/integration/babel-custom/node_modules/babel-plugin-dummy/package.json create mode 100644 packages/core/integration-tests/test/integration/babel-custom/package.json create mode 100644 packages/core/integration-tests/test/integration/babel-custom/ts.ts create mode 100644 packages/core/integration-tests/test/integration/babel-custom/tsx.tsx create mode 100644 packages/core/integration-tests/test/integration/babel-custom/yarn.lock create mode 100644 packages/core/integration-tests/test/integration/babel-env-name/yarn.lock create mode 100644 packages/core/integration-tests/test/integration/env-computed/index.js create mode 100644 packages/core/integration-tests/test/integration/env-hasOwnProperty/index.js create mode 100644 packages/core/integration-tests/test/integration/formats/esm-export-shadow/a.mjs create mode 100644 packages/core/integration-tests/test/integration/formats/esm-export-shadow/package.json create mode 100644 packages/core/integration-tests/test/integration/formats/esm-export-shadow/yarn.lock create mode 100644 packages/core/integration-tests/test/integration/formats/esm-import-shadow/a.mjs create mode 100644 packages/core/integration-tests/test/integration/formats/esm-import-shadow/node_modules/b/index.mjs create mode 100644 packages/core/integration-tests/test/integration/formats/esm-import-shadow/package.json create mode 100644 packages/core/integration-tests/test/integration/formats/esm-import-shadow/yarn.lock create mode 100644 packages/core/integration-tests/test/integration/js-runtime-dedup/async1.js create mode 100644 packages/core/integration-tests/test/integration/js-runtime-dedup/async2.js create mode 100644 packages/core/integration-tests/test/integration/js-runtime-dedup/index.js create mode 100644 packages/core/integration-tests/test/integration/js-runtime-dedup/shared.js create mode 100644 packages/core/integration-tests/test/integration/mdx/package.json create mode 100644 packages/core/integration-tests/test/integration/multi-asset-transformer/.babelrc create mode 100644 packages/core/integration-tests/test/integration/multi-asset-transformer/.parcelrc create mode 100644 packages/core/integration-tests/test/integration/multi-asset-transformer/index.js create mode 100644 packages/core/integration-tests/test/integration/multi-asset-transformer/node_modules/parcel-transformer-test/index.js create mode 100644 packages/core/integration-tests/test/integration/multi-asset-transformer/node_modules/parcel-transformer-test/package.json create mode 100644 packages/core/integration-tests/test/integration/multi-asset-transformer/yarn.lock create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/export-non-object/index.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/export-non-object/other.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/interop-require-commonjs-wrapped/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/interop-require-commonjs-wrapped/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/module-exports-default-assignment/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/module-exports-default-assignment/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/module-exports-default-assignment/index.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/mutated-non-static-require/index.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/mutated-non-static-require/other.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-local-assign/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-local-assign/basic.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-local-assign/destructure.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-local-assign/in-function.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-local-assign/member.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-new/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-new/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-non-const-export/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-non-const-export/destructure.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-non-const-export/live.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/require-non-const-export/member.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/tree-shaking-string/.terserrc create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/tree-shaking/.terserrc create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-default-interop/async.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-default-interop/index.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-default-interop/run-cjs.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-default-interop/run-interop.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-default-interop/shared.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-expressions/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-expressions/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-expressions/require.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-typeof-require/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-typeof-require/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/commonjs/wrap-typeof-require/c.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/circular-wrap/a.mjs create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/circular-wrap/b.mjs create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/circular-wrap/c.mjs create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/circular-wrap/d.mjs create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/circular-wrap/index.mjs create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/double-esmodule/foo.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/double-esmodule/index.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/export-default-live/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/export-default-live/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/import-local-assign/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/import-local-assign/default.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/import-local-assign/destructure-assign.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/import-local-assign/multiple.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/import-local-assign/named.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/import-local-assign/namespace.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-duplication/async1.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-duplication/async2.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-duplication/index.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-duplication/package.json create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-duplication/v.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-order/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-order/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-order/index.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-order/run1.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-order/run2.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-order/shared1.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/shared-bundle-side-effect-order/shared2.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/tree-shaking-cross-bundle-re-export/.terserrc create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/tree-shaking-cross-bundle/.terserrc create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/tree-shaking-dynamic-import/.terserrc create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/tree-shaking/.terserrc create mode 100644 packages/core/integration-tests/test/integration/svg/package.json create mode 100644 packages/core/integration-tests/test/transpilation.js create mode 100644 packages/packagers/js/src/CJSOutputFormat.js create mode 100644 packages/packagers/js/src/DevPackager.js create mode 100644 packages/packagers/js/src/ESMOutputFormat.js create mode 100644 packages/packagers/js/src/GlobalOutputFormat.js delete mode 100644 packages/packagers/js/src/JSPackager.js create mode 100644 packages/packagers/js/src/ScopeHoistingPackager.js rename packages/packagers/js/src/{prelude.js => dev-prelude.js} (99%) create mode 100644 packages/packagers/js/src/helpers.js create mode 100644 packages/packagers/js/src/index.js delete mode 100644 packages/shared/scope-hoisting/.eslintrc.json delete mode 100644 packages/shared/scope-hoisting/package.json delete mode 100644 packages/shared/scope-hoisting/src/concat.js delete mode 100644 packages/shared/scope-hoisting/src/formats/commonjs.js delete mode 100644 packages/shared/scope-hoisting/src/formats/esmodule.js delete mode 100644 packages/shared/scope-hoisting/src/formats/global.js delete mode 100644 packages/shared/scope-hoisting/src/formats/index.js delete mode 100644 packages/shared/scope-hoisting/src/generate.js delete mode 100644 packages/shared/scope-hoisting/src/helpers.js delete mode 100644 packages/shared/scope-hoisting/src/hoist.js delete mode 100644 packages/shared/scope-hoisting/src/index.js delete mode 100644 packages/shared/scope-hoisting/src/link.js delete mode 100644 packages/shared/scope-hoisting/src/prelude.js delete mode 100644 packages/shared/scope-hoisting/src/renamer.js delete mode 100644 packages/shared/scope-hoisting/src/types.js delete mode 100644 packages/shared/scope-hoisting/src/utils.js create mode 100644 packages/transformers/js/.gitignore create mode 100644 packages/transformers/js/Cargo.toml rename {native-packages/fs-search => packages/transformers/js}/build.rs (100%) create mode 100644 packages/transformers/js/hoist.md create mode 100644 packages/transformers/js/src/decl_collector.rs create mode 100644 packages/transformers/js/src/dependency_collector.rs create mode 100644 packages/transformers/js/src/env_replacer.rs create mode 100644 packages/transformers/js/src/fs.rs create mode 100644 packages/transformers/js/src/global_replacer.rs create mode 100644 packages/transformers/js/src/hoist.rs create mode 100644 packages/transformers/js/src/lib.rs create mode 100644 packages/transformers/js/src/modules.rs create mode 100644 packages/transformers/js/src/native.js create mode 100644 packages/transformers/js/src/utils.rs delete mode 100644 packages/transformers/js/src/visitors/dependencies.js delete mode 100644 packages/transformers/js/src/visitors/fs.js delete mode 100644 packages/transformers/js/src/visitors/globals.js delete mode 100644 packages/transformers/js/src/visitors/modules.js delete mode 100644 packages/transformers/js/src/visitors/process.js delete mode 100644 packages/transformers/js/src/visitors/utils.js delete mode 100644 packages/transformers/react-refresh-babel/package.json delete mode 100644 packages/transformers/react-refresh-babel/src/ReactRefreshBabelTransformer.js rename {native-packages => packages/utils}/fs-search/.gitignore (100%) rename {native-packages => packages/utils}/fs-search/Cargo.toml (100%) create mode 100644 packages/utils/fs-search/build.rs rename {native-packages => packages/utils}/fs-search/index.js (53%) rename {native-packages => packages/utils}/fs-search/package.json (84%) rename {native-packages => packages/utils}/fs-search/src/lib.rs (94%) delete mode 100644 scripts/link-native.js diff --git a/native-packages/fs-search/.cargo/config.toml b/.cargo/config.toml similarity index 100% rename from native-packages/fs-search/.cargo/config.toml rename to .cargo/config.toml diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 74254a2d0..292bf9598 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -19,17 +19,17 @@ jobs: toolchain: stable profile: minimal override: true - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 if: ${{ matrix.os == 'macos-latest' }} - run: strip -x native-packages/*/*.node # Must use -x on macOS. This produces larger results on linux. + run: strip -x packages/*/*/*.node # Must use -x on macOS. This produces larger results on linux. - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-${{ matrix.os }} - path: native-packages/*/*.node + path: packages/*/*/*.node - name: Smoke test run: node -e "require('@parcel/fs-search')" @@ -48,18 +48,18 @@ jobs: toolchain: stable profile: minimal override: true - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - run: strip native-packages/*/*.node + run: strip packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-linux-gnu-x64 - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node - name: Smoke test run: node -e 'require("@parcel/fs-search")' @@ -89,20 +89,20 @@ jobs: run: | sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - run: ${{ matrix.strip }} native-packages/*/*.node + run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-${{ matrix.target }} - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node - name: Configure binfmt-support run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - name: Smoke test @@ -143,20 +143,20 @@ jobs: curl -O https://musl.cc/aarch64-linux-musl-cross.tgz tar xzf aarch64-linux-musl-cross.tgz cp -R aarch64-linux-musl-cross/* /usr - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - run: ${{ matrix.strip }} native-packages/*/*.node + run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-linux-musl - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node - name: Smoke test if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} run: node -e 'require("@parcel/fs-search")' @@ -173,20 +173,20 @@ jobs: profile: minimal override: true target: aarch64-apple-darwin - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release env: RUST_TARGET: aarch64-apple-darwin - name: Strip debug symbols - run: strip -x native-packages/*/*.node + run: strip -x packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-apple-aarch64 - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node build-and-release: runs-on: ubuntu-latest @@ -198,17 +198,17 @@ jobs: - build-apple-silicon steps: - uses: actions/checkout@v1 - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release - name: Download artifacts uses: actions/download-artifact@v2 with: path: artifacts - name: Move artifacts - run: for d in artifacts/*/*; do cp $d/*.node native-packages/$(basename $d); done + run: for d in artifacts/*/*/*; do cp $d/*.node packages/$(basename $(dirname $d))/$(basename $d); done - name: Debug - run: ls -l native-packages/*/* + run: ls -l packages/*/*/*.node - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index aa60cfe1a..dfdc60a1f 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -18,17 +18,17 @@ jobs: toolchain: stable profile: minimal override: true - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 if: ${{ matrix.os == 'macos-latest' }} - run: strip -x native-packages/*/*.node # Must use -x on macOS. This produces larger results on linux. + run: strip -x packages/*/*/*.node # Must use -x on macOS. This produces larger results on linux. - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-${{ matrix.os }} - path: native-packages/*/*.node + path: packages/*/*/*.node - name: Smoke test run: node -e "require('@parcel/fs-search')" @@ -47,18 +47,18 @@ jobs: toolchain: stable profile: minimal override: true - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - run: strip native-packages/*/*.node + run: strip packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-linux-gnu-x64 - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node - name: Smoke test run: node -e 'require("@parcel/fs-search")' @@ -88,20 +88,20 @@ jobs: run: | sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - run: ${{ matrix.strip }} native-packages/*/*.node + run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-${{ matrix.target }} - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node - name: Configure binfmt-support run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - name: Smoke test @@ -142,20 +142,20 @@ jobs: curl -O https://musl.cc/aarch64-linux-musl-cross.tgz tar xzf aarch64-linux-musl-cross.tgz cp -R aarch64-linux-musl-cross/* /usr - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release env: RUST_TARGET: ${{ matrix.target }} - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 - run: ${{ matrix.strip }} native-packages/*/*.node + run: ${{ matrix.strip }} packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-linux-musl - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node - name: Smoke test if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} run: node -e 'require("@parcel/fs-search")' @@ -172,20 +172,20 @@ jobs: profile: minimal override: true target: aarch64-apple-darwin - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release env: RUST_TARGET: aarch64-apple-darwin - name: Strip debug symbols - run: strip -x native-packages/*/*.node + run: strip -x packages/*/*/*.node - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: bindings-apple-aarch64 - path: native-packages/*/*.node + path: packages/*/*/*.node - name: debug - run: ls -l native-packages/*/*.node + run: ls -l packages/*/*/*.node build-and-release: runs-on: ubuntu-latest @@ -197,17 +197,17 @@ jobs: - build-apple-silicon steps: - uses: actions/checkout@v1 - - name: Link native packages - run: node scripts/link-native.js - uses: bahmutov/npm-install@v1.1.0 + - name: Build native packages + run: yarn build-native-release - name: Download artifacts uses: actions/download-artifact@v2 with: path: artifacts - name: Move artifacts - run: for d in artifacts/*/*; do cp $d/*.node native-packages/$(basename $d); done + run: for d in artifacts/*/*/*; do cp $d/*.node packages/$(basename $(dirname $d))/$(basename $d); done - name: Debug - run: ls -l native-packages/*/* + run: ls -l packages/*/*/*.node - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 78b1dd1ed..90b5550a1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,3 @@ tmp parcel-bundle-reports/ .verdaccio_storage/ sourcemap-info.json -packages/native-packages diff --git a/.prettierrc b/.prettierrc index 92d4379a7..6fbb6f968 100644 --- a/.prettierrc +++ b/.prettierrc @@ -7,6 +7,7 @@ { "files": [ "packages/packagers/js/src/prelude.js", + "packages/packagers/swc/src/dev-prelude.js", "packages/shared/scope-hoisting/src/helpers.js" ], "options": { diff --git a/Cargo.lock b/Cargo.lock index e9529853c..62d2a095f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,224 +1,1402 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "ast_node" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93f52ce8fac3d0e6720a92b0576d737c01b1b5db4dd786e962e5925f00bf755" +dependencies = [ + "darling", + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chunked_transfer" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" + +[[package]] +name = "cpufeatures" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec1028182c380cc45a2e2c5ec841134f2dfd0f8f5f0a5bcd68004f81b5efdf4" +dependencies = [ + "libc", +] + +[[package]] +name = "darling" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "dashmap" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" +dependencies = [ + "cfg-if 1.0.0", + "num_cpus", +] + +[[package]] +name = "data-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "dunce" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2641c4a7c0c4101df53ea572bffdc561c146f6c2eb09e4df02bc4811e3feeb4" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "enum_kind" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b940da354ae81ef0926c5eaa428207b8f4f091d3956c891dfbd124162bed99" +dependencies = [ + "pmutil", + "proc-macro2", + "swc_macros_common", + "syn", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "from_variant" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0951635027ca477be98f8774abd6f0345233439d63f307e47101acb40c7cc63d" +dependencies = [ + "pmutil", + "proc-macro2", + "swc_macros_common", + "syn", +] + +[[package]] +name = "fs_extra" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "if_chain" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f7280c75fb2e2fc47080ec80ccc481376923acb04501957fc38f935c3de5088" + +[[package]] +name = "indexmap" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "indoc" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a75aeaaef0ce18b58056d306c27b07436fbb34b8816c53094b76dd81803136" +dependencies = [ + "unindent", +] + +[[package]] +name = "is-macro" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a322dd16d960e322c3d92f541b4c1a4f0a2e81e1fdeee430d8cecc8b72e8015f" +dependencies = [ + "Inflector", + "pmutil", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "jemalloc-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" +dependencies = [ + "cc", + "fs_extra", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" +dependencies = [ + "jemalloc-sys", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" + +[[package]] +name = "libmimalloc-sys" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2396cf99d2f58611cd69f0efeee4af3d2e2c7b61bed433515029163aa567e65c" +dependencies = [ + "cc", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "mimalloc" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7c6b11afd1e5e689ac96b6d18b1fc763398fe3d7eed99e8773426bc2033dfb" +dependencies = [ + "libmimalloc-sys", +] + +[[package]] +name = "napi" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ed03b524c2131d292902f683334c42f12724c9c3770d8b6340f6abbe6a3975b" +dependencies = [ + "napi-build", + "napi-sys", + "serde", + "serde_json", + "winapi", +] + +[[package]] +name = "napi-build" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3039ed15066300360660239cab9a6071a0ed899547c49e40952d87ded49b29b8" +dependencies = [ + "cfg-if 1.0.0", + "ureq", +] + +[[package]] +name = "napi-derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e7ed160148f94ee17936f00288029cb0cfb37c08bbace9f514f735dcd869ed7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "napi-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "192c38c1012409fbf1d9868e29375fc3e1444cf1e222ba407c7bca6a2187fbfa" + +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "ordered-float" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b50b8919aecb97e5ee9aceef27e24f39c46b11831130f4a6b7b091ec5de0de12" +dependencies = [ + "num-traits", +] + +[[package]] +name = "owning_ref" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "parcel-fs-search" +version = "0.1.0" +dependencies = [ + "napi", + "napi-build", + "napi-derive", +] + +[[package]] +name = "parcel-js-swc" +version = "0.1.0" +dependencies = [ + "Inflector", + "data-encoding", + "dunce", + "indoc", + "jemallocator", + "mimalloc", + "napi", + "napi-build", + "napi-derive", + "serde", + "sha-1", + "swc_atoms", + "swc_common", + "swc_ecma_preset_env", + "swc_ecmascript", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "phf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_macros", + "phf_shared", + "proc-macro-hack", +] + +[[package]] +name = "phf_generator" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pmutil" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3894e5d549cccbe44afecf72922f277f603cd4bb0219c8342631ef18fffbe004" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "retain_mut" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c17925a9027d298a4603d286befe3f9dc0e8ed02523141914eb628798d6e5b" + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64 0.13.0", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] -name = "base64" -version = "0.13.0" +name = "serde" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +dependencies = [ + "serde_derive", +] [[package]] -name = "bumpalo" -version = "3.6.1" +name = "serde_derive" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] -name = "cc" -version = "1.0.67" +name = "serde_json" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +dependencies = [ + "itoa", + "ryu", + "serde", +] [[package]] -name = "cfg-if" -version = "1.0.0" +name = "sha-1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "b659df5fc3ce22274daac600ffb845300bd2125bcfaec047823075afdab81c00" +dependencies = [ + "block-buffer", + "cfg-if 1.0.0", + "cpufeatures", + "digest", + "opaque-debug", +] [[package]] -name = "chunked_transfer" -version = "1.4.0" +name = "siphasher" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" +checksum = "cbce6d4507c7e4a3962091436e56e95290cb71fa302d0d270e32130b75fbff27" [[package]] -name = "form_urlencoded" -version = "1.0.1" +name = "smallvec" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "sourcemap" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e031f2463ecbdd5f34c950f89f5c1e1032f22c0f8e3dc4bdb2e8b6658cf61eb" dependencies = [ - "matches", - "percent-encoding", + "base64 0.11.0", + "if_chain", + "lazy_static", + "regex", + "rustc_version", + "serde", + "serde_json", + "url", ] [[package]] -name = "idna" -version = "0.2.3" +name = "spin" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "st-map" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3caeb13a58f859600a7b75fffe66322e1fca0122ca02cfc7262344a7e30502d1" dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", + "arrayvec", + "static-map-macro", ] [[package]] -name = "js-sys" -version = "0.3.50" +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static-map-macro" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" +checksum = "d5503e07f148238811bbfd578684a0457c7284bab41b60d76def35431a1295fd" dependencies = [ - "wasm-bindgen", + "pmutil", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "lazy_static" -version = "1.4.0" +name = "string_cache" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" +dependencies = [ + "lazy_static", + "new_debug_unreachable", + "phf_shared", + "precomputed-hash", + "serde", +] [[package]] -name = "libc" -version = "0.2.94" +name = "string_cache_codegen" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" +checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", +] [[package]] -name = "log" -version = "0.4.14" +name = "string_enum" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "f584cc881e9e5f1fd6bf827b0444aa94c30d8fe6378cf241071b5f5700b2871f" dependencies = [ - "cfg-if", + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn", ] [[package]] -name = "matches" -version = "0.1.8" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] -name = "napi" -version = "1.6.0" +name = "swc_atoms" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f06c3175294af4a9d4217c370250f5acea6c06b3d162b7a2f7c8e5a00393b684" +checksum = "7bcdb70cb6ecee568e5acfda1a8c6e851ecf49443e5fb51f1b13613b5d04d2b0" dependencies = [ - "napi-build", - "napi-sys", - "winapi", + "string_cache", + "string_cache_codegen", ] [[package]] -name = "napi-build" -version = "1.0.2" +name = "swc_common" +version = "0.10.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3039ed15066300360660239cab9a6071a0ed899547c49e40952d87ded49b29b8" +checksum = "99ca8ee04fe88cca78cd9724a4fe44b438b47754f62f5919760755ba306da336" dependencies = [ - "cfg-if", - "ureq", + "ast_node", + "atty", + "cfg-if 0.1.10", + "either", + "from_variant", + "fxhash", + "log", + "num-bigint", + "once_cell", + "owning_ref", + "scoped-tls", + "serde", + "sourcemap", + "string_cache", + "swc_eq_ignore_macros", + "swc_visit", + "termcolor", + "unicode-width", ] [[package]] -name = "napi-derive" -version = "1.1.0" +name = "swc_ecma_ast" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7ed160148f94ee17936f00288029cb0cfb37c08bbace9f514f735dcd869ed7" +checksum = "8418b0b8a387a1ea919e5bc21d79897c0b24832cae9fd4974d9e2ae8a58df81e" +dependencies = [ + "is-macro", + "num-bigint", + "serde", + "string_enum", + "swc_atoms", + "swc_common", +] + +[[package]] +name = "swc_ecma_codegen" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f62df17607eee6c488fdd24d192911db862b2af68a6ea72e166bb699f8a417a" +dependencies = [ + "bitflags", + "num-bigint", + "sourcemap", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_codegen_macros", + "swc_ecma_parser", +] + +[[package]] +name = "swc_ecma_codegen_macros" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51af418026cb4ea588e2b15fa206c44e09a3184b718e12a0919729c7c3ad20d3" dependencies = [ + "pmutil", "proc-macro2", "quote", + "swc_macros_common", "syn", ] [[package]] -name = "napi-sys" -version = "1.1.0" +name = "swc_ecma_parser" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "192c38c1012409fbf1d9868e29375fc3e1444cf1e222ba407c7bca6a2187fbfa" +checksum = "fd24742a8ab30029226dfdf7116bba00a39b9a04da36b762edc999d239a03c7e" +dependencies = [ + "either", + "enum_kind", + "fxhash", + "log", + "num-bigint", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_visit", + "unicode-xid", +] [[package]] -name = "once_cell" -version = "1.7.2" +name = "swc_ecma_preset_env" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +checksum = "53907bd28a020425b4036be439555bb21ceb505f53e4d1b1b7157d16729fffe2" +dependencies = [ + "dashmap", + "fxhash", + "indexmap", + "once_cell", + "semver", + "serde", + "serde_json", + "st-map", + "string_enum", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms", + "swc_ecma_utils", + "swc_ecma_visit", + "walkdir", +] [[package]] -name = "parcel-fs-search" -version = "0.1.0" +name = "swc_ecma_transforms" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3494813dd593a7b354d33ddfcae468efb5f4e80bdde0c906e26e7d93121dc932" dependencies = [ - "napi", - "napi-build", - "napi-derive", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_compat", + "swc_ecma_transforms_module", + "swc_ecma_transforms_optimization", + "swc_ecma_transforms_proposal", + "swc_ecma_transforms_react", + "swc_ecma_transforms_typescript", + "swc_ecma_utils", + "swc_ecma_visit", + "unicode-xid", ] [[package]] -name = "percent-encoding" -version = "2.1.0" +name = "swc_ecma_transforms_base" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "4f63bd141c5652c699c6a805331ded67d08c8bd9d147cd162e35a6372823e9d8" +dependencies = [ + "fxhash", + "once_cell", + "phf", + "scoped-tls", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_utils", + "swc_ecma_visit", +] [[package]] -name = "proc-macro2" -version = "1.0.26" +name = "swc_ecma_transforms_compat" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "95c28c1d3acd44cf81f36014509ea03b23872ee5f5ac7e2138c2eb876775b035" dependencies = [ - "unicode-xid", + "arrayvec", + "fxhash", + "indexmap", + "is-macro", + "num-bigint", + "ordered-float", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] -name = "quote" -version = "1.0.9" +name = "swc_ecma_transforms_macros" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "f7680ada61fa22c2164c3f32864efba31566710b503c30631ccc3b6f0fa800bc" dependencies = [ + "pmutil", "proc-macro2", + "quote", + "swc_macros_common", + "syn", ] [[package]] -name = "ring" -version = "0.16.20" +name = "swc_ecma_transforms_module" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "4daa8fe579e60b0d395fe484788dbe0d965a1964cbb6ca5724507dd81dde05f0" dependencies = [ - "cc", - "libc", - "once_cell", - "spin", - "untrusted", - "web-sys", - "winapi", + "Inflector", + "fxhash", + "indexmap", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] -name = "rustls" -version = "0.19.1" +name = "swc_ecma_transforms_optimization" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "8574e9c20238a027546f7ec2f74644e52a61125acd7e7182d29fde905bf0ca41" dependencies = [ - "base64", + "dashmap", + "fxhash", + "indexmap", "log", - "ring", - "sct", - "webpki", + "once_cell", + "retain_mut", + "serde_json", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] -name = "sct" -version = "0.6.1" +name = "swc_ecma_transforms_proposal" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +checksum = "299f631d0910207dea416d366bafe047c49c961de78948a4765e2c60226bc9bd" dependencies = [ - "ring", - "untrusted", + "either", + "fxhash", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] -name = "spin" -version = "0.5.2" +name = "swc_ecma_transforms_react" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "27a76789fa8936f09d223c371576da408c38e7916e3825efe36932802b4739ed" +dependencies = [ + "base64 0.13.0", + "dashmap", + "indexmap", + "once_cell", + "regex", + "serde", + "sha-1", + "string_enum", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_typescript" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c46e69c7e1b21ee12b33158ac2ed6b449d65a866d58c64a752aa33cb22a57cab" +dependencies = [ + "fxhash", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_utils" +version = "0.34.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476b09bb911caf1485a314e50758503a7d7a807d8db467022b59bdd81014a26c" +dependencies = [ + "once_cell", + "scoped-tls", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_visit", + "unicode-xid", +] + +[[package]] +name = "swc_ecma_visit" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81e54a3b94a33507346193c1f56d8251b3d9bc1381214174f982e6f091716dfe" +dependencies = [ + "num-bigint", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_visit", +] + +[[package]] +name = "swc_ecmascript" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad428a7b5e0c493521bc18b9b4d943f42aa13f386b15e3c9535eeb65412d8b2" +dependencies = [ + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_parser", + "swc_ecma_transforms", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c8f200a2eaed938e7c1a685faaa66e6d42fa9e17da5f62572d3cbc335898f5e" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_macros_common" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08ed2e930f5a1a4071fe62c90fd3a296f6030e5d94bfe13993244423caf59a78" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_visit" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583cfe83f6002e1118559308b88181f34b5936b403b72548cd0259bfcf0ca39e" +dependencies = [ + "either", + "swc_visit_macros", +] + +[[package]] +name = "swc_visit_macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b2825fee79f10d0166e8e650e79c7a862fb991db275743083f07555d7641f0" +dependencies = [ + "Inflector", + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] [[package]] name = "syn" -version = "1.0.71" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373" +checksum = "f3a1d708c221c5a612956ef9f75b37e454e88d1f7b899fbd3a18d4252012d663" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + [[package]] name = "tinyvec" version = "1.2.0" @@ -234,6 +1412,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + [[package]] name = "unicode-bidi" version = "0.3.5" @@ -252,11 +1436,23 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "unindent" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" [[package]] name = "untrusted" @@ -270,7 +1466,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2475a6781e9bc546e7b64f4013d2f4032c8c6a40fcffd7c6f4ee734a890972ab" dependencies = [ - "base64", + "base64 0.13.0", "chunked_transfer", "log", "once_cell", @@ -282,9 +1478,9 @@ dependencies = [ [[package]] name = "url" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ "form_urlencoded", "idna", @@ -292,21 +1488,44 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasm-bindgen" -version = "0.2.73" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.73" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" dependencies = [ "bumpalo", "lazy_static", @@ -319,9 +1538,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.73" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -329,9 +1548,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.73" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" dependencies = [ "proc-macro2", "quote", @@ -342,15 +1561,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.73" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" +checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" [[package]] name = "web-sys" -version = "0.3.50" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +checksum = "59fe19d70f5dacc03f6e46777213facae5ac3801575d56ca6cbd4c93dcd12310" dependencies = [ "js-sys", "wasm-bindgen", @@ -391,6 +1610,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 25f38b05b..c5e3cedef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] -members = ["native-packages/fs-search"] +members = ["packages/transformers/js", "packages/utils/fs-search"] [profile.release] -lto = true opt-level = 3 +# lto = true diff --git a/azure-pipelines-template.yml b/azure-pipelines-template.yml index b4060dd3f..56d9b2116 100644 --- a/azure-pipelines-template.yml +++ b/azure-pipelines-template.yml @@ -67,12 +67,12 @@ jobs: yarn path: $(YARN_CACHE_FOLDER) displayName: Cache yarn directory - - script: node scripts/link-native.js - displayName: 'Link native dependencies' # use `--frozen-lockfile` to fail immediately if the committed yarn.lock needs updates # https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-frozen-lockfile - script: yarn --frozen-lockfile displayName: 'Install dependencies' + - script: yarn build-native-release + displayName: 'Build native packages' - script: yarn test:unit displayName: 'Run unit tests' - script: yarn test:integration-ci diff --git a/gulpfile.js b/gulpfile.js index 754bab002..937505ffe 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -21,12 +21,14 @@ const paths = { '!packages/*/scope-hoisting/src/helpers.js', '!**/loaders/**', '!**/prelude.js', + '!**/dev-prelude.js', ...IGNORED_PACKAGES, ], packageOther: [ 'packages/*/scope-hoisting/src/helpers.js', 'packages/*/*/src/**/loaders/**', 'packages/*/*/src/**/prelude.js', + 'packages/*/*/src/**/dev-prelude.js', 'packages/*/dev-server/src/templates/**', ], packageJson: [ diff --git a/lerna.json b/lerna.json index 99ebfd3f7..a956024df 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { - "packages": ["packages/*/*", "native-packages/*"], + "packages": ["packages/*/*"], "version": "independent" } diff --git a/package.json b/package.json index 16a303e91..e92dd5c34 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,13 @@ ], "scripts": { "build": "cross-env NODE_ENV=production PARCEL_BUILD_ENV=production gulp", + "build-native": "node scripts/build-native.js", + "build-native-release": "node scripts/build-native.js --release", "clean-test": "rimraf packages/core/integration-tests/.parcel-cache && rimraf packages/core/integration-tests/dist", "clean": "yarn clean-test && lerna clean --yes && lerna exec -- rimraf ./lib && yarn", "format": "prettier --write \"./packages/*/*/{src,bin,test}/**/*.{js,json,md}\" && cargo fmt --all", "link-all": "node scripts/link-all.js packages", "unlink-all": "node scripts/unlink-all.js packages", - "link-native": "node scripts/link-native.js && yarn", - "unlink-native": "rimraf packages/native-packages", - "postinstall": "node scripts/postinstall.js", "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", @@ -42,6 +41,7 @@ "doctoc": "^1.4.0", "eslint": "^7.20.0", "flow-bin": "0.150.0", + "glob": "^7.1.6", "gulp": "^4.0.2", "gulp-babel": "^8.0.0", "husky": "^6.0.0", diff --git a/packages/configs/default/index.json b/packages/configs/default/index.json index 73e6e0fbe..a1489e970 100644 --- a/packages/configs/default/index.json +++ b/packages/configs/default/index.json @@ -5,7 +5,6 @@ "bundle-text:*": ["@parcel/transformer-inline-string", "..."], "data-url:*": ["@parcel/transformer-inline-string", "..."], "*.{js,mjs,jsm,jsx,es6,cjs,ts,tsx}": [ - "@parcel/transformer-react-refresh-babel", "@parcel/transformer-babel", "@parcel/transformer-js", "@parcel/transformer-react-refresh-wrap" diff --git a/packages/configs/default/package.json b/packages/configs/default/package.json index 080b97096..bc741444a 100644 --- a/packages/configs/default/package.json +++ b/packages/configs/default/package.json @@ -25,8 +25,8 @@ "@parcel/optimizer-terser": "2.0.0-beta.2", "@parcel/packager-css": "2.0.0-beta.2", "@parcel/packager-html": "2.0.0-beta.2", - "@parcel/packager-js": "2.0.0-beta.2", "@parcel/packager-raw": "2.0.0-beta.2", + "@parcel/packager-js": "2.0.0-beta.2", "@parcel/reporter-dev-server": "2.0.0-beta.2", "@parcel/resolver-default": "2.0.0-beta.2", "@parcel/runtime-browser-hmr": "2.0.0-beta.2", @@ -40,7 +40,6 @@ "@parcel/transformer-postcss": "2.0.0-beta.2", "@parcel/transformer-posthtml": "2.0.0-beta.2", "@parcel/transformer-raw": "2.0.0-beta.2", - "@parcel/transformer-react-refresh-babel": "2.0.0-beta.2", "@parcel/transformer-react-refresh-wrap": "2.0.0-beta.2" }, "parcelDependencies": { diff --git a/packages/core/core/src/Transformation.js b/packages/core/core/src/Transformation.js index 5699c561f..e69b56abc 100644 --- a/packages/core/core/src/Transformation.js +++ b/packages/core/core/src/Transformation.js @@ -208,7 +208,9 @@ export default class Transformation { } } + // $FlowFixMe return { + $$raw: true, assets, configRequests, invalidateOnFileCreate: this.invalidateOnFileCreate, @@ -467,6 +469,10 @@ export default class Transformation { ); for (let result of transformerResults) { + if (result instanceof UncommittedAsset) { + resultingAssets.push(result); + continue; + } resultingAssets.push( asset.createChildAsset( result, @@ -488,36 +494,30 @@ export default class Transformation { inputAssets = resultingAssets; } - // Make assets with ASTs generate unless they are js assets and target uses - // scope hoisting or we do CSS modules tree shaking. This parallelizes generation + // Make assets with ASTs generate unless they are CSS modules. This parallelizes generation // and distributes work more evenly across workers than if one worker needed to // generate all assets in a large bundle during packaging. - let generate = pipeline.generate; - if (generate != null) { - await Promise.all( - resultingAssets - .filter( - asset => - asset.ast != null && - !( - (asset.value.env.shouldScopeHoist && - asset.value.type === 'js') || - (this.options.mode === 'production' && - asset.value.type === 'css' && - asset.value.symbols) - ), - ) - .map(async asset => { - if (asset.isASTDirty) { - let output = await generate(asset); - asset.content = output.content; - asset.mapBuffer = output.map?.toBuffer(); - } + await Promise.all( + resultingAssets + .filter( + asset => + asset.ast != null && + !( + this.options.mode === 'production' && + asset.value.type === 'css' && + asset.value.symbols + ), + ) + .map(async asset => { + if (asset.isASTDirty && asset.generate) { + let output = await asset.generate(); + asset.content = output.content; + asset.mapBuffer = output.map?.toBuffer(); + } - asset.clearAST(); - }), - ); - } + asset.clearAST(); + }), + ); return finalAssets.concat(resultingAssets); } @@ -758,9 +758,9 @@ export default class Transformation { options: pipeline.pluginOptions, logger, })) && - pipeline.generate + asset.generate ) { - let output = await pipeline.generate(asset); + let output = await asset.generate(); asset.content = output.content; asset.mapBuffer = output.map?.toBuffer(); } @@ -798,17 +798,16 @@ export default class Transformation { ); // Create generate function that can be called later - pipeline.generate = (input: UncommittedAsset): Promise => { - let ast = input.ast; - let asset = new Asset(input); - if (transformer.generate && ast) { + asset.generate = (): Promise => { + let publicAsset = new Asset(asset); + if (transformer.generate && asset.ast) { let generated = transformer.generate({ - asset, - ast, + asset: publicAsset, + ast: asset.ast, options: pipeline.pluginOptions, logger, }); - input.clearAST(); + asset.clearAST(); return Promise.resolve(generated); } @@ -839,35 +838,14 @@ type TransformerWithNameAndConfig = {| resolveFrom: FilePath, |}; -function normalizeAssets( - results: Array, -): Promise> { +function normalizeAssets(results: Array) { return Promise.all( - results.map>(async result => { - if (!(result instanceof MutableAsset)) { - return result; + results.map(result => { + if (result instanceof MutableAsset) { + return mutableAssetToUncommittedAsset(result); } - let internalAsset = mutableAssetToUncommittedAsset(result); - // $FlowFixMe - ignore id already on env - return { - ast: internalAsset.ast, - content: await internalAsset.content, - query: internalAsset.value.query, - // $FlowFixMe - dependencies: [...internalAsset.value.dependencies.values()], - env: internalAsset.value.env, - filePath: result.filePath, - isInline: result.isInline, - isIsolated: result.isIsolated, - map: await internalAsset.getMap(), - meta: result.meta, - pipeline: internalAsset.value.pipeline, - // $FlowFixMe - symbols: internalAsset.value.symbols, - type: result.type, - uniqueKey: internalAsset.value.uniqueKey, - }; + return result; }), ); } diff --git a/packages/core/core/src/UncommittedAsset.js b/packages/core/core/src/UncommittedAsset.js index 77e058039..0f6e3185a 100644 --- a/packages/core/core/src/UncommittedAsset.js +++ b/packages/core/core/src/UncommittedAsset.js @@ -7,6 +7,7 @@ import type { DependencyOptions, FilePath, FileCreateInvalidation, + GenerateOutput, PackageJSON, PackageName, TransformerResult, @@ -36,6 +37,7 @@ import {mergeEnvironments} from './Environment'; import {PARCEL_VERSION} from './constants'; import { createAsset, + createAssetIdFromOptions, getConfig, getInvalidationId, getInvalidationHash, @@ -64,6 +66,7 @@ export default class UncommittedAsset { idBase: ?string; invalidations: Map; fileCreateInvalidations: Array; + generate: ?() => Promise; constructor({ value, @@ -269,6 +272,7 @@ export default class UncommittedAsset { } setMap(map: ?SourceMap): void { + this.map = map; this.mapBuffer = map?.toBuffer(); } @@ -435,4 +439,9 @@ export default class UncommittedAsset { getPackage(): Promise { return this.getConfig(['package.json']); } + + updateId() { + // $FlowFixMe - this is fine + this.value.id = createAssetIdFromOptions(this.value); + } } diff --git a/packages/core/core/src/Validation.js b/packages/core/core/src/Validation.js index 006941e8d..61bbe3139 100644 --- a/packages/core/core/src/Validation.js +++ b/packages/core/core/src/Validation.js @@ -81,6 +81,7 @@ export default class Validation { this.options.inputFS, assetFilePath, configNames, + this.options.projectRoot, ), }); } @@ -101,6 +102,7 @@ export default class Validation { this.options.inputFS, input.value.filePath, configNames, + this.options.projectRoot, ), }); } diff --git a/packages/core/core/src/assetUtils.js b/packages/core/core/src/assetUtils.js index 7d346b72f..38e2aa11c 100644 --- a/packages/core/core/src/assetUtils.js +++ b/packages/core/core/src/assetUtils.js @@ -70,7 +70,7 @@ type AssetOptions = {| configKeyPath?: string, |}; -function createAssetIdFromOptions(options: AssetOptions): string { +export function createAssetIdFromOptions(options: AssetOptions): string { let uniqueKey = options.uniqueKey ?? ''; let idBase = options.idBase != null ? options.idBase : options.filePath; let queryString = options.query ? objectSortedEntries(options.query) : ''; @@ -200,6 +200,7 @@ export async function getConfig( asset.options.inputFS, asset.value.filePath, filePaths, + asset.options.projectRoot, parse == null ? null : {parse}, ); if (!conf) { @@ -243,13 +244,10 @@ export async function getInvalidationHash( // Only recompute the hash of this file if we haven't seen it already during this build. let fileHash = hashCache.get(invalidation.filePath); if (fileHash == null) { - fileHash = await md5FromFilePath( - options.inputFS, - invalidation.filePath, - ); + fileHash = md5FromFilePath(options.inputFS, invalidation.filePath); hashCache.set(invalidation.filePath, fileHash); } - hash.update(fileHash); + hash.update(await fileHash); break; } case 'env': diff --git a/packages/core/core/src/loadDotEnv.js b/packages/core/core/src/loadDotEnv.js index 725d33784..2bc1609e2 100644 --- a/packages/core/core/src/loadDotEnv.js +++ b/packages/core/core/src/loadDotEnv.js @@ -1,7 +1,7 @@ // @flow strict-local import type {FileSystem} from '@parcel/fs'; -import type {EnvMap} from '@parcel/types'; +import type {EnvMap, FilePath} from '@parcel/types'; import {resolveConfig} from '@parcel/utils'; import dotenv from 'dotenv'; @@ -10,7 +10,8 @@ import variableExpansion from 'dotenv-expand'; export default async function loadEnv( env: EnvMap, fs: FileSystem, - filePath: string, + filePath: FilePath, + projectRoot: FilePath, ): Promise { const NODE_ENV = env.NODE_ENV ?? 'development'; @@ -26,7 +27,12 @@ export default async function loadEnv( let envs = await Promise.all( dotenvFiles.map(async dotenvFile => { - const envPath = await resolveConfig(fs, filePath, [dotenvFile]); + const envPath = await resolveConfig( + fs, + filePath, + [dotenvFile], + projectRoot, + ); if (envPath == null) { return; } diff --git a/packages/core/core/src/loadParcelPlugin.js b/packages/core/core/src/loadParcelPlugin.js index 93f1004c8..0cb64a812 100644 --- a/packages/core/core/src/loadParcelPlugin.js +++ b/packages/core/core/src/loadParcelPlugin.js @@ -29,9 +29,12 @@ export default async function loadPlugin( let resolveFrom = configPath; let range; if (resolveFrom.includes(NODE_MODULES)) { - let configPkg = await loadConfig(options.inputFS, resolveFrom, [ - 'package.json', - ]); + let configPkg = await loadConfig( + options.inputFS, + resolveFrom, + ['package.json'], + options.projectRoot, + ); if ( configPkg != null && configPkg.config.dependencies?.[pluginName] == null @@ -139,7 +142,12 @@ export default async function loadPlugin( !semver.satisfies(PARCEL_VERSION, parcelVersionRange) ) { let pkgFile = nullthrows( - await resolveConfig(options.inputFS, resolved, ['package.json']), + await resolveConfig( + options.inputFS, + resolved, + ['package.json'], + options.projectRoot, + ), ); let pkgContents = await options.inputFS.readFile(pkgFile, 'utf8'); throw new ThrowableDiagnostic({ diff --git a/packages/core/core/src/public/Asset.js b/packages/core/core/src/public/Asset.js index 6bd4a85f3..ab242e159 100644 --- a/packages/core/core/src/public/Asset.js +++ b/packages/core/core/src/public/Asset.js @@ -240,7 +240,10 @@ export class MutableAsset extends BaseAsset implements IMutableAsset { } set type(type: string): void { - this.#asset.value.type = type; + if (type !== this.#asset.value.type) { + this.#asset.value.type = type; + this.#asset.updateId(); + } } get isIsolated(): boolean { @@ -318,5 +321,6 @@ export class MutableAsset extends BaseAsset implements IMutableAsset { setEnvironment(env: EnvironmentOptions): void { this.#asset.value.env = createEnvironment(env); + this.#asset.updateId(); } } diff --git a/packages/core/core/src/public/Config.js b/packages/core/core/src/public/Config.js index 2fd9680d4..73fcede37 100644 --- a/packages/core/core/src/public/Config.js +++ b/packages/core/core/src/public/Config.js @@ -118,6 +118,7 @@ export default class PublicConfig implements IConfig { this.#options.inputFS, searchPath, fileNames, + this.#options.projectRoot, parse == null ? null : {parse}, ); if (conf == null) { diff --git a/packages/core/core/src/requests/ParcelConfigRequest.js b/packages/core/core/src/requests/ParcelConfigRequest.js index 5264c37ed..1379c7e02 100644 --- a/packages/core/core/src/requests/ParcelConfigRequest.js +++ b/packages/core/core/src/requests/ParcelConfigRequest.js @@ -139,7 +139,12 @@ export async function resolveParcelConfig( options.config != null ? (await options.packageManager.resolve(options.config, resolveFrom)) .resolved - : await resolveConfig(options.inputFS, resolveFrom, ['.parcelrc']); + : await resolveConfig( + options.inputFS, + resolveFrom, + ['.parcelrc'], + options.projectRoot, + ); let usedDefault = false; if (configPath == null && options.defaultConfig != null) { @@ -460,6 +465,7 @@ async function processExtendedConfig( options.inputFS, extendsSpecifier, path.dirname(resolvedExtendedConfigPath), + options.projectRoot, ); throw new ThrowableDiagnostic({ diagnostic: { diff --git a/packages/core/core/src/requests/TargetRequest.js b/packages/core/core/src/requests/TargetRequest.js index d6c82cfb7..b29687f9a 100644 --- a/packages/core/core/src/requests/TargetRequest.js +++ b/packages/core/core/src/requests/TargetRequest.js @@ -297,7 +297,12 @@ export class TargetResolver { exclusiveTarget?: string, ): Promise> { let rootFile = path.join(rootDir, 'index'); - let conf = await loadConfig(this.fs, rootFile, ['package.json']); + let conf = await loadConfig( + this.fs, + rootFile, + ['package.json'], + this.options.projectRoot, + ); // Invalidate whenever a package.json file is added. this.api.invalidateOnFileCreate({ @@ -364,6 +369,7 @@ export class TargetResolver { this.fs, path.join(rootDir, 'index'), ['browserslist', '.browserslistrc'], + this.options.projectRoot, ); this.api.invalidateOnFileCreate({ diff --git a/packages/core/core/src/resolveOptions.js b/packages/core/core/src/resolveOptions.js index 13b6659dd..80889f580 100644 --- a/packages/core/core/src/resolveOptions.js +++ b/packages/core/core/src/resolveOptions.js @@ -37,20 +37,18 @@ export default async function resolveOptions( let inputFS = initialOptions.inputFS || new NodeFS(); let outputFS = initialOptions.outputFS || new NodeFS(); - let packageManager = - initialOptions.packageManager || new NodePackageManager(inputFS); - let entryRoot = initialOptions.entryRoot != null ? path.resolve(initialOptions.entryRoot) : getRootDir(entries); let projectRootFile = - (await resolveConfig(inputFS, path.join(entryRoot, 'index'), [ - ...LOCK_FILE_NAMES, - '.git', - '.hg', - ])) || path.join(inputFS.cwd(), 'index'); // ? Should this just be rootDir + (await resolveConfig( + inputFS, + path.join(entryRoot, 'index'), + [...LOCK_FILE_NAMES, '.git', '.hg'], + path.parse(entryRoot).root, + )) || path.join(inputFS.cwd(), 'index'); // ? Should this just be rootDir let lockFile = null; let rootFileName = path.basename(projectRootFile); @@ -59,6 +57,10 @@ export default async function resolveOptions( } let projectRoot = path.dirname(projectRootFile); + let packageManager = + initialOptions.packageManager || + new NodePackageManager(inputFS, projectRoot); + let inputCwd = inputFS.cwd(); let outputCwd = outputFS.cwd(); @@ -101,6 +103,7 @@ export default async function resolveOptions( initialOptions.env ?? {}, inputFS, path.join(projectRoot, 'index'), + projectRoot, )), }, mode, diff --git a/packages/core/core/test/test-utils.js b/packages/core/core/test/test-utils.js index d52f638a5..d63be1505 100644 --- a/packages/core/core/test/test-utils.js +++ b/packages/core/core/test/test-utils.js @@ -33,7 +33,7 @@ export const DEFAULT_OPTIONS: ParcelOptions = { outputFS, cache, shouldPatchConsole: false, - packageManager: new NodePackageManager(inputFS), + packageManager: new NodePackageManager(inputFS, '/'), additionalReporters: [], instanceId: 'test', defaultTargetOptions: { diff --git a/packages/core/fs/src/MemoryFS.js b/packages/core/fs/src/MemoryFS.js index f0a052da4..4a599acbe 100644 --- a/packages/core/fs/src/MemoryFS.js +++ b/packages/core/fs/src/MemoryFS.js @@ -618,8 +618,12 @@ export class MemoryFS implements FileSystem { await this.writeFile(snapshot, '' + this.events.length); } - findAncestorFile(fileNames: Array, fromDir: FilePath): ?FilePath { - return findAncestorFile(this, fileNames, fromDir); + findAncestorFile( + fileNames: Array, + fromDir: FilePath, + root: FilePath, + ): ?FilePath { + return findAncestorFile(this, fileNames, fromDir, root); } findNodeModule(moduleName: string, fromDir: FilePath): ?FilePath { diff --git a/packages/core/fs/src/OverlayFS.js b/packages/core/fs/src/OverlayFS.js index 81f5e8c61..375c0dffc 100644 --- a/packages/core/fs/src/OverlayFS.js +++ b/packages/core/fs/src/OverlayFS.js @@ -196,8 +196,12 @@ export class OverlayFS implements FileSystem { await this.writable.writeSnapshot(dir, snapshot, opts); } - findAncestorFile(fileNames: Array, fromDir: FilePath): ?FilePath { - return findAncestorFile(this, fileNames, fromDir); + findAncestorFile( + fileNames: Array, + fromDir: FilePath, + root: FilePath, + ): ?FilePath { + return findAncestorFile(this, fileNames, fromDir, root); } findNodeModule(moduleName: string, fromDir: FilePath): ?FilePath { diff --git a/packages/core/fs/src/find.js b/packages/core/fs/src/find.js index 731dafefc..60a1abfff 100644 --- a/packages/core/fs/src/find.js +++ b/packages/core/fs/src/find.js @@ -36,9 +36,11 @@ export function findAncestorFile( fs: FileSystem, fileNames: Array, dir: FilePath, + root: FilePath, ): ?FilePath { - let {root} = path.parse(dir); - while (dir !== root) { + let {root: pathRoot} = path.parse(dir); + // eslint-disable-next-line no-constant-condition + while (true) { if (path.basename(dir) === 'node_modules') { return null; } @@ -54,6 +56,10 @@ export function findAncestorFile( } } + if (dir === root || dir === pathRoot) { + break; + } + dir = path.dirname(dir); } diff --git a/packages/core/fs/src/types.js b/packages/core/fs/src/types.js index c4f34bd10..e90b1575c 100644 --- a/packages/core/fs/src/types.js +++ b/packages/core/fs/src/types.js @@ -64,7 +64,11 @@ export interface FileSystem { snapshot: FilePath, opts: WatcherOptions, ): Promise; - findAncestorFile(fileNames: Array, fromDir: FilePath): ?FilePath; + findAncestorFile( + fileNames: Array, + fromDir: FilePath, + root: FilePath, + ): ?FilePath; findNodeModule(moduleName: string, fromDir: FilePath): ?FilePath; findFirstFile(filePaths: Array): ?FilePath; } diff --git a/packages/core/integration-tests/test/babel.js b/packages/core/integration-tests/test/babel.js index aa773de73..b09ab2a95 100644 --- a/packages/core/integration-tests/test/babel.js +++ b/packages/core/integration-tests/test/babel.js @@ -15,7 +15,6 @@ import { import Logger from '@parcel/logger'; import os from 'os'; import {spawnSync} from 'child_process'; -import {symlinkSync} from 'fs'; import tempy from 'tempy'; const parcelCli = require.resolve('parcel/src/bin.js'); @@ -116,39 +115,6 @@ describe('babel', function() { assert.deepEqual(messages, []); }); - it('should not compile with babel if no targets are defined', async function() { - await bundle(path.join(__dirname, '/integration/babel-default/index.js'), { - defaultTargetOptions: { - engines: undefined, - shouldOptimize: false, - }, - }); - let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); - assert(file.includes('class Foo')); - assert(file.includes('class Bar')); - }); - - it('should support compiling with babel using browserlist', async function() { - await bundle( - path.join(__dirname, '/integration/babel-browserslist/index.js'), - ); - - let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); - assert(file.includes('function Foo')); - assert(file.includes('function Bar')); - }); - - 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'); - assert(file.includes('async function Bar() {}')); - // Check that core-js's globalThis polyfill is referenced. - // NOTE: This may change if core-js internals change. - assert(file.includes('esnext.global-this')); - assert(!file.includes('es.array.concat')); - }); - 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; @@ -180,35 +146,6 @@ describe('babel', function() { ); }); - it('can build using @babel/preset-env when engines have semver ranges', async () => { - let fixtureDir = path.join(__dirname, '/integration/babel-semver-engine'); - await bundle(path.join(fixtureDir, 'index.js')); - - let legacy = await outputFS.readFile( - path.join(fixtureDir, 'dist', 'legacy.js'), - 'utf8', - ); - assert(legacy.includes('function Foo')); - assert(legacy.includes('function Bar')); - - let modern = await outputFS.readFile( - path.join(fixtureDir, 'dist', 'modern.js'), - 'utf8', - ); - assert(modern.includes('class Foo')); - assert(modern.includes('class Bar')); - }); - - it('should not compile node_modules by default', async function() { - await bundle( - path.join(__dirname, '/integration/babel-node-modules/index.js'), - ); - - let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); - assert(/class \S+ \{\}/.test(file)); - assert(file.includes('function Bar')); - }); - it.skip('should compile node_modules with browserslist to app target', async function() { await bundle( path.join( @@ -222,84 +159,6 @@ describe('babel', function() { assert(file.includes('function Bar')); }); - it('should not compile node_modules with a source field in package.json when not symlinked', async function() { - await bundle( - path.join( - __dirname, - '/integration/babel-node-modules-source-unlinked/index.js', - ), - ); - - let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); - assert(!file.includes('function Foo')); - assert(file.includes('function Bar')); - }); - - 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'); - assert(file.includes('React.createElement("div"')); - }); - - 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() { - let b = await bundle( - path.join(__dirname, '/integration/jsx-react/pure-comment.js'), - ); - - let file = await outputFS.readFile( - path.join(distDir, 'pure-comment.js'), - 'utf8', - ); - assert(file.includes('/*#__PURE__*/_reactDefault.default.createElement')); - - let res = await run(b); - assert(res.Foo()); - }); - - 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() { - 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() { - let b = await bundle( - path.join(__dirname, '/integration/jsx-preact-ts/index.tsx'), - ); - - assert(typeof (await run(b)) === 'object'); - }); - - 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() { - 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 strip away flow types', async function() { let b = await bundle( path.join(__dirname, '/integration/babel-strip-flow-types/index.js'), @@ -380,29 +239,6 @@ describe('babel', function() { await outputFS.rimraf(path.join(fixtureDir, 'dist')); }); - it('should support building with default babel config when running parcel globally', async function() { - let tmpDir = tempy.directory(); - let distDir = path.join(tmpDir, 'dist'); - await fs.ncp( - path.join(__dirname, '/integration/babel-default'), - path.join(tmpDir, '/input'), - ); - await bundle(path.join(tmpDir, '/input/index.js'), { - targets: { - modern: { - engines: { - node: '^4.0.0', - }, - distDir, - }, - }, - shouldAutoInstall: true, - }); - let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); - assert(file.includes('function Foo')); - assert(file.includes('function Bar')); - }); - it('should support building with custom babel config when running parcel globally', async function() { let tmpDir = tempy.directory(); let distDir = path.join(tmpDir, 'dist'); @@ -463,7 +299,7 @@ describe('babel', function() { await bundle( path.join(__dirname, '/integration/babel-env-name/index.js'), { - targets: {main: {distDir, engines: {browsers: ['ie 11']}}}, + targets: {main: {distDir, engines: {}}}, shouldDisableCache: false, }, ); @@ -485,7 +321,7 @@ describe('babel', function() { await bundle( path.join(__dirname, '/integration/babel-env-name/index.js'), { - targets: {main: {distDir, engines: {browsers: ['ie 11']}}}, + targets: {main: {distDir, engines: {}}}, shouldDisableCache: false, env: {NODE_ENV: 'production'}, }, @@ -499,7 +335,7 @@ describe('babel', function() { await bundle( path.join(__dirname, '/integration/babel-env-name/index.js'), { - targets: {main: {distDir, engines: {browsers: ['ie 11']}}}, + targets: {main: {distDir, engines: {}}}, shouldDisableCache: false, env: {BABEL_ENV: 'development'}, }, @@ -536,31 +372,6 @@ describe('babel', function() { } }); - it('should compile node_modules when symlinked with a source field in package.json', async function() { - const inputDir = path.join(__dirname, '/input'); - await fs.rimraf(inputDir); - await fs.mkdirp(path.join(inputDir, 'node_modules')); - await fs.ncp( - path.join( - path.join(__dirname, '/integration/babel-node-modules-source'), - ), - inputDir, - ); - - // Create the symlink here to prevent cross platform and git issues - symlinkSync( - path.join(inputDir, 'packages/foo'), - path.join(inputDir, 'node_modules/foo'), - 'dir', - ); - - await bundle(inputDir + '/index.js', {outputFS: fs}); - - let file = await fs.readFile(path.join(distDir, 'index.js'), 'utf8'); - assert(file.includes('function Foo')); - assert(file.includes('function Bar')); - }); - it('should rebuild when .babelrc changes', async function() { let inputDir = tempy.directory(); let differentPath = path.join(inputDir, 'differentConfig'); @@ -662,7 +473,10 @@ describe('babel', function() { ); build(); - let file = await fs.readFile(path.join(distDir, 'index.js'), 'utf8'); + let file = await fs.readFile( + path.join(inputDir, 'dist', 'index.js'), + 'utf8', + ); assert(!file.includes('REPLACE_ME')); assert(file.includes('hello there')); @@ -680,39 +494,78 @@ describe('babel', function() { ); build(); - file = await fs.readFile(path.join(distDir, 'index.js'), 'utf8'); + file = await fs.readFile(path.join(inputDir, 'dist', 'index.js'), 'utf8'); assert(!file.includes('REPLACE_ME')); assert(!file.includes('hello there')); assert(file.includes('something different')); }); }); - it('should support transpiling optional chaining', async function() { + it('should enable shippedProposals with @parcel/babel-preset-env in custom babelrc', async function() { let b = await bundle( - path.join(__dirname, '/integration/babel-optional-chaining/index.js'), + path.join( + __dirname, + '/integration/babel-preset-env-shippedProposals/index.js', + ), ); let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); - assert(!file.includes('?.')); + assert(!file.includes('#priv')); let output = await run(b); - assert.equal(typeof output, 'object'); - assert.deepEqual(output.default, [undefined, undefined]); + assert.strictEqual(typeof output, 'object'); + assert.strictEqual(output.default, 123); }); - it('should enable shippedProposals with @parcel/babel-preset-env in custom babelrc', async function() { + it('should compile with custom babel plugin plus default transforms', async function() { let b = await bundle( - path.join( - __dirname, - '/integration/babel-preset-env-shippedProposals/index.js', - ), + path.join(__dirname, '/integration/babel-custom/index.js'), ); let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); - assert(!file.includes('#priv')); + assert(!file.includes('class Test')); + assert(!file.includes('REPLACE_ME')); + assert(!file.includes('#private')); let output = await run(b); assert.strictEqual(typeof output, 'object'); - assert.strictEqual(output.default, 123); + assert.strictEqual(output.default, 'hello'); + }); + + it('should compile with custom babel plugin and jsx', async function() { + let b = await bundle( + path.join(__dirname, '/integration/babel-custom/jsx.js'), + ); + + let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert(!file.includes('REPLACE_ME')); + assert(file.includes('React.createElement')); + }); + + it('should compile with custom babel plugin and typescript', async function() { + let b = await bundle( + path.join(__dirname, '/integration/babel-custom/ts.ts'), + ); + + let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert(!file.includes('class Test')); + assert(!file.includes('REPLACE_ME')); + assert(!file.includes('#private')); + assert(!file.includes('interface')); + + let output = await run(b); + assert.strictEqual(typeof output, 'object'); + assert.strictEqual(output.default, 'hello'); + }); + + it('should compile with custom babel plugin and tsx', async function() { + let b = await bundle( + path.join(__dirname, '/integration/babel-custom/tsx.tsx'), + ); + + let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); + assert(!file.includes('REPLACE_ME')); + assert(!file.includes('interface')); + assert(file.includes('React.createElement')); }); }); diff --git a/packages/core/integration-tests/test/cache.js b/packages/core/integration-tests/test/cache.js index eb33deee6..0e5ce2bb9 100644 --- a/packages/core/integration-tests/test/cache.js +++ b/packages/core/integration-tests/test/cache.js @@ -21,7 +21,7 @@ import {NodePackageManager} from '@parcel/package-manager'; import {createWorkerFarm} from '@parcel/core'; let inputDir: string; -let packageManager = new NodePackageManager(inputFS); +let packageManager = new NodePackageManager(inputFS, '/'); function runBundle(entries = 'src/index.js', opts) { entries = (Array.isArray(entries) ? entries : [entries]).map(entry => @@ -1141,10 +1141,18 @@ describe('cache', 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, + outputFS: inputFS, async setup() { - await overlayFS.writeFile(path.join(inputDir, 'src/test.txt'), 'hi'); + await inputFS.mkdirp(inputDir); + await inputFS.ncp( + path.join(__dirname, '/integration/cache'), + inputDir, + ); + await inputFS.writeFile(path.join(inputDir, 'src/test.txt'), 'hi'); - await overlayFS.writeFile( + await inputFS.writeFile( path.join(inputDir, 'src/index.js'), 'module.exports = require("fs").readFileSync(__dirname + "/test.txt", "utf8")', ); @@ -1152,10 +1160,12 @@ describe('cache', function() { async update(b) { assert.equal(await run(b.bundleGraph), 'hi'); - await overlayFS.writeFile( + await inputFS.writeFile( path.join(inputDir, 'src/test.txt'), 'updated', ); + + await sleep(100); }, }); @@ -1379,10 +1389,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - !contents.includes('export default'), - 'should not include export default', - ); + assert(!contents.includes('export '), 'should not include export'); let pkgFile = path.join(inputDir, 'package.json'); let pkg = JSON.parse(await overlayFS.readFile(pkgFile)); @@ -1404,10 +1411,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - contents.includes('export default'), - 'should include export default', - ); + assert(contents.includes('export '), 'should include export'); }); it('should support adding a second target', async function() { @@ -1568,10 +1572,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - contents.includes('export default'), - 'should include export default', - ); + assert(contents.includes('export '), 'should include export'); let pkg = JSON.parse(await overlayFS.readFile(pkgFile)); await overlayFS.writeFile( @@ -1701,10 +1702,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - contents.includes('export default'), - 'should include export default', - ); + assert(contents.includes('export '), 'should include export'); contents = await overlayFS.readFile( b.bundleGraph.getBundles()[1].filePath, @@ -1737,10 +1735,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - !contents.includes('export default'), - 'should not include export default', - ); + assert(!contents.includes('export '), 'should not include export'); assert( !contents.includes('module.exports ='), 'should not include module.exports', @@ -1876,10 +1871,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - !contents.includes('export default'), - 'does not include export default', - ); + assert(!contents.includes('export '), 'does not include export'); await overlayFS.writeFile( pkgFile, @@ -1899,10 +1891,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - contents.includes('export default'), - 'should include export default', - ); + assert(contents.includes('export '), 'should include export'); }); it('should update when a package.json is deleted', async function() { @@ -1930,10 +1919,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - contents.includes('export default'), - 'should include export default', - ); + assert(contents.includes('export '), 'should include export'); await overlayFS.unlink(pkgFile); }, }); @@ -1942,10 +1928,7 @@ describe('cache', function() { b.bundleGraph.getBundles()[0].filePath, 'utf8', ); - assert( - !contents.includes('export default'), - 'does not include export default', - ); + assert(!contents.includes('export '), 'does not include export'); }); describe('browserslist', function() { @@ -4287,7 +4270,7 @@ describe('cache', function() { ?.filePath, 'utf8', ); - assert.equal(html.match(/