Code Monkey home page Code Monkey logo

Comments (9)

TivoSoho avatar TivoSoho commented on June 11, 2024 1

Thank you. It is indeed our own configuration issue and I aplogize. We had: condition "include: **/*.js" to make sure it is only injected into JS files (it tries to insert into scss otherwise), however that mapping doesn't work with node_modules then and was then not injecting it properly. Will adjust it accordingly

from jqtree.

TivoSoho avatar TivoSoho commented on June 11, 2024

Or rather, even a proper wrapper fixed it for me (copied from a library that works with vite command):

;(function ($, window, document, undefined) {
...
})( jQuery, window, document );

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

I'll have look

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

I tried to use Vite js with jqTree and it works. See https://github.com/mbraak/vite-jqtree-demo

I didn't make any changes to jqTree.

from jqtree.

TivoSoho avatar TivoSoho commented on June 11, 2024

Unfortunately I must re-open this case. It seemed to work since I was probably only testing it in development mode, which it did not work before due to my own error (previous error was about missing jquery). However, if I run vite build/npm run build, then it throws error about "require is not defined":

app-d21daea4.js:15 Uncaught ReferenceError: require is not defined
    at app-d21daea4.js:15:15490
    at app-d21daea4.js:1:23
    at app-d21daea4.js:17:17925
...
    Yt.JqTreeWidget = void 0;
    var Bs = Me(require("./version")) <-

If I run vite/npm run dev then it works.

I am made a sample barebone Laravel project: https://github.com/TivoSoho/laravel-jqtree There is essentially nothing there, but we use it in laravel context in case it matters. This is the config:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import inject from "@rollup/plugin-inject";

export default defineConfig({
    plugins: [
        inject({
            $: 'jquery',
            jQuery: 'jquery',
        }),
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
});

and this is the app.js:

import './bootstrap';
import $ from 'jquery';

window.$ = $;
window.jQuery = $;

import 'jqtree';

Any suggestions as to what I might be doing wrong, what is missing for it to work?

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

I made a branch in the jqtree repository with a fix: #739

In my vite project I changed the jqtree dependency to:

"jqtree": "https://github.com/mbraak/jqTree.git#change-bundle-in-package"

Can you check if this works for you? It works in my test project.

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

The fix is included the latest release

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

There is still an issue when the jquery versions are different. I'm working on a pr.

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

The issue with the different jquery versions is fixed in version 1.7.3

from jqtree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.