From 543dde9144b2fffd54b5de74c1fb359073ff53a4 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Fri, 25 Mar 2022 10:27:17 +1100 Subject: [PATCH] Reference lang source code directly from components --- .github/workflows/ci.yaml | 42 ++++++------------- packages/components/package.json | 5 +-- packages/components/src/SquiggleChart.tsx | 2 +- ...pertentiles.json => spec-percentiles.json} | 0 packages/components/tsconfig.json | 14 ++++++- packages/components/webpack.config.js | 6 ++- packages/squiggle-lang/package.json | 2 +- packages/squiggle-lang/tsconfig.json | 3 +- 8 files changed, 36 insertions(+), 38 deletions(-) rename packages/components/src/{spec-pertentiles.json => spec-percentiles.json} (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cb8d135e..e4eef4ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,37 +32,28 @@ jobs: name: Language build and test runs-on: ubuntu-latest needs: pre_check - if: ${{ needs.pre_check.outputs.should_skip_lang != 'true' || needs.pre_check.outputs.should_skip_components != 'true' }} + if: ${{ needs.pre_check.outputs.should_skip_lang != 'true' }} defaults: run: shell: bash working-directory: packages/squiggle-lang steps: - uses: actions/checkout@v2 - # - name: Install packages from monorepo level - # run: cd ../../ && yarn - - name: Install packages - run: yarn + - name: Install dependencies from monorepo level + run: cd ../../ && yarn + # - name: Install dependencies + # run: yarn - name: Build rescript codebase run: yarn build - name: Run tests run: yarn test - name: Run tsc and webpack run: yarn bundle - - name: Cache lang build and bundle outputs - uses: actions/cache@v3 - id: lang-outputs - with: - path: | - lib - dist - node_modules - key: ${{ github.sha }} components-build-test: name: Components build and test runs-on: ubuntu-latest - needs: [pre_check, lang-build-test] + needs: [pre_check] if: ${{ needs.pre_check.outputs.should_skip_components != 'true' }} defaults: run: @@ -70,19 +61,12 @@ jobs: working-directory: packages/components steps: - uses: actions/checkout@v2 - - name: Gain lang build and bundle outputs from cache - uses: actions/cache@v3 - id: lang-outputs - with: - path: | - lib - dist - node_modules - key: ${{ github.sha }} - # - name: Install packages from monorepo level - # run: cd ../../ && yarn - - name: Install packages for components package - run: yarn + - name: Build rescript in squiggle-lang + run: cd ../squiggle-lang && yarn build + - name: Install dependencies from monorepo level + run: cd ../../ && yarn + # - name: Install dependencies for components package + # run: yarn - name: Run tsc and webpack # I'm uncertain if bundle comes before build, it was jotted down in a readme that way but it may have been erroneous. run: yarn bundle - name: Build storybook @@ -99,7 +83,7 @@ jobs: working-directory: packages/website steps: - uses: actions/checkout@v2 - - name: Install packages + - name: Install dependencies run: yarn - name: Build website assets run: yarn build diff --git a/packages/components/package.json b/packages/components/package.json index b480e4ed..c7197f2a 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -28,7 +28,7 @@ "scripts": { "start": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public", "build": "build-storybook -s public", - "bundle": "tsc && webpack", + "bundle": "webpack", "all": "yarn bundle && yarn build" }, "eslintConfig": { @@ -80,7 +80,6 @@ "@types/react": "17.0.39" }, "source": "./src/index.ts", - "module": "dist/index.js", "main": "dist/bundle.js", - "types": "dist/index.d.ts" + "types": "dist/src/index.d.ts" } diff --git a/packages/components/src/SquiggleChart.tsx b/packages/components/src/SquiggleChart.tsx index a23ef2e6..27823b12 100644 --- a/packages/components/src/SquiggleChart.tsx +++ b/packages/components/src/SquiggleChart.tsx @@ -10,7 +10,7 @@ import type { } from "@quri/squiggle-lang"; import { createClassFromSpec } from "react-vega"; import * as chartSpecification from "./spec-distributions.json"; -import * as percentilesSpec from "./spec-pertentiles.json"; +import * as percentilesSpec from "./spec-percentiles.json"; let SquiggleVegaChart = createClassFromSpec({ spec: chartSpecification as Spec, diff --git a/packages/components/src/spec-pertentiles.json b/packages/components/src/spec-percentiles.json similarity index 100% rename from packages/components/src/spec-pertentiles.json rename to packages/components/src/spec-percentiles.json diff --git a/packages/components/tsconfig.json b/packages/components/tsconfig.json index b4b8699a..62cf4fcf 100644 --- a/packages/components/tsconfig.json +++ b/packages/components/tsconfig.json @@ -1,5 +1,8 @@ { "compilerOptions": { + "paths": { + "@quri/squiggle-lang": ["../squiggle-lang/src/js"] + }, "module": "commonjs", "jsx": "react", "resolveJsonModule": true, @@ -7,12 +10,19 @@ "esModuleInterop": true, "removeComments": true, "preserveConstEnums": true, + "composite": true, "outDir": "./dist", "declarationDir": "./dist", "declaration": true, "sourceMap": true }, + "files": ["src/spec-distributions.json","src/spec-percentiles.json"], "target": "ES6", - "include": ["src/**/*"], - "exclude": ["node_modules", "**/*.spec.ts"] + "include": ["src/**/*", "src/*"], + "exclude": ["node_modules", "**/*.spec.ts"], + "references": [ + { + "path": "../squiggle-lang" + } + ] } diff --git a/packages/components/webpack.config.js b/packages/components/webpack.config.js index 13300a58..5c0cbb7b 100644 --- a/packages/components/webpack.config.js +++ b/packages/components/webpack.config.js @@ -8,13 +8,17 @@ module.exports = { rules: [ { test: /\.tsx?$/, - use: "ts-loader", + loader: "ts-loader", + options: { projectReferences: true }, exclude: /node_modules/, }, ], }, resolve: { extensions: [".js", ".tsx", ".ts"], + alias: { + "@quri/squiggle-lang": path.resolve(__dirname, '../squiggle-lang/src/js') + }, }, output: { filename: "bundle.js", diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index ecddbd96..3b97c854 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -4,7 +4,7 @@ "homepage": "https://squiggle-language.com", "scripts": { "build": "rescript build -with-deps", - "bundle": "tsc && webpack", + "bundle": "webpack", "start": "rescript build -w -with-deps", "clean": "rescript clean", "test": "jest", diff --git a/packages/squiggle-lang/tsconfig.json b/packages/squiggle-lang/tsconfig.json index 63f896f0..2f41e5e1 100644 --- a/packages/squiggle-lang/tsconfig.json +++ b/packages/squiggle-lang/tsconfig.json @@ -9,7 +9,8 @@ "sourceMap": true, "outDir": "./dist", "declarationDir": "./dist", - "declaration": true + "declaration": true, + "composite": true }, "target": "ES6", "include": ["src/**/*"],