diff --git a/.gitignore b/.gitignore index 5e7582bea..97b8da99a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ lib/ logs/ node_modules/ tmp +.turbo /target/ diff --git a/.mocharc.json b/.mocharc.json index b75f693a3..81eae57f2 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,5 +1,6 @@ { - "spec": "packages/*/!(integration-tests)/test/{*.js,**/*.{test,spec}.js}", + "$schema": "https://json.schemastore.org/mocharc", + "spec": "test/{*.js,**/*.{test,spec}.js}", "require": [ "@atlaspack/babel-register", "@atlaspack/test-utils/src/mochaSetup.js" diff --git a/crates/atlaspack_plugin_resolver/src/atlaspack_resolver.rs b/crates/atlaspack_plugin_resolver/src/atlaspack_resolver.rs index edc66a694..d2ef99488 100644 --- a/crates/atlaspack_plugin_resolver/src/atlaspack_resolver.rs +++ b/crates/atlaspack_plugin_resolver/src/atlaspack_resolver.rs @@ -361,7 +361,9 @@ impl ResolverPlugin for AtlaspackResolver { (atlaspack_resolver::Resolution::External, _query) => { if let Some(_source_path) = &ctx.dependency.source_path { if ctx.dependency.env.is_library && ctx.dependency.specifier_type != SpecifierType::Url { - todo!("check excluded dependency for libraries"); + return Err(anyhow::anyhow!( + "Not implemented: We need to check excluded dependency for libraries" + )); } } diff --git a/crates/atlaspack_plugin_rpc/src/plugin/resolver.rs b/crates/atlaspack_plugin_rpc/src/plugin/resolver.rs index e0d2f8980..b3e7dade6 100644 --- a/crates/atlaspack_plugin_rpc/src/plugin/resolver.rs +++ b/crates/atlaspack_plugin_rpc/src/plugin/resolver.rs @@ -1,11 +1,11 @@ -use std::fmt; -use std::fmt::Debug; - +use anyhow::anyhow; use atlaspack_config::PluginNode; use atlaspack_core::plugin::PluginContext; use atlaspack_core::plugin::ResolveContext; use atlaspack_core::plugin::Resolved; use atlaspack_core::plugin::ResolverPlugin; +use std::fmt; +use std::fmt::Debug; #[derive(Hash)] pub struct RpcResolverPlugin {} @@ -24,6 +24,6 @@ impl RpcResolverPlugin { impl ResolverPlugin for RpcResolverPlugin { fn resolve(&self, _ctx: ResolveContext) -> Result { - todo!() + Err(anyhow!("Not implemented")) } } diff --git a/crates/lmdb-js-lite/index.d.ts b/crates/lmdb-js-lite/index.d.ts index 9289d1ee3..68a6ab2b8 100644 --- a/crates/lmdb-js-lite/index.d.ts +++ b/crates/lmdb-js-lite/index.d.ts @@ -22,7 +22,7 @@ export interface LmdbOptions { */ mapSize?: number } -function initTracingSubscriber(): void +export function initTracingSubscriber(): void export interface Entry { key: string value: Buffer diff --git a/package.json b/package.json index 36f9f12fd..356c1d923 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,11 @@ "postinstall": "patch-package" }, "devDependencies": { + "@atlaspack/babel-register": "*", + "@babel/cli": "^7.25.6", "@babel/core": "^7.22.11", "@khanacademy/flow-to-ts": "^0.5.2", "@napi-rs/cli": "^2.18.3", - "@atlaspack/babel-register": "*", "@types/node": ">= 18", "buffer": "mischnic/buffer#b8a4fa94", "cross-env": "^7.0.0", @@ -62,7 +63,9 @@ "punycode": "^1.4.1", "rimraf": "^5.0.5", "semver": "^7.5.2", - "sinon": "^7.3.1" + "sinon": "^7.3.1", + "ts-node": "^10.9.2", + "turbo": "^2.1.2" }, "engines": { "node": ">= 16.0.0" diff --git a/packages/bundlers/default/package.json b/packages/bundlers/default/package.json index 39c4de11a..bf0489305 100644 --- a/packages/bundlers/default/package.json +++ b/packages/bundlers/default/package.json @@ -11,6 +11,9 @@ }, "main": "lib/DefaultBundler.js", "source": "src/DefaultBundler.js", + "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib" + }, "engines": { "node": ">= 16.0.0", "parcel": "^2.12.0" diff --git a/packages/bundlers/library/package.json b/packages/bundlers/library/package.json index 8a93aa698..f618cca26 100644 --- a/packages/bundlers/library/package.json +++ b/packages/bundlers/library/package.json @@ -11,6 +11,9 @@ }, "main": "lib/LibraryBundler.js", "source": "src/LibraryBundler.js", + "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib" + }, "engines": { "node": ">= 16.0.0", "parcel": "^2.12.0" diff --git a/packages/compressors/brotli/package.json b/packages/compressors/brotli/package.json index f92a647cb..960c89ba1 100644 --- a/packages/compressors/brotli/package.json +++ b/packages/compressors/brotli/package.json @@ -9,6 +9,9 @@ "type": "git", "url": "https://github.com/atlassian-labs/atlaspack.git" }, + "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib" + }, "main": "lib/BrotliCompressor.js", "source": "src/BrotliCompressor.js", "engines": { diff --git a/packages/compressors/gzip/package.json b/packages/compressors/gzip/package.json index 5291394fe..bb8b26bff 100644 --- a/packages/compressors/gzip/package.json +++ b/packages/compressors/gzip/package.json @@ -5,6 +5,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib" + }, "repository": { "type": "git", "url": "https://github.com/atlassian-labs/atlaspack.git" diff --git a/packages/compressors/raw/package.json b/packages/compressors/raw/package.json index b610c331e..16bf22f12 100644 --- a/packages/compressors/raw/package.json +++ b/packages/compressors/raw/package.json @@ -5,6 +5,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib" + }, "repository": { "type": "git", "url": "https://github.com/atlassian-labs/atlaspack.git" diff --git a/packages/configs/default/package.json b/packages/configs/default/package.json index 7c3f17173..4fc5dcb14 100644 --- a/packages/configs/default/package.json +++ b/packages/configs/default/package.json @@ -11,6 +11,7 @@ }, "main": "index.json", "scripts": { + "test": "mocha", "test-ci": "mocha" }, "dependencies": { diff --git a/packages/configs/repl/package.json b/packages/configs/repl/package.json index db3d2d3d9..468f17504 100644 --- a/packages/configs/repl/package.json +++ b/packages/configs/repl/package.json @@ -8,9 +8,6 @@ "url": "https://github.com/atlassian-labs/atlaspack.git" }, "main": "index.json", - "scripts": { - "test-ci": "mocha" - }, "dependencies": { "@atlaspack/bundler-default": "2.12.0", "@atlaspack/compressor-raw": "2.12.0", diff --git a/packages/core/cache/package.json b/packages/core/cache/package.json index 15e246719..f05a33cad 100644 --- a/packages/core/cache/package.json +++ b/packages/core/cache/package.json @@ -17,6 +17,7 @@ "node": ">= 16.0.0" }, "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib", "test": "mocha", "build-ts": "mkdir -p lib && flow-to-ts src/types.js > lib/types.d.ts", "check-ts": "tsc --noEmit index.d.ts" diff --git a/packages/core/cli/package.json b/packages/core/cli/package.json index 9046b885b..6ebb03549 100644 --- a/packages/core/cli/package.json +++ b/packages/core/cli/package.json @@ -17,6 +17,7 @@ "source": "src/bin.js", "scripts": { "prepack": "./ensure-no-dev-lib.sh", + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib", "dev:prepare": "rimraf ./lib/ && mkdir -p lib && cp ./bin/dev-bin.js ./lib/bin.js" }, "engines": { diff --git a/packages/core/codeframe/package.json b/packages/core/codeframe/package.json index d7f63342d..98443d7ae 100644 --- a/packages/core/codeframe/package.json +++ b/packages/core/codeframe/package.json @@ -6,6 +6,10 @@ "publishConfig": { "access": "public" }, + "scripts": { + "build": "NODE_ENV=production ATLASPACK_BUILD_ENV=production ATLASPACK_SELF_BUILD=true atlaspack build --no-cache .", + "test": "mocha" + }, "repository": { "type": "git", "url": "https://github.com/atlassian-labs/atlaspack.git" diff --git a/packages/core/core/package.json b/packages/core/core/package.json index c046ab3fc..3468119ea 100644 --- a/packages/core/core/package.json +++ b/packages/core/core/package.json @@ -15,6 +15,7 @@ "node": ">= 16.0.0" }, "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib", "test": "mocha", "test-ci": "mocha", "check-ts": "tsc --noEmit index.d.ts" diff --git a/packages/core/core/src/Atlaspack.js b/packages/core/core/src/Atlaspack.js index 6758cb2fe..3fe167b84 100644 --- a/packages/core/core/src/Atlaspack.js +++ b/packages/core/core/src/Atlaspack.js @@ -130,7 +130,7 @@ export default class Atlaspack { rustAtlaspack = new AtlaspackV3({ ...options, corePath: path.join(__dirname, '..'), - threads: process.env.NODE_ENV === 'test' ? 2 : undefined, + threads: process.env.NODE_ENV === 'test' ? 0 : undefined, entries: Array.isArray(entries) ? entries : entries == null diff --git a/packages/core/core/src/atlaspack-v3/worker/index.js b/packages/core/core/src/atlaspack-v3/worker/index.js index c79047238..cc65e0042 100644 --- a/packages/core/core/src/atlaspack-v3/worker/index.js +++ b/packages/core/core/src/atlaspack-v3/worker/index.js @@ -1,7 +1,4 @@ -if ( - process.env.ATLASPACK_BUILD_ENV !== 'production' || - process.env.ATLASPACK_SELF_BUILD -) { +if (process.env.ATLASPACK_SELF_BUILD) { require('@atlaspack/babel-register'); } diff --git a/packages/core/core/src/index.js b/packages/core/core/src/index.js index 638adc7af..209cf2056 100644 --- a/packages/core/core/src/index.js +++ b/packages/core/core/src/index.js @@ -20,4 +20,6 @@ export { INTERNAL_TRANSFORM, } from './Atlaspack'; +export {ATLASPACK_VERSION} from './constants'; + export * from './atlaspack-v3'; diff --git a/packages/core/core/src/requests/BundleGraphRequest.js b/packages/core/core/src/requests/BundleGraphRequest.js index bb9130d44..762582faa 100644 --- a/packages/core/core/src/requests/BundleGraphRequest.js +++ b/packages/core/core/src/requests/BundleGraphRequest.js @@ -114,7 +114,9 @@ export default function createBundleGraphRequest( let {assetGraph, changedAssets, assetRequests} = await api.runRequest( request, { - force: options.shouldBuildLazily && requestedAssetIds.size > 0, + force: + Boolean(input.rustAtlaspack) || + (options.shouldBuildLazily && requestedAssetIds.size > 0), }, ); diff --git a/packages/core/diagnostic/package.json b/packages/core/diagnostic/package.json index 609248b8e..9954a4c71 100644 --- a/packages/core/diagnostic/package.json +++ b/packages/core/diagnostic/package.json @@ -17,6 +17,8 @@ "node": ">= 16.0.0" }, "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib", + "test": "mocha", "build-ts": "flow-to-ts src/*.js --write && tsc --emitDeclarationOnly --declaration --esModuleInterop src/*.ts && mkdir -p lib && mv src/*.d.ts lib/. && rm src/*.ts", "check-ts": "tsc --noEmit lib/diagnostic.d.ts" }, diff --git a/packages/core/feature-flags/package.json b/packages/core/feature-flags/package.json index 380c9b61d..9ee828326 100644 --- a/packages/core/feature-flags/package.json +++ b/packages/core/feature-flags/package.json @@ -14,6 +14,8 @@ "source": "src/index.js", "types": "lib/types.d.ts", "scripts": { + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib", + "test": "mocha test", "build-ts": "mkdir -p lib && flow-to-ts src/types.js > lib/types.d.ts", "check-ts": "tsc --noEmit lib/types.d.ts" }, diff --git a/packages/core/fs/package.json b/packages/core/fs/package.json index a2364f535..46fa64d7f 100644 --- a/packages/core/fs/package.json +++ b/packages/core/fs/package.json @@ -44,6 +44,8 @@ } }, "scripts": { + "test": "mocha", + "build": "NODE_ENV=production ATLASPACK_BUILD_ENV=production ATLASPACK_SELF_BUILD=true atlaspack build --no-cache .", "build-ts": "mkdir -p lib && flow-to-ts src/types.js > lib/types.d.ts", "check-ts": "tsc --noEmit index.d.ts" }, diff --git a/packages/core/fs/test/OverlayFS.test.js b/packages/core/fs/test/OverlayFS.test.js index 3f5e35506..7647c66fd 100644 --- a/packages/core/fs/test/OverlayFS.test.js +++ b/packages/core/fs/test/OverlayFS.test.js @@ -1,9 +1,10 @@ // @flow +import {fsFixture} from '@atlaspack/test-utils'; +import WorkerFarm from '@atlaspack/workers'; + import {OverlayFS} from '../src/OverlayFS'; -import {fsFixture} from '@atlaspack/test-utils/src/fsFixture'; import {MemoryFS} from '../src/MemoryFS'; -import WorkerFarm from '@atlaspack/workers'; import assert from 'assert'; import path from 'path'; @@ -15,7 +16,7 @@ describe('OverlayFS', () => { beforeEach(() => { workerFarm = new WorkerFarm({ - workerPath: require.resolve('@atlaspack/core/src/worker.js'), + workerPath: require.resolve('@atlaspack/core/lib/worker.js'), }); underlayFS = new MemoryFS(workerFarm); fs = new OverlayFS(workerFarm, underlayFS); diff --git a/packages/core/graph/package.json b/packages/core/graph/package.json index 9d844a30c..3844311a0 100644 --- a/packages/core/graph/package.json +++ b/packages/core/graph/package.json @@ -3,6 +3,10 @@ "version": "3.2.0", "description": "Blazing fast, zero configuration web application bundler", "license": "(MIT OR Apache-2.0)", + "scripts": { + "test": "mocha", + "build": "babel --presets=@atlaspack/babel-preset src --out-dir lib" + }, "publishConfig": { "access": "public" }, diff --git a/packages/core/integration-tests/.gitignore b/packages/core/integration-tests/.gitignore index 3709f8231..72315d15d 100644 --- a/packages/core/integration-tests/.gitignore +++ b/packages/core/integration-tests/.gitignore @@ -7,3 +7,4 @@ test/integration/**/target test/integration/**/Cargo.lock test/**/package-lock.json test/integration/babel-plugin-autoinstall/package.json +built-tests diff --git a/packages/core/integration-tests/.mocharc.json b/packages/core/integration-tests/.mocharc.json index a05bfa5bb..48aa697c3 100644 --- a/packages/core/integration-tests/.mocharc.json +++ b/packages/core/integration-tests/.mocharc.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/mocharc", "require": [ "@atlaspack/babel-register", "@atlaspack/test-utils/src/mochaSetup.js" diff --git a/packages/core/integration-tests/package.json b/packages/core/integration-tests/package.json index 8b2fd46a9..afccc243f 100644 --- a/packages/core/integration-tests/package.json +++ b/packages/core/integration-tests/package.json @@ -8,7 +8,8 @@ "url": "https://github.com/atlassian-labs/atlaspack.git" }, "scripts": { - "test": "cross-env NODE_ENV=test ATLASPACK_BUILD_ENV=test mocha --experimental-vm-modules", + "test": "yarn run clear && cross-env ATLASPACK_WORKERS=1 NODE_ENV=test ATLASPACK_BUILD_ENV=test mocha --experimental-vm-modules ./test", + "clear": "rm -rf ./test/.parcel-cache && rm -rf ./test/input", "test-ci": "yarn test --config .mocharc.ci.json" }, "devDependencies": { diff --git a/packages/core/integration-tests/test/BundleGraph.js b/packages/core/integration-tests/test/BundleGraph.js index 474f624f8..db92ee5db 100644 --- a/packages/core/integration-tests/test/BundleGraph.js +++ b/packages/core/integration-tests/test/BundleGraph.js @@ -11,10 +11,10 @@ import { } from '@atlaspack/test-utils'; import type {BundleGraph, BundleGroup, PackagedBundle} from '@atlaspack/types'; -describe.v2('BundleGraph', () => { +describe('BundleGraph', () => { it('can traverse assets across bundles and contexts', async () => { let b = await bundle( - path.join(__dirname, '/integration/worker-shared/index.js'), + path.join(__dirname, 'integration/worker-shared/index.js'), ); let assets = []; @@ -85,7 +85,7 @@ describe.v2('BundleGraph', () => { ]); }); - describe('getBundlesInBundleGroup', () => { + describe.v2('getBundlesInBundleGroup', () => { let bundleGraph: BundleGraph; let bundleGroup: BundleGroup; let dir = path.join(__dirname, 'get-bundles-in-bundle-group'); diff --git a/packages/core/integration-tests/test/api.js b/packages/core/integration-tests/test/api.js index d4cb3bdd1..d0ed354a3 100644 --- a/packages/core/integration-tests/test/api.js +++ b/packages/core/integration-tests/test/api.js @@ -12,14 +12,14 @@ import { overlayFS, } from '@atlaspack/test-utils'; -import {ATLASPACK_VERSION} from '../../core/src/constants'; +import {ATLASPACK_VERSION} from '@atlaspack/core'; -describe.v2('JS API', function () { - it('should respect distEntry', async function () { +describe('JS API', function () { + it.v2('should respect distEntry', async function () { const NAME = 'custom-name.js'; let b = await bundle( - path.join(__dirname, '/integration/js-comment/index.js'), + path.join(__dirname, 'integration/js-comment/index.js'), { targets: { default: {distDir, distEntry: NAME}, @@ -40,7 +40,7 @@ describe.v2('JS API', function () { it('should run additional reports from the options', async function () { let b = await bundle( - path.join(__dirname, '/integration/js-comment/index.js'), + path.join(__dirname, 'integration/js-comment/index.js'), { additionalReporters: [ { @@ -85,10 +85,10 @@ describe.v2('JS API', function () { yarn.lock: reporter-plugin.js: - import {Reporter} from '@atlaspack/plugin'; - import path from 'node:path'; + const {Reporter} = require('@atlaspack/plugin'); + const path = require('node:path'); - export default new Reporter({ + module.exports = new Reporter({ async report({event, options}) { if (event.type === 'buildSuccess') { await options.outputFS.writeFile(path.join(options.projectRoot, 'atlaspack-version.txt'), options.parcelVersion); diff --git a/packages/core/integration-tests/test/atlaspack-query.js b/packages/core/integration-tests/test/atlaspack-query.js index fd14b6a16..6be8a9f4f 100644 --- a/packages/core/integration-tests/test/atlaspack-query.js +++ b/packages/core/integration-tests/test/atlaspack-query.js @@ -8,7 +8,7 @@ import { overlayFS, inputFS, } from '@atlaspack/test-utils'; -import {loadGraphs} from '../../../dev/query/src'; +import {loadGraphs} from '@atlaspack/query'; describe.v2('atlaspack-query', () => { it('loadGraphs', async function () { diff --git a/packages/core/integration-tests/test/babel.js b/packages/core/integration-tests/test/babel.js index 96415877e..939008d86 100644 --- a/packages/core/integration-tests/test/babel.js +++ b/packages/core/integration-tests/test/babel.js @@ -13,7 +13,6 @@ import { outputFS, removeDistDirectory, run, - sleep, } from '@atlaspack/test-utils'; import Logger from '@atlaspack/logger'; import os from 'os'; @@ -27,10 +26,7 @@ const inputDir = path.join(__dirname, '/input'); describe.v2('babel', function () { let subscription; beforeEach(async function () { - // TODO maybe don't do this for all tests - await sleep(100); await outputFS.rimraf(inputDir); - await sleep(100); }); afterEach(async () => { @@ -93,7 +89,7 @@ describe.v2('babel', function () { }); it('should support compiling with babel using .babelrc config', async function () { - await bundle(path.join(__dirname, '/integration/babelrc-custom/index.js')); + await bundle(path.join(__dirname, 'integration/babelrc-custom/index.js')); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); assert(!file.includes('REPLACE_ME')); @@ -108,7 +104,7 @@ describe.v2('babel', function () { } }); await bundle( - path.join(__dirname, '/integration/babel-config-json-custom/index.js'), + path.join(__dirname, 'integration/babel-config-json-custom/index.js'), ); loggerDisposable.dispose(); @@ -166,7 +162,7 @@ describe.v2('babel', function () { it('should strip away flow types', async function () { let b = await bundle( - path.join(__dirname, '/integration/babel-strip-flow-types/index.js'), + path.join(__dirname, 'integration/babel-strip-flow-types/index.js'), ); let output = await run(b); @@ -179,7 +175,7 @@ describe.v2('babel', function () { it('should support compiling with babel using babel.config.js config', async function () { await bundle( - path.join(__dirname, '/integration/babel-config-js/src/index.js'), + path.join(__dirname, 'integration/babel-config-js/src/index.js'), ); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); @@ -189,7 +185,7 @@ describe.v2('babel', function () { it('should support compiling with babel using babel.config.js config with a require in it', async function () { await bundle( - path.join(__dirname, '/integration/babel-config-js-require/src/index.js'), + path.join(__dirname, 'integration/babel-config-js-require/src/index.js'), ); let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); @@ -248,7 +244,7 @@ describe.v2('babel', function () { let tmpDir = tempy.directory(); let distDir = path.join(tmpDir, 'dist'); await fs.ncp( - path.join(__dirname, '/integration/babelrc-custom'), + path.join(__dirname, 'integration/babelrc-custom'), path.join(tmpDir, '/input'), ); await bundle(path.join(tmpDir, '/input/index.js'), { @@ -287,7 +283,7 @@ describe.v2('babel', function () { describe('Babel envName', () => { it('should prefer BABEL_ENV to NODE_ENV', async () => { await bundle( - path.join(__dirname, '/integration/babel-env-name/index.js'), + path.join(__dirname, 'integration/babel-env-name/index.js'), { targets: {main: {distDir, engines: {browsers: ['ie 11']}}}, env: {BABEL_ENV: 'production', NODE_ENV: 'development'}, @@ -302,7 +298,7 @@ describe.v2('babel', function () { it('should invalidate when BABEL_ENV changes', async () => { await bundle( - path.join(__dirname, '/integration/babel-env-name/index.js'), + path.join(__dirname, 'integration/babel-env-name/index.js'), { targets: {main: {distDir, engines: {}}}, shouldDisableCache: false, @@ -315,7 +311,7 @@ describe.v2('babel', function () { assert(file.includes('class Foo')); await bundle( - path.join(__dirname, '/integration/babel-env-name/index.js'), + path.join(__dirname, 'integration/babel-env-name/index.js'), {shouldDisableCache: false, env: {BABEL_ENV: 'production'}}, ); file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8'); @@ -324,7 +320,7 @@ describe.v2('babel', function () { it('should invalidate when NODE_ENV changes from BABEL_ENV', async () => { await bundle( - path.join(__dirname, '/integration/babel-env-name/index.js'), + path.join(__dirname, 'integration/babel-env-name/index.js'), { targets: {main: {distDir, engines: {}}}, shouldDisableCache: false, @@ -338,7 +334,7 @@ describe.v2('babel', function () { assert(!file.includes('class Foo')); await bundle( - path.join(__dirname, '/integration/babel-env-name/index.js'), + path.join(__dirname, 'integration/babel-env-name/index.js'), { targets: {main: {distDir, engines: {}}}, shouldDisableCache: false, @@ -351,7 +347,7 @@ describe.v2('babel', function () { it('should be "production" if Atlaspack is run in production mode', async () => { await bundle( - path.join(__dirname, '/integration/babel-env-name/index.js'), + path.join(__dirname, 'integration/babel-env-name/index.js'), { targets: {main: {distDir, engines: {browsers: ['ie 11']}}}, mode: 'production', @@ -459,7 +455,7 @@ describe.v2('babel', function () { it('should invalidate babel.config.js across runs', async function () { let dateRe = /return (\d+);/; - let fixtureDir = path.join(__dirname, '/integration/babel-config-js'); + let fixtureDir = path.join(__dirname, 'integration/babel-config-js'); let distDir = path.resolve(fixtureDir, './dist'); let cacheDir = path.resolve(fixtureDir, '.parcel-cache'); await fs.rimraf(distDir); @@ -575,7 +571,7 @@ describe.v2('babel', function () { it('should compile with custom babel plugin plus default transforms', async function () { let b = await bundle( - path.join(__dirname, '/integration/babel-custom/index.js'), + path.join(__dirname, 'integration/babel-custom/index.js'), ); let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); @@ -590,7 +586,7 @@ describe.v2('babel', function () { it('should compile with custom babel plugin and jsx', async function () { let b = await bundle( - path.join(__dirname, '/integration/babel-custom/jsx.js'), + path.join(__dirname, 'integration/babel-custom/jsx.js'), ); let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); @@ -600,7 +596,7 @@ describe.v2('babel', function () { it('should compile with custom babel plugin and typescript', async function () { let b = await bundle( - path.join(__dirname, '/integration/babel-custom/ts.ts'), + path.join(__dirname, 'integration/babel-custom/ts.ts'), ); let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); @@ -616,7 +612,7 @@ describe.v2('babel', function () { it('should compile with custom babel plugin and tsx', async function () { let b = await bundle( - path.join(__dirname, '/integration/babel-custom/tsx.tsx'), + path.join(__dirname, 'integration/babel-custom/tsx.tsx'), ); let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8'); @@ -632,7 +628,7 @@ describe.v2('babel', function () { messages.push(message); } }); - let filePath = path.join(__dirname, '/integration/babel-warn-all/index.js'); + let filePath = path.join(__dirname, 'integration/babel-warn-all/index.js'); await bundle(filePath); loggerDisposable.dispose(); diff --git a/packages/core/integration-tests/test/blob-url.js b/packages/core/integration-tests/test/blob-url.js index c058fd6ba..f6807b21d 100644 --- a/packages/core/integration-tests/test/blob-url.js +++ b/packages/core/integration-tests/test/blob-url.js @@ -27,7 +27,7 @@ const URL = { describe('blob-url:', () => { it('inlines and compiles content as a blob url', async () => { - let b = await bundle(join(__dirname, '/integration/blob-url/index.js')); + let b = await bundle(join(__dirname, 'integration/blob-url/index.js')); let created = []; @@ -63,7 +63,7 @@ describe('blob-url:', () => { }); it('inlines, compiles, and minifies content as a blob url', async () => { - let b = await bundle(join(__dirname, '/integration/blob-url/index.js'), { + let b = await bundle(join(__dirname, 'integration/blob-url/index.js'), { defaultTargetOptions: { shouldOptimize: true, }, diff --git a/packages/core/integration-tests/test/bundler.js b/packages/core/integration-tests/test/bundler.js index 16f26cb15..463ad96bf 100644 --- a/packages/core/integration-tests/test/bundler.js +++ b/packages/core/integration-tests/test/bundler.js @@ -6,15 +6,15 @@ import { bundle, describe, findAsset, + fsFixture, it, overlayFS, - fsFixture, run, } from '@atlaspack/test-utils'; import {hashString} from '@atlaspack/rust'; import {normalizePath} from '@atlaspack/utils'; -describe.v2('bundler', function () { +describe('bundler', function () { it('should not create shared bundles when a bundle is being reused and disableSharedBundles is enabled', async function () { await fsFixture(overlayFS, __dirname)` disable-shared-bundle-single-source @@ -532,8 +532,10 @@ describe.v2('bundler', function () { ]); }); - it('should not count inline assests towards parallel request limit', async function () { - await fsFixture(overlayFS, __dirname)` + it.v2( + 'should not count inline assests towards parallel request limit', + async function () { + await fsFixture(overlayFS, __dirname)` inlined-assests buzz.js: export default 7; @@ -562,291 +564,309 @@ describe.v2('bundler', function () { yarn.lock:`; - // Shared bundle should not be removed in this case - let b = await bundle(path.join(__dirname, 'inlined-assests/local.html'), { - mode: 'production', - defaultTargetOptions: { - shouldScopeHoist: false, - }, - inputFS: overlayFS, - }); - - assertBundles(b, [ - { - assets: ['local.html'], - }, - { - assets: ['buzz.js'], - }, - { - assets: [ - 'inline-module.js', - 'local.html', - 'bundle-url.js', - 'cacheLoader.js', - 'js-loader.js', - ], - }, - { - assets: ['esmodule-helpers.js'], - }, - ]); - }); - - it('should not create a shared bundle from an asset if that asset is shared by less than minBundles bundles', async function () { - let b = await bundle( - path.join(__dirname, 'integration/min-bundles/index.js'), - { + // Shared bundle should not be removed in this case + let b = await bundle(path.join(__dirname, 'inlined-assests/local.html'), { mode: 'production', defaultTargetOptions: { shouldScopeHoist: false, }, - }, - ); + inputFS: overlayFS, + }); - assertBundles(b, [ - { - name: 'index.js', - assets: [ - 'index.js', - 'bundle-url.js', - 'cacheLoader.js', - 'css-loader.js', - 'esmodule-helpers.js', - 'js-loader.js', - 'bundle-manifest.js', - ], - }, - { - // a and b are shared between only 2 bundles so they are kept in each bundle - assets: ['bar.js', 'a.js', 'b.js'], - }, - { - assets: ['buzz.js'], - }, - { - assets: ['a.js', 'b.js', 'foo.js'], - }, - { - // c is shared between 3 different bundles, so it stays - assets: ['c.js'], - }, - { - assets: ['styles.css'], - }, - { - assets: ['local.html'], - }, - ]); - }); + assertBundles(b, [ + { + assets: ['local.html'], + }, + { + assets: ['buzz.js'], + }, + { + assets: [ + 'inline-module.js', + 'local.html', + 'bundle-url.js', + 'cacheLoader.js', + 'js-loader.js', + ], + }, + { + assets: ['esmodule-helpers.js'], + }, + ]); + }, + ); + + it.v2( + 'should not create a shared bundle from an asset if that asset is shared by less than minBundles bundles', + async function () { + let b = await bundle( + path.join(__dirname, 'integration/min-bundles/index.js'), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); - it('should remove reused bundle (over shared bundles based on size) if the bundlegroup hit the parallel request limit', async function () { - let b = await bundle( - path.join( - __dirname, - 'integration/shared-bundle-reused-bundle-remove-reuse/index.js', - ), - { - mode: 'production', - defaultTargetOptions: { - shouldScopeHoist: false, + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'css-loader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], }, - }, - ); + { + // a and b are shared between only 2 bundles so they are kept in each bundle + assets: ['bar.js', 'a.js', 'b.js'], + }, + { + assets: ['buzz.js'], + }, + { + assets: ['a.js', 'b.js', 'foo.js'], + }, + { + // c is shared between 3 different bundles, so it stays + assets: ['c.js'], + }, + { + assets: ['styles.css'], + }, + { + assets: ['local.html'], + }, + ]); + }, + ); + + it.v2( + 'should remove reused bundle (over shared bundles based on size) if the bundlegroup hit the parallel request limit', + async function () { + let b = await bundle( + path.join( + __dirname, + 'integration/shared-bundle-reused-bundle-remove-reuse/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); - assertBundles(b, [ - { - name: 'index.js', - assets: [ - 'index.js', - 'bundle-url.js', - 'cacheLoader.js', - 'css-loader.js', - 'esmodule-helpers.js', - 'js-loader.js', - 'bundle-manifest.js', - ], - }, - { - assets: ['bar.js', 'foo.js', 'a.js', 'b.js'], - }, - { - assets: ['buzz.js'], - }, - { - assets: ['c.js'], - }, - { - assets: ['a.js', 'b.js', 'foo.js'], - }, - { - assets: ['styles.css'], - }, - { - assets: ['local.html'], - }, - ]); - }); + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'css-loader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['bar.js', 'foo.js', 'a.js', 'b.js'], + }, + { + assets: ['buzz.js'], + }, + { + assets: ['c.js'], + }, + { + assets: ['a.js', 'b.js', 'foo.js'], + }, + { + assets: ['styles.css'], + }, + { + assets: ['local.html'], + }, + ]); + }, + ); //This test case is the same as previous except we remove the shared bundle since it is smaller - it('should remove shared bundle (over reused bundles based on size) if the bundlegroup hit the parallel request limit', async function () { - let b = await bundle( - path.join( - __dirname, - 'integration/shared-bundle-reused-bundle-remove-shared/index.js', - ), - { - mode: 'production', - defaultTargetOptions: { - shouldScopeHoist: false, + it.v2( + 'should remove shared bundle (over reused bundles based on size) if the bundlegroup hit the parallel request limit', + async function () { + let b = await bundle( + path.join( + __dirname, + 'integration/shared-bundle-reused-bundle-remove-shared/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, }, - }, - ); - - assertBundles(b, [ - { - name: 'index.js', - assets: [ - 'index.js', - 'bundle-url.js', - 'cacheLoader.js', - 'css-loader.js', - 'esmodule-helpers.js', - 'js-loader.js', - 'bundle-manifest.js', - ], - }, - { - assets: ['bar.js', 'c.js'], - }, - { - // A consequence of our shared bundle 'c' being removed for the bundleGroup bar - // is that it must also be removed for buzz, even though the buzz bundleGroup does not - // hit the parallel request limit. This is because the shared bundle is no longer sharing - // it is only attached to one bundle and thus should be removed. - assets: ['buzz.js', 'c.js'], - }, - { - assets: ['a.js', 'b.js', 'foo.js'], - }, - { - assets: ['styles.css'], - }, - { - assets: ['local.html'], - }, - ]); - }); + ); - it('should not remove shared bundle from graph if one bundlegroup hits the parallel request limit, and at least 2 other bundleGroups that need it do not', async function () { - //The shared bundle should only be 'put back' for the bundlegroups which hit the parallel request limit - // But if there are at least two other bundlegroups using this shared bundle that do not hit the max limit - // the shared bundle should not be removed from the graph - let b = await bundle( - path.join( - __dirname, - 'integration/shared-bundle-remove-from-one-group-only/index.js', - ), - { - mode: 'production', - defaultTargetOptions: { - shouldScopeHoist: false, + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'css-loader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], }, - }, - ); - - assertBundles(b, [ - { - name: 'index.js', - assets: [ - 'index.js', - 'bundle-url.js', - 'cacheLoader.js', - 'css-loader.js', - 'esmodule-helpers.js', - 'js-loader.js', - 'bundle-manifest.js', - ], - }, - { - assets: ['bar.js', 'c.js'], // shared bundle merged back - }, - { - assets: ['buzz.js'], - }, - { - assets: ['c.js'], // shared bundle - }, - { - assets: ['foo.js'], - }, - { - assets: ['styles.css'], - }, - { - assets: ['local.html'], - }, - ]); - }); + { + assets: ['bar.js', 'c.js'], + }, + { + // A consequence of our shared bundle 'c' being removed for the bundleGroup bar + // is that it must also be removed for buzz, even though the buzz bundleGroup does not + // hit the parallel request limit. This is because the shared bundle is no longer sharing + // it is only attached to one bundle and thus should be removed. + assets: ['buzz.js', 'c.js'], + }, + { + assets: ['a.js', 'b.js', 'foo.js'], + }, + { + assets: ['styles.css'], + }, + { + assets: ['local.html'], + }, + ]); + }, + ); + + it.v2( + 'should not remove shared bundle from graph if one bundlegroup hits the parallel request limit, and at least 2 other bundleGroups that need it do not', + async function () { + //The shared bundle should only be 'put back' for the bundlegroups which hit the parallel request limit + // But if there are at least two other bundlegroups using this shared bundle that do not hit the max limit + // the shared bundle should not be removed from the graph + let b = await bundle( + path.join( + __dirname, + 'integration/shared-bundle-remove-from-one-group-only/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); - it('should not remove shared bundle from graph if its parent (a reused bundle) is removed by parallel request limit', async function () { - //The shared bundle should only be 'put back' for the bundlegroups which hit the parallel request limit - // But if there are at least two other bundlegroups using this shared bundle that do not hit the max limit - // the shared bundle should not be removed from the graph - let b = await bundle( - path.join( - __dirname, - 'integration/shared-bundle-between-reused-bundle-removal/index.js', - ), - { - mode: 'production', - defaultTargetOptions: { - shouldScopeHoist: false, + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'css-loader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], }, - }, - ); + { + assets: ['bar.js', 'c.js'], // shared bundle merged back + }, + { + assets: ['buzz.js'], + }, + { + assets: ['c.js'], // shared bundle + }, + { + assets: ['foo.js'], + }, + { + assets: ['styles.css'], + }, + { + assets: ['local.html'], + }, + ]); + }, + ); + + it.v2( + 'should not remove shared bundle from graph if its parent (a reused bundle) is removed by parallel request limit', + async function () { + //The shared bundle should only be 'put back' for the bundlegroups which hit the parallel request limit + // But if there are at least two other bundlegroups using this shared bundle that do not hit the max limit + // the shared bundle should not be removed from the graph + let b = await bundle( + path.join( + __dirname, + 'integration/shared-bundle-between-reused-bundle-removal/index.js', + ), + { + mode: 'production', + defaultTargetOptions: { + shouldScopeHoist: false, + }, + }, + ); - assertBundles(b, [ - { - name: 'index.js', - assets: [ - 'index.js', - 'bundle-url.js', - 'cacheLoader.js', - 'css-loader.js', - 'esmodule-helpers.js', - 'js-loader.js', - 'bundle-manifest.js', - ], - }, - { - assets: ['bar.js', 'foo.js', 'a.js', 'b.js'], // shared bundle merged back - }, - { - assets: ['buzz.js'], - }, - { - assets: ['c.js'], // shared bundle - }, - { - assets: ['foo.js', 'a.js', 'b.js'], - }, - { - assets: ['styles.css'], - }, - { - assets: ['local.html'], - }, - ]); + assertBundles(b, [ + { + name: 'index.js', + assets: [ + 'index.js', + 'bundle-url.js', + 'cacheLoader.js', + 'css-loader.js', + 'esmodule-helpers.js', + 'js-loader.js', + 'bundle-manifest.js', + ], + }, + { + assets: ['bar.js', 'foo.js', 'a.js', 'b.js'], // shared bundle merged back + }, + { + assets: ['buzz.js'], + }, + { + assets: ['c.js'], // shared bundle + }, + { + assets: ['foo.js', 'a.js', 'b.js'], + }, + { + assets: ['styles.css'], + }, + { + assets: ['local.html'], + }, + ]); - assert( - b - .getReferencedBundles(b.getBundlesWithAsset(findAsset(b, 'bar.js'))[0]) - .includes(b.getBundlesWithAsset(findAsset(b, 'c.js'))[0]), - ); - }); + assert( + b + .getReferencedBundles( + b.getBundlesWithAsset(findAsset(b, 'bar.js'))[0], + ) + .includes(b.getBundlesWithAsset(findAsset(b, 'c.js'))[0]), + ); + }, + ); - it('should split manifest bundle', async function () { + it.v2('should split manifest bundle', async function () { let b = await bundle( [ path.join(__dirname, 'integration/split-manifest-bundle/a.html'), @@ -1025,7 +1045,7 @@ describe.v2('bundler', function () { ]); }); - it('should support inline constants', async () => { + it.v2('should support inline constants', async () => { await fsFixture(overlayFS, __dirname)` inline-constants-shared-bundles one.html: @@ -1099,7 +1119,7 @@ describe.v2('bundler', function () { ]); }); - it('should support inline constants with shared bundles', async () => { + it.v2('should support inline constants with shared bundles', async () => { await fsFixture(overlayFS, __dirname)` inline-constants-shared-bundles one.html: @@ -1264,7 +1284,7 @@ describe.v2('bundler', function () { 'async value should not be inlined', ); }); - describe('manual shared bundles', () => { + describe.v2('manual shared bundles', () => { const dir = path.join(__dirname, 'manual-bundle'); beforeEach(() => { diff --git a/packages/core/integration-tests/test/cache.js b/packages/core/integration-tests/test/cache.js index d33ea73e1..df597bef5 100644 --- a/packages/core/integration-tests/test/cache.js +++ b/packages/core/integration-tests/test/cache.js @@ -33,11 +33,11 @@ import {md} from '@atlaspack/diagnostic'; import fs from 'fs'; import {NodePackageManager} from '@atlaspack/package-manager'; import {createWorkerFarm} from '@atlaspack/core'; -import resolveOptions from '@atlaspack/core/src/resolveOptions'; +import resolveOptions from '@atlaspack/core/lib/resolveOptions'; import logger from '@atlaspack/logger'; import sinon from 'sinon'; import {version} from '@atlaspack/core/package.json'; -import {deserialize} from '@atlaspack/core/src/serializer'; +import {deserialize} from '@atlaspack/core/lib/serializer'; import {hashString} from '@atlaspack/rust'; let inputDir: string; @@ -76,7 +76,7 @@ type TestConfig = {| async function testCache(update: UpdateFn | TestConfig, integration) { await overlayFS.rimraf(path.join(__dirname, '/input')); await ncp( - path.join(__dirname, '/integration', integration ?? 'cache'), + path.join(__dirname, 'integration', integration ?? 'cache'), path.join(inputDir), ); @@ -266,7 +266,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); }, @@ -313,7 +313,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -364,7 +364,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -408,7 +408,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -466,7 +466,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); }, @@ -521,7 +521,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -580,7 +580,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -635,7 +635,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -690,7 +690,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -745,7 +745,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile( @@ -799,7 +799,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.mkdirp( @@ -872,7 +872,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.copyFile( @@ -935,7 +935,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.mkdirp( @@ -1197,7 +1197,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); await inputFS.writeFile(path.join(inputDir, 'src/test.txt'), 'hi'); @@ -3545,7 +3545,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/pnp-require'), + path.join(__dirname, 'integration/pnp-require'), inputDir, ); @@ -4064,7 +4064,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/cache'), + path.join(__dirname, 'integration/cache'), inputDir, ); @@ -4214,7 +4214,10 @@ describe.v2('cache', function () { describe('esm', function () { async function setup() { await inputFS.mkdirp(inputDir); - await inputFS.ncp(path.join(__dirname, '/integration/cache'), inputDir); + await inputFS.ncp( + path.join(__dirname, 'integration/cache'), + inputDir, + ); await inputFS.writeFile( path.join(inputDir, '.parcelrc'), JSON.stringify({ @@ -4486,7 +4489,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/postcss-js-config-7'), + path.join(__dirname, 'integration/postcss-js-config-7'), inputDir, ); }, @@ -4525,7 +4528,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(path.join(inputDir, 'node_modules')); await inputFS.ncp( - path.join(__dirname, '/integration/postcss-autoinstall/npm'), + path.join(__dirname, 'integration/postcss-autoinstall/npm'), inputDir, ); await inputFS.ncp( @@ -4596,7 +4599,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/postcss-esm-config'), + path.join(__dirname, 'integration/postcss-esm-config'), inputDir, ); }, @@ -4751,7 +4754,7 @@ describe.v2('cache', function () { async setup() { await inputFS.mkdirp(inputDir); await inputFS.ncp( - path.join(__dirname, '/integration/posthtml'), + path.join(__dirname, 'integration/posthtml'), inputDir, ); @@ -6458,7 +6461,7 @@ describe.v2('cache', function () { it('should correctly read additional child assets from cache', async function () { await ncp( - path.join(__dirname, '/integration/postcss-modules-cjs'), + path.join(__dirname, 'integration/postcss-modules-cjs'), path.join(inputDir), ); @@ -6492,7 +6495,7 @@ describe.v2('cache', function () { it('should correctly read additional child assets from cache 2', async function () { await ncp( - path.join(__dirname, '/integration/postcss-modules-cjs'), + path.join(__dirname, 'integration/postcss-modules-cjs'), path.join(inputDir), ); @@ -6534,7 +6537,7 @@ describe.v2('cache', function () { }); it('should correctly reuse intermediate pipeline results when transforming', async function () { - await ncp(path.join(__dirname, '/integration/json'), path.join(inputDir)); + await ncp(path.join(__dirname, 'integration/json'), path.join(inputDir)); let entry = path.join(inputDir, 'index.js'); let original = await overlayFS.readFile(entry, 'utf8'); @@ -6563,7 +6566,7 @@ describe.v2('cache', function () { it('properly watches included files even after resaving them without changes', async function () { this.timeout(15000); let subscription; - let fixture = path.join(__dirname, '/integration/included-file'); + let fixture = path.join(__dirname, 'integration/included-file'); try { let b = bundler(path.join(fixture, 'index.txt'), { inputFS: overlayFS, @@ -6620,7 +6623,7 @@ describe.v2('cache', function () { it('properly handles included files even after when changing back to a cached state', async function () { this.timeout(15000); let subscription; - let fixture = path.join(__dirname, '/integration/included-file'); + let fixture = path.join(__dirname, 'integration/included-file'); try { let b = bundler(path.join(fixture, 'index.txt'), { inputFS: overlayFS, @@ -6667,7 +6670,7 @@ describe.v2('cache', function () { it('properly watches included files after a transformer error', async function () { this.timeout(15000); let subscription; - let fixture = path.join(__dirname, '/integration/included-file'); + let fixture = path.join(__dirname, 'integration/included-file'); try { let b = bundler(path.join(fixture, 'index.txt'), { inputFS: overlayFS, @@ -6719,7 +6722,10 @@ describe.v2('cache', function () { outputFS: inputFS, async setup() { await inputFS.mkdirp(inputDir); - await inputFS.ncp(path.join(__dirname, '/integration/cache'), inputDir); + await inputFS.ncp( + path.join(__dirname, 'integration/cache'), + inputDir, + ); }, update: async b => { assert.equal(await run(b.bundleGraph), 4); diff --git a/packages/core/integration-tests/test/compressors.js b/packages/core/integration-tests/test/compressors.js index 5198cad4d..5fd4bd8f4 100644 --- a/packages/core/integration-tests/test/compressors.js +++ b/packages/core/integration-tests/test/compressors.js @@ -36,7 +36,10 @@ describe.v2('compressors', function () { it('should be able to disable raw output', async function () { await bundle( - path.join(__dirname, 'integration/compressors-disable-default/index.js'), + path.join( + __dirname, + 'integration/compressors-disable-default/index.js', + ), { mode: 'production', }, diff --git a/packages/core/integration-tests/test/config-merging.js b/packages/core/integration-tests/test/config-merging.js index 628df1fe7..251e96698 100644 --- a/packages/core/integration-tests/test/config-merging.js +++ b/packages/core/integration-tests/test/config-merging.js @@ -5,11 +5,11 @@ import path from 'path'; describe.v2('config merging', function () { it('should merge incomplete config packages', async function () { let b = await bundle( - path.join(__dirname, '/integration/config-merging/index.js'), + path.join(__dirname, 'integration/config-merging/index.js'), ); let content = ( await outputFS.readFile( - path.join(__dirname, '/integration/config-merging/dist/index.js'), + path.join(__dirname, 'integration/config-merging/dist/index.js'), ) ).toString(); assert(content.includes('runtime injected')); diff --git a/packages/core/integration-tests/test/contentHashing.js b/packages/core/integration-tests/test/contentHashing.js index d97dcafa0..020f158ff 100644 --- a/packages/core/integration-tests/test/contentHashing.js +++ b/packages/core/integration-tests/test/contentHashing.js @@ -21,14 +21,14 @@ function bundle(path) { }); } -describe.v2('content hashing', function () { +describe('content hashing', function () { beforeEach(async () => { await outputFS.rimraf(path.join(__dirname, '/input')); }); - it('should update content hash when content changes', async function () { + it.v2('should update content hash when content changes', async function () { await ncp( - path.join(__dirname, '/integration/html-css'), + path.join(__dirname, 'integration/html-css'), path.join(__dirname, '/input'), ); @@ -59,9 +59,9 @@ describe.v2('content hashing', function () { assert.notEqual(filename, newFilename); }); - it('should update content hash when raw asset changes', async function () { + it.v2('should update content hash when raw asset changes', async function () { await ncp( - path.join(__dirname, '/integration/import-raw'), + path.join(__dirname, 'integration/import-raw'), path.join(__dirname, '/input'), ); @@ -94,25 +94,28 @@ describe.v2('content hashing', function () { ); }); - it('should generate the same hash for the same distDir inside separate projects', async () => { - let a = await _bundle( - path.join(__dirname, 'integration/hash-distDir/a/index.html'), - {sourceMaps: true}, - ); - let b = await _bundle( - path.join(__dirname, 'integration/hash-distDir/b/index.html'), - {sourceMaps: true}, - ); - - let aBundles = a.getBundles(); - let bBundles = b.getBundles(); - - assert.equal(aBundles.length, 2); - assert.equal(bBundles.length, 2); - - let aJS = aBundles.find(bundle => bundle.type === 'js'); - let bJS = bBundles.find(bundle => bundle.type === 'js'); - assert(/index\.[a-f0-9]*\.js/.test(path.basename(aJS.filePath))); - assert.equal(aJS.name, bJS.name); - }); + it.v2( + 'should generate the same hash for the same distDir inside separate projects', + async () => { + let a = await _bundle( + path.join(__dirname, 'integration/hash-distDir/a/index.html'), + {sourceMaps: true}, + ); + let b = await _bundle( + path.join(__dirname, 'integration/hash-distDir/b/index.html'), + {sourceMaps: true}, + ); + + let aBundles = a.getBundles(); + let bBundles = b.getBundles(); + + assert.equal(aBundles.length, 2); + assert.equal(bBundles.length, 2); + + let aJS = aBundles.find(bundle => bundle.type === 'js'); + let bJS = bBundles.find(bundle => bundle.type === 'js'); + assert(/index\.[a-f0-9]*\.js/.test(path.basename(aJS.filePath))); + assert.equal(aJS.name, bJS.name); + }, + ); }); diff --git a/packages/core/integration-tests/test/css-modules.js b/packages/core/integration-tests/test/css-modules.js index 79af5b9cb..8d59fdc44 100644 --- a/packages/core/integration-tests/test/css-modules.js +++ b/packages/core/integration-tests/test/css-modules.js @@ -17,7 +17,7 @@ import postcss from 'postcss'; describe.v2('css modules', () => { it('should support transforming css modules (require)', async () => { let b = await bundle( - path.join(__dirname, '/integration/postcss-modules-cjs/index.js'), + path.join(__dirname, 'integration/postcss-modules-cjs/index.js'), ); assertBundles(b, [ @@ -208,7 +208,7 @@ describe.v2('css modules', () => { it('should support css modules composes imports', async () => { let b = await bundle( - path.join(__dirname, '/integration/postcss-composes/index.js'), + path.join(__dirname, 'integration/postcss-composes/index.js'), ); assertBundles(b, [ @@ -251,7 +251,7 @@ describe.v2('css modules', () => { it('should not include css twice for composes imports', async () => { let b = await bundle( - path.join(__dirname, '/integration/postcss-composes/index.js'), + path.join(__dirname, 'integration/postcss-composes/index.js'), ); await run(b); @@ -265,7 +265,7 @@ describe.v2('css modules', () => { it('should support composes imports for sass', async () => { let b = await bundle( - path.join(__dirname, '/integration/postcss-composes/index2.js'), + path.join(__dirname, 'integration/postcss-composes/index2.js'), ); assertBundles(b, [ @@ -293,7 +293,7 @@ describe.v2('css modules', () => { it('should support composes imports with custom path names', async () => { let b = await bundle( - path.join(__dirname, '/integration/postcss-composes/index3.js'), + path.join(__dirname, 'integration/postcss-composes/index3.js'), ); assertBundles(b, [ @@ -321,7 +321,7 @@ describe.v2('css modules', () => { it('should support deep nested composes imports', async () => { let b = await bundle( - path.join(__dirname, '/integration/postcss-composes/index4.js'), + path.join(__dirname, 'integration/postcss-composes/index4.js'), ); assertBundles(b, [ @@ -362,7 +362,7 @@ describe.v2('css modules', () => { it('should support composes imports for multiple selectors', async () => { let b = await bundle( - path.join(__dirname, '/integration/postcss-composes/index5.js'), + path.join(__dirname, 'integration/postcss-composes/index5.js'), ); assertBundles(b, [ @@ -438,7 +438,7 @@ describe.v2('css modules', () => { it('should fall back to postcss for legacy css modules', async function () { let b = await bundle( - path.join(__dirname, '/integration/css-modules-legacy/index.js'), + path.join(__dirname, 'integration/css-modules-legacy/index.js'), ); assertBundles(b, [ @@ -458,7 +458,7 @@ describe.v2('css modules', () => { it('should fall back to postcss for legacy css modules with :export', async function () { let b = await bundle( - path.join(__dirname, '/integration/css-modules-legacy/b.js'), + path.join(__dirname, 'integration/css-modules-legacy/b.js'), ); assertBundles(b, [ @@ -478,7 +478,7 @@ describe.v2('css modules', () => { it('should optimize away unused @keyframes', async function () { let b = await bundle( - path.join(__dirname, '/integration/css-modules-keyframes/index.js'), + path.join(__dirname, 'integration/css-modules-keyframes/index.js'), { mode: 'production', }, @@ -502,7 +502,7 @@ describe.v2('css modules', () => { it('should not double optimize css modules processed with postcss', async function () { let b = await bundle( - path.join(__dirname, '/integration/postcss-modules-optimize/index.js'), + path.join(__dirname, 'integration/postcss-modules-optimize/index.js'), { mode: 'production', }, @@ -526,7 +526,7 @@ describe.v2('css modules', () => { it('should compile css modules for multiple targets', async function () { let b = await bundle( - path.join(__dirname, '/integration/css-modules-targets/index.html'), + path.join(__dirname, 'integration/css-modules-targets/index.html'), { mode: 'production', }, @@ -554,7 +554,7 @@ describe.v2('css modules', () => { it('should not fail with many css modules', async function () { let b = await bundle( - path.join(__dirname, '/integration/css-modules-bug/src/index.html'), + path.join(__dirname, 'integration/css-modules-bug/src/index.html'), ); assertBundles(b, [ @@ -582,8 +582,8 @@ describe.v2('css modules', () => { it('should handle @import in css modules', async function () { let b = await bundle( [ - path.join(__dirname, '/integration/css-modules-import/page1.html'), - path.join(__dirname, '/integration/css-modules-import/page2.html'), + path.join(__dirname, 'integration/css-modules-import/page1.html'), + path.join(__dirname, 'integration/css-modules-import/page2.html'), ], {mode: 'production'}, ); @@ -640,7 +640,7 @@ describe.v2('css modules', () => { it('should not process inline