Skip to content

Commit

Permalink
Move resources to web which leads to bug
Browse files Browse the repository at this point in the history
1. Move several files to `web`.
2. Update vite config to point to the current location.

```
6:48:53 PM [vite] Internal server error: Failed to resolve import "react" from "../target/scala-3.2.2/livechart-fastopt/livechart.LiveChart$package$.js". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/brunohenriques/workspace/issue-rd-scalajs-sbt-vite-laminar-chartjs-example/target/scala-3.2.2/livechart-fastopt/livechart.LiveChart$package$.js:3:28
  1  |  'use strict';
  2  |  import * as $i_$002fjavascript$002esvg from "/javascript.svg";
  3  |  import * as $i_react from "react";
     |                             ^
  4  |  import * as $i_react$002ddom$002fclient from "react-dom/client";
  5  |  import * as $j_internal$002d3ebfae0cba70adf981029a0da5b1e4b5ab5d02c6 from "./internal-3ebfae0cba70adf981029a0da5b1e4b5ab5d02c6.js";
```
  • Loading branch information
bphenriques committed Oct 15, 2023
1 parent 6c7b188 commit 33cf7c2
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
web/node_modules

This comment has been minimized.

Copy link
@bphenriques

bphenriques Oct 15, 2023

Author Owner

IntelliJ renamed this out-of-the-blue. No harm but annoying.

dist
dist-ssr
*.local
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Reproduces an issue where vite gets confused where external `node_modules` are.

The project starts from the end of the [ScalaJS vite tutorial](https://www.scala-js.org/doc/tutorial/scalajs-vite.html),
then:
1. Stable: Migrate to Slinky's `main` branch that supports React 18 (previous commit).
2. Buggy: Move several resources to the `web` folder (current commit).

## How to reproduce
Terminal 1:
- Run `sbt "~fastLinkJS"`

- Terminal 2:
- Go to `web`
- Run `npm install`
- Run `npm run dev`

## Workaround

While it is running with the bug, run the following at the root:
```
cp -r web/node_modules .
```
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
4 changes: 3 additions & 1 deletion vite.config.js → web/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import { defineConfig } from "vite";
import scalaJSPlugin from "@scala-js/vite-plugin-scalajs";

export default defineConfig({
plugins: [scalaJSPlugin()],
plugins: [scalaJSPlugin({
cwd: '..',
})],
});

0 comments on commit 33cf7c2

Please sign in to comment.