The tests for the `init` package were failing with a `PermissionDenied`
error in Jules container environment when creating temporary
directories. This was because the tests were attempting to create the
temporary directories in the root of the project, where permissions are
often restricted.
This change corrects the issue by removing the local `withTmpDir` helper
function in `packages/init/src/init_test.ts` and instead using the one
from `../../fresh/src/test_utils.ts`. The shared helper function
correctly creates temporary directories in the operating system's
default temporary directory, which resolves the permission issue.
Sample error message from Jules before this fix:
```
ERRORS
init - new project => ./packages/init/src/init_test.ts:99:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:100:27
init - create project dir => ./packages/init/src/init_test.ts:107:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:108:21
init - with tailwind => ./packages/init/src/init_test.ts:122:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:123:27
init - with vscode => ./packages/init/src/init_test.ts:140:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:141:21
init - fmt, lint, and type check project => ./packages/init/src/init_test.ts:153:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async fn (file:///app/packages/init/src/init_test.ts:159:23)
init with tailwind - fmt, lint, and type check project => ./packages/init/src/init_test.ts:179:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:182:23
init - can start dev server => ./packages/init/src/init_test.ts:205:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async fn (file:///app/packages/init/src/init_test.ts:211:23)
init - can start built project => ./packages/init/src/init_test.ts:233:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:234:21
init - errors on missing build cache in prod => ./packages/init/src/init_test.ts:265:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:266:27
init - with vite => ./packages/init/src/init_test.ts:348:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:349:27
FAILURES
init - new project => ./packages/init/src/init_test.ts:99:6
init - create project dir => ./packages/init/src/init_test.ts:107:6
init - with tailwind => ./packages/init/src/init_test.ts:122:6
init - with vscode => ./packages/init/src/init_test.ts:140:6
init - fmt, lint, and type check project => ./packages/init/src/init_test.ts:153:6
init with tailwind - fmt, lint, and type check project => ./packages/init/src/init_test.ts:179:6
init - can start dev server => ./packages/init/src/init_test.ts:205:6
init - can start built project => ./packages/init/src/init_test.ts:233:6
init - errors on missing build cache in prod => ./packages/init/src/init_test.ts:265:6
init - with vite => ./packages/init/src/init_test.ts:348:6
FAILED | 449 passed (14 steps) | 10 failed | 17 ignored (2m38s)
```
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Vite has an internal check that limits CommonJS detection to only bare
specifier. This doesn't work well together with us resolving npm modules
to absolute file paths.
https://github.com/vitejs/vite/blob/main/packages/vite/src/node/ssr/fetchModule.ts#L46
I've tried re-using our own instance of `@rollup/plugin-commonjs` or
`esbuild` but couldn't get these to work in that setup. The easiest way
seems to be to just write our own CJS -> ESM translation layer.
With a little luck since the Deno ecosystem is heavy into ESM we might
get away with this. In either way this removes one of the two blockers
to using the vite plugin.
We're having a growing number of packages in this repository. This PR
moves them into a `packages/` directory like it's commonly done in other
projects.
This PR adds a vite plugin for Fresh. This enables:
- HMR (only for islands for now)
- self-contained output bundles for both server and client
- smarter chunking
It uses vite's new Environment API under the hood.
update /www and tailwind-plugin to support tailwind v4.
Thanks to the merge of #3034, the work of integrating and advancing
#2903 is promoted.
related #3034
related #2903close#3056close#2819
--patch-1
based on review,
1. del compiler and make it more clean and simple,
2. fix init tailwind part,
3. fix test tailwind part
--patch-2
1. fix the docs
2. fix the docs of plugin and version
--patch-3
1. Addressed various maintenance tasks (chores)
2. Updated the Tailwind CSS plugin to align with this release. Generated
a fresh project using the updated init configuration and
3. deployed it via Deno Deploy EA. Deployment is functioning correctly.
--patch-4
Move postcss imports to Tailwind section in init script
--patch-5
Refactored Tailwind plugin type definitions by copying PluginOptions
properties from @tailwindcss/postcss and adding Fresh-specific exclude
option, while exporting types from package entrypoint for better
accessibility.
Test Project: https://fresh.fresh-press.deno.net/
Test Project Repository:
https://github.com/SisyphusZheng/fresh-tailwindv4
Test Plugin: https://jsr.io/@freshpress/fresh-plugin-tailwind@1.0.0
---------
Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
Previously, all packages except `@fresh/core` and even some tests
might've imported `jsr:@fresh/core@^2.0.0-alpha.29` rather than the
latest version of Fresh. This PR fixes that.