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

Yak shaving the build with the latest yarn version #48

Merged
merged 8 commits into from
Feb 11, 2024
Merged
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
13 changes: 8 additions & 5 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Enable Corepack
run: corepack enable

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
version: '20.x'
cache: 'yarn'

- name: Yarn install
run: yarn install --frozen-lockfile
- name: Yarn Install
run: 'yarn install --frozen-lockfile'

- name: Run Prettier
run: 'yarn run prettier --check .'
run: 'yarn run prettier --check --fail-on-errors .'
1 change: 1 addition & 0 deletions .github/workflows/standardrb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Enable Corepack
run: corepack enable

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.gem
*.key
*.metafile.json
.containers.yml
.yarn
/.bundle/
/doc/
/log/*.log /node_modules
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ tzdata

RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get -y --no-install-recommends install nodejs && \
npm install -g npm@latest yarn
corepack enable && \
yarn set version stable

RUN apt-get clean
RUN gem update --system && gem install bundler
Expand Down
42 changes: 42 additions & 0 deletions bin/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as esbuild from 'esbuild'
import fs from 'fs'

const debug = process.argv.includes('--debug')

const context = await esbuild.context({
entryPoints: ['app/javascript/index.js'],
external: ['@hotwired/turbo'],
bundle: true,
format: 'esm',
logLevel: 'debug',
metafile: true,
minify: !debug,
outfile: 'app/assets/builds/@turbo-boost/streams.js',
sourcemap: true,
target: ['chrome79', 'edge44', 'es2020', 'firefox71', 'opera65', 'safari13']
})

const watch = process.argv.includes('--watch')

if (watch) {
context.logLevel = 'verbose'
await context.watch()
} else {
const result = await context.rebuild()
const metafile = 'app/assets/builds/@turbo-boost/streams.metafile.json'

fs.writeFile(metafile, JSON.stringify(result.metafile), ex => {
if (ex) {
console.error('Build failed!❗️')
conosle.error(ex)
} else {
const message = [
'Build succeeded! 🚀',
`|- Metafile saved to ... → ${metafile}`,
'|- Analyze the bundle at → https://esbuild.github.io/analyze/'
]
console.log(message.join('\n'))
}
context.dispose()
})
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
esbuild:
<<: *default_app
container_name: turbo_boost-streams-esbuild
command: /bin/bash -c "yarn && yarn build:watch"
command: /bin/bash -c "yarn build:watch"
depends_on:
web:
condition: service_healthy
Expand Down
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,34 @@
],
"main": "streams.js",
"files": [
"app/assets/builds/@turbo-boost/streams.js",
"app/assets/builds/@turbo-boost/streams.js.map"
"app/assets/builds/@turbo-boost/**/*{.js,.map}"
],
"repository": "https://github.com/hopsoft/turbo_boost-streams",
"author": "Nate Hopkins (hopsoft) <natehop@gmail.com>",
"license": "MIT",
"dependencies": {
"@alpinejs/morph": ">=3.10.4",
"alpinejs": ">=3.10.4"
"@alpinejs/morph": "^3.13.5",
"alpinejs": "^3.13.5"
},
"peerDependencies": {
"@hotwired/turbo-rails": ">= 7.2.0"
},
"devDependencies": {
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.4",
"@tailwindcss/typography": "^0.5.9",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"esbuild": "^0.20.0",
"eslint": "^8.19.0",
"eslint": "^8.56.0",
"flowbite": "1.5.3",
"playwright": "^1.36.2",
"prettier": "^3.0.0",
"prettier-plugin-tailwindcss": "^0.5.4",
"tailwindcss": "^3.3.3"
"playwright": "^1.41.2",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.1"
},
"scripts": {
"build": "esbuild app/javascript/index.js --bundle --minify --sourcemap --format=esm --target=es2020,chrome79,edge44,firefox71,opera65,safari13 --analyze --outfile=app/assets/builds/@turbo-boost/streams.js",
"build:watch": "yarn build -- --watch"
}
"build": "bin/standardize && node bin/build.mjs",
"build:all": "bin/standardize && node bin/build.mjs && rake build",
"build:watch": "yarn build --watch"
},
"packageManager": "yarn@4.1.0"
}
Loading
Loading