Unable to create web-components by using vue-cli and vue3 - web-component

I am trying to get web-components work inside vue3 project.
I did following steps. (Try to make super simple way)
I made a new project on vue-cli.
I chose vue3 preview.
After that I tried to execute script, which should generate web-components from existing project components.
vue-cli-service build --target wc-async 'src/components/*.vue'
I get following error:
error in ./src/components/HelloWorld.vue?vue&type=template&id=0dfd15f1&bindings={"label":"props"}?shadow
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
Unexpected token ? in JSON at position 17
at JSON.parse (<anonymous>)
at Object.TemplateLoader (C:\git\vue-tests\footest\node_modules\vue-loader-v16\dist\templateLoader.js:37:154)
# ./src/components/HelloWorld.vue?vue&type=template&id=0dfd15f1&bindings={"label":"props"}?shadow 1:0-424 1:0-424
# ./src/components/HelloWorld.vue?shadow
# ./node_modules/#vue/cli-service/lib/commands/build/entry-wc.js
I tested this scenario with vue2 starting template and everything works. Is there something what I dont understand correctly or is it so that this is not working with vue3.

Related

Adding dependencies to the "ui" package of a Turborepo with Next.js throws Unexpected token 'export'

If you run
npx degit vercel/turbo/examples/with-react-native-web with-react-native-web
cd with-react-native-web
yarn install
To create a basic Turborepo that has a Nextjs application, a react-native mobile app with Expo and a ui package to share components between apps (there is a Button as an example already shared between the two apps), it works. But my ui package needs other dependencies, for example:
#fortawesome/fontawesome-svg-core,
#fortawesome/free-solid-svg-icons,
#fortawesome/react-native-fontawesome,
This is because the buttons that I want to render icons on my buttons. Once I install this dependency and try to use the button that has an icon, the Next.js app throws:
Unexpected token 'export'.
I understand this is because #fortawesome/react-native-fontawesome is using import/export syntax and needs to be transpiled to be used on the Next.js app, and I cannot make it work. I am trying to do this by adding this to my next.config.js:
transpilePackages: ['ui'],
I also tried using next-transpile-modules which i don't think is the right solution since next now supports what that package used to be for through transpilePackages
I also tried to specify that the ui package was "type": "module" but still, I am getting the same error.
How can you specify that those dependencies that belong to the ui package must be transpiled to be run by the browser?
I have checked the package #fortawesome/react-native-fontawesome
package.json of #fortawesome/react-native-fontawesome does not contain field "type": "module" but index.js contains:
export { default as FontAwesomeIcon } from './dist/components/FontAwesomeIcon'
therefore Next handles #fortawesome/react-native-fontawesome as non-ES module but this module contains export statement.
You mentioned transpilePackages field in next.config.js, so I think it may help with this issue (but pls check version of Next where transpilePackages appeared).

Using Azure static web app with a Quasar Project

