Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set-up turbo repo and move towards ahead of time compiled files #100

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lib/
logs/
node_modules/
tmp
.turbo

/target/

Expand Down
3 changes: 2 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 3 additions & 1 deletion crates/atlaspack_plugin_resolver/src/atlaspack_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be here? Also a lot of the checks for this code path in the JS version seem a bit overkill to me 🤷

"Not implemented: We need to check excluded dependency for libraries"
));
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/atlaspack_plugin_rpc/src/plugin/resolver.rs
Original file line number Diff line number Diff line change
@@ -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 {}
Expand All @@ -24,6 +24,6 @@ impl RpcResolverPlugin {

impl ResolverPlugin for RpcResolverPlugin {
fn resolve(&self, _ctx: ResolveContext) -> Result<Resolved, anyhow::Error> {
todo!()
Err(anyhow!("Not implemented"))
}
}
2 changes: 1 addition & 1 deletion crates/lmdb-js-lite/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface LmdbOptions {
*/
mapSize?: number
}
function initTracingSubscriber(): void
export function initTracingSubscriber(): void
export interface Entry {
key: string
value: Buffer
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions packages/bundlers/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions packages/bundlers/library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions packages/compressors/brotli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/compressors/gzip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions packages/compressors/raw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions packages/configs/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"main": "index.json",
"scripts": {
"test": "mocha",
"test-ci": "mocha"
},
"dependencies": {
Expand Down
3 changes: 0 additions & 3 deletions packages/configs/repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/core/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions packages/core/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/codeframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions packages/core/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/Atlaspack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert?

entries: Array.isArray(entries)
? entries
: entries == null
Expand Down
5 changes: 1 addition & 4 deletions packages/core/core/src/atlaspack-v3/worker/index.js
Original file line number Diff line number Diff line change
@@ -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');
}

Expand Down
2 changes: 2 additions & 0 deletions packages/core/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ export {
INTERNAL_TRANSFORM,
} from './Atlaspack';

export {ATLASPACK_VERSION} from './constants';

export * from './atlaspack-v3';
4 changes: 3 additions & 1 deletion packages/core/core/src/requests/BundleGraphRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
);

Expand Down
2 changes: 2 additions & 0 deletions packages/core/diagnostic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/feature-flags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
7 changes: 4 additions & 3 deletions packages/core/fs/test/OverlayFS.test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions packages/core/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
1 change: 1 addition & 0 deletions packages/core/integration-tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ test/integration/**/target
test/integration/**/Cargo.lock
test/**/package-lock.json
test/integration/babel-plugin-autoinstall/package.json
built-tests
1 change: 1 addition & 0 deletions packages/core/integration-tests/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/mocharc",
"require": [
"@atlaspack/babel-register",
"@atlaspack/test-utils/src/mochaSetup.js"
Expand Down
3 changes: 2 additions & 1 deletion packages/core/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/integration-tests/test/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
} from '@atlaspack/test-utils';
import type {BundleGraph, BundleGroup, PackagedBundle} from '@atlaspack/types';

describe.v2('BundleGraph', () => {
describe('BundleGraph', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these test changes should be in a separate PR to reduce noise, including the join / removal

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 = [];
Expand Down Expand Up @@ -85,7 +85,7 @@ describe.v2('BundleGraph', () => {
]);
});

describe('getBundlesInBundleGroup', () => {
describe.v2('getBundlesInBundleGroup', () => {
let bundleGraph: BundleGraph<PackagedBundle>;
let bundleGroup: BundleGroup;
let dir = path.join(__dirname, 'get-bundles-in-bundle-group');
Expand Down
16 changes: 8 additions & 8 deletions packages/core/integration-tests/test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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: [
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/atlaspack-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Loading