-
-
Notifications
You must be signed in to change notification settings - Fork 110
Description
Describe the bug
Unable to build an application using a using a generated solid library, as the vite.config.ts and project.json are written as an application config; not a library.
To Reproduce
npx create-nx-workspace --preset=apps solid-test
cd solid-test
npm i @nxext/solid
nx g @nxext/solid:application apps/app-web
nx g @nxext/solid:lib libs/lib-app-web
nx g @nxext/solid:component hello --project lib-app-webimport { Hello } from "@solid-test/lib-app-web"; in apps/app-web/src/App.tsx and place it in the app layout.
Manually resolve #1061 #1161 and #1162
nx serve app-web
See the app runs,
nx build app-web
see the build fail
> nx run lib-app-web:build:production
vite v5.4.11 building for production...
✓ 0 modules transformed.
x Build failed in 8ms
NX Could not resolve entry module "libs/lib-app-web/index.html".
Pass --verbose to see the stacktrace.
Expected behavior
Build should work.
Additional context
Looking at what happens with the @nx/react generators for libraries, I believe there are a few things needing tweaking but most important of them is that the vite.config.ts and project.json should probably not have the build targets in it.
$ git diff
diff --git a/libs/lib-app-web/project.json b/libs/lib-app-web/project.json
index ed3173b..510b303 100644
--- a/libs/lib-app-web/project.json
+++ b/libs/lib-app-web/project.json
@@ -17,22 +17,6 @@
"options": {
"jestConfig": "libs/lib-app-web/jest.config.ts"
}
- },
- "build": {
- "executor": "@nx/vite:build",
- "outputs": ["{options.outputPath}"],
- "defaultConfiguration": "production",
- "options": {
- "outputPath": "dist/libs/lib-app-web"
- },
- "configurations": {
- "development": {
- "mode": "development"
- },
- "production": {
- "mode": "production"
- }
- }
}
}
}
diff --git a/libs/lib-app-web/vite.config.ts b/libs/lib-app-web/vite.config.ts
index bae39ff..5aed6e6 100644
--- a/libs/lib-app-web/vite.config.ts
+++ b/libs/lib-app-web/vite.config.ts
@@ -7,25 +7,9 @@ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/libs/lib-app-web',
- server: {
- port: 4200,
- host: 'localhost',
- },
- preview: {
- port: 4300,
- host: 'localhost',
- },
plugins: [solidPlugin(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],
// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },
- build: {
- outDir: '../../dist/libs/lib-app-web',
- emptyOutDir: true,
- reportCompressedSize: true,
- commonjsOptions: {
- transformMixedEsModules: true,
- },
- },
});This is a bit closer to the generated vite.config for the react project; and this builds successfully. and nx run app-web:preview runs successfully
$ nx build app-web
> nx run app-web:build:production
vite v5.4.11 building for production...
✓ 11 modules transformed.
../../dist/apps/app-web/index.html 0.60 kB │ gzip: 0.36 kB
../../dist/apps/app-web/assets/index-kNDHXHrP.css 0.71 kB │ gzip: 0.47 kB
../../dist/apps/app-web/assets/index-k5vfhgCj.js 9.53 kB │ gzip: 3.85 kB
✓ built in 274ms
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
NX Successfully ran target build for project app-web (1s)I suspect there may be other issues with the lint and test setup as well but I haven't looked much into those yet.
I'm concerned I'm now pushing into spam territory with the recent number of bugs on a similar set of entry points into the project so I will avoid opening any more issues related to "solid project generation". I'm wondering if #1061 #1161 #1162 and this one should be addressed in one PR since they're kind of all contributing blocks to the process of new project setup and build?