I thought it would be pretty simple to host a vuejs quasar project in azure static web apps but I cannot even seem to do the build process from github to publish the website. I can do quasar dev and quasar serve locally and all works great. It is just the assets do not seem to load and trigger a build error for pushing to github/azure. My error comes out as follows:
[vite:asset] Could not load /github/workspace/src/assets/imgs/12.jpg (imported by src/components/HomeRecentWork.vue): ENOENT: no such file or directory, open '/github/workspace/src/assets/imgs/12.jpg'
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: Could not load /github/workspace/src/assets/imgs/12.jpg (imported by src/components/HomeRecentWork.vue): ENOENT: no such file or directory, open '/github/workspace/src/assets/imgs/12.jpg'] {
errno: -2,
code: 'PLUGIN_ERROR',
syscall: 'open',
path: '/github/workspace/src/assets/imgs/12.jpg',
pluginCode: 'ENOENT',
plugin: 'vite:asset',
hook: 'load',
watchFiles: [
'/github/workspace/index.html',
'/github/workspace/.quasar/client-entry.js',
'/github/workspace/node_modules/vite/package.json',
'/github/workspace/node_modules/vue/package.json',
'/github/workspace/node_modules/#quasar/extras/package.json',
'/github/workspace/node_modules/quasar/package.json',
'/github/workspace/node_modules/vue/dist/vue.runtime.esm-bundler.js',
'/github/workspace/node_modules/#quasar/extras/fontawesome-v6/fontawesome-v6.css',
'/github/workspace/node_modules/#quasar/extras/roboto-font/roboto-font.css',
'/github/workspace/node_modules/#quasar/extras/material-icons/material-icons.css',
'/github/workspace/node_modules/quasar/dist/quasar.sass',
'/github/workspace/.quasar/app.js',
'/github/workspace/.quasar/quasar-user-options.js',
'/github/workspace/src/css/app.scss',
'/github/workspace/src/boot/axios.js',
'vite/preload-helper',
'/github/workspace/node_modules/#vue/runtime-dom/package.json',
'/github/workspace/node_modules/#vue/runtime-dom/dist/runtime-dom.esm-bundler.js',
'/github/workspace/node_modules/quasar/src/vue-plugin.js',
'/github/workspace/src/App.vue',
'/github/workspace/src/stores/index.js',
'/github/workspace/src/router/index.js',
'/github/workspace/node_modules/quasar/src/plugins/Meta.js',
'/github/workspace/node_modules/quasar/src/plugins/Notify.js',
'/github/workspace/node_modules/axios/package.json',
'/github/workspace/node_modules/quasar/wrappers/index.mjs',
'/github/workspace/node_modules/axios/index.js',
'/github/workspace/node_modules/#vue/runtime-core/package.json',
'/github/workspace/node_modules/#vue/shared/package.json',
'/github/workspace/node_modules/#vue/runtime-core/dist/runtime-core.esm-bundler.js',
'/github/workspace/node_modules/#vue/shared/dist/shared.esm-bundler.js',
'/github/workspace/node_modules/quasar/src/install-quasar.js',
'/github/workspace/node_modules/quasar/src/lang.js',
'/github/workspace/node_modules/quasar/src/icon-set.js',
'plugin-vue:export-helper',
'/github/workspace/node_modules/pinia/package.json',
'/github/workspace/node_modules/pinia/dist/pinia.mjs',
'/github/workspace/node_modules/vue-router/package.json',
'/github/workspace/node_modules/vue-router/dist/vue-router.mjs',
'/github/workspace/src/router/routes.js',
'/github/workspace/node_modules/quasar/src/plugins/Platform.js',
'/github/workspace/node_modules/quasar/src/utils/extend.js',
'/github/workspace/node_modules/quasar/src/components/avatar/QAvatar.js',
'/github/workspace/node_modules/quasar/src/components/icon/QIcon.js',
'/github/workspace/node_modules/quasar/src/components/btn/QBtn.js',
'/github/workspace/node_modules/quasar/src/components/spinner/QSpinner.js',
'/github/workspace/node_modules/quasar/src/utils/private/create.js',
'/github/workspace/node_modules/quasar/src/utils/event.js',
'/github/workspace/node_modules/quasar/src/utils/private/global-nodes.js',
'/github/workspace/node_modules/quasar/src/utils/is.js',
'\x00commonjsHelpers.js',
'/github/workspace/node_modules/axios/lib/axios.js',
'\x00/github/workspace/node_modules/axios/lib/axios.js?commonjs-proxy',
'/github/workspace/node_modules/#vue/reactivity/package.json',
'/github/workspace/node_modules/#vue/reactivity/dist/reactivity.esm-bundler.js',
'/github/workspace/node_modules/quasar/src/plugins/Screen.js',
'/github/workspace/node_modules/quasar/src/plugins/Dark.js',
'/github/workspace/node_modules/quasar/src/history.js',
'/github/workspace/node_modules/quasar/src/body.js',
'/github/workspace/node_modules/quasar/src/utils/private/symbols.js',
'/github/workspace/node_modules/quasar/src/utils/private/global-config.js',
'/github/workspace/node_modules/quasar/src/utils/private/define-reactive-plugin.js',
'/github/workspace/node_modules/quasar/lang/en-US.mjs',
'/github/workspace/node_modules/quasar/src/utils/private/inject-obj-prop.js',
'/github/workspace/node_modules/quasar/icon-set/material-icons.mjs',
'/github/workspace/node_modules/vue-demi/package.json',
'/github/workspace/node_modules/#vue/devtools-api/package.json',
'/github/workspace/node_modules/vue-demi/lib/index.mjs',
'/github/workspace/node_modules/#vue/devtools-api/lib/esm/index.js',
'/github/workspace/src/layouts/MainLayout.vue',
'/github/workspace/src/pages/IndexPage.vue',
'/github/workspace/src/pages/ErrorNotFound.vue',
'/github/workspace/node_modules/quasar/src/composables/private/use-size.js',
'/github/workspace/node_modules/quasar/src/utils/private/render.js',
'/github/workspace/node_modules/quasar/src/directives/Ripple.js',
'/github/workspace/node_modules/quasar/src/components/btn/use-btn.js',
'/github/workspace/node_modules/quasar/src/utils/private/key-composition.js',
'/github/workspace/node_modules/quasar/src/components/spinner/use-spinner.js',
'\x00/github/workspace/node_modules/axios/lib/axios.js?commonjs-module',
'/github/workspace/node_modules/axios/lib/utils.js',
'\x00/github/workspace/node_modules/axios/lib/utils.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/helpers/bind.js',
'\x00/github/workspace/node_modules/axios/lib/helpers/bind.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/core/Axios.js',
'\x00/github/workspace/node_modules/axios/lib/core/Axios.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/core/mergeConfig.js',
'\x00/github/workspace/node_modules/axios/lib/core/mergeConfig.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/defaults.js',
'\x00/github/workspace/node_modules/axios/lib/defaults.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/cancel/Cancel.js',
'\x00/github/workspace/node_modules/axios/lib/cancel/Cancel.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/cancel/CancelToken.js',
'\x00/github/workspace/node_modules/axios/lib/cancel/CancelToken.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/cancel/isCancel.js',
'\x00/github/workspace/node_modules/axios/lib/cancel/isCancel.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/helpers/spread.js',
'\x00/github/workspace/node_modules/axios/lib/helpers/spread.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/helpers/isAxiosError.js',
'\x00/github/workspace/node_modules/axios/lib/helpers/isAxiosError.js?commonjs-proxy',
'/github/workspace/node_modules/quasar/src/utils/debounce.js',
... 128 more items
]
}
Node.js v18.12.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
---End of Oryx build logs---
Oryx has failed to build the solution.
I have not found much info on doing a quasar project inside azure web apps so any advice would be helpful. All the tutorials I have found and gone through do not have these issues and I really do not have a complicated project that deviates from the standard quasar project.
EDIT:
the issue is actually my image paths. I am using with src="~assets/imgs/embroidery.jpg" where ~ must be an alias setup in quasar. Works for components in quasar but not for raw img tags. If i use a relative path like ../assets/imgs/filename.jpg it still draws an error on build. However, if i do /assets/imgs/filename.jpg and put the assets folder in public it works. I dont want to do this however so how should i put the paths for images in my components if not a vue-component per say?

Errors with Material UI AppBar

I am building a student project. I have tried several times to incorporate Material UI into my project but have had no success. For instance, I am attempting to add "App Bar with Menu" linked here. I have installed npm install #mui/material #emotion/react #emotion/styled #material-ui/icons in React, and copied the code exactly from MUI's example into its own component in my project, but am receiving the following errors:
Compiled with problems:
ERROR in ./src/components/MenuAppBar/MenuAppBar.js 12:0-48
Module not found: Error: Can't resolve '#mui/icons-material/Menu' in '/home/michael/flatiron/phase-5/project-template/frontend/src/components/MenuAppBar'
ERROR in ./src/components/MenuAppBar/MenuAppBar.js 13:0-62
Module not found: Error: Can't resolve '#mui/icons-material/AccountCircle' in '/home/michael/flatiron/phase-5/project-template/frontend/src/components/MenuAppBar'
What am I missing? I don't see any documentation on this AppBar that would tell me I have to install something other than what I've installed, and I pulled up three youtube videos which simply show the user copying the code into a component, as I've done.

create-next-app does not work, get internal server error

Need some advice on this. I have initialize a whole new project by using create-next-app:
npx create-next-app nextjs-app
I was able to start the project by calling npm run dev. This is what i have in the terminal when run on the development server:
ready - started server on http://localhost:3000
However, i get internal server error when navigate to localhost:3000. There is this error on the terminal:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
I am running on node v12.16.3 and npm v6.14.4

How to load a QML plugin like a dependency for another QML plugin?

I have 2 QML Plugins: icL.Look and icL.Editor, the second depend by the first. If I exclude the dependency all are working OK. But I need it. So when I run the app I get the next error
qrc:/windows/start-window.qml:5 plugin cannot be loaded for module
"icL.Editor": unable to load library /path/libicLeditorPlugin.so:
(/path/libicLeditorPlugin.so: undefined symbol: _ZN3icL4look5Chars5clineE)
21:52:20: The program has unexpectedly finished.
icL.look.Chars.cline is a static field.
Do you have some idea?

Resources