0

I have some files app.js

import $ from 'jquery';
// export for others scripts to use
window.$ = window.jQuery = $;
import personnal from './assets/js/personnal';
import {cube,machin} from './assets/js/exporting';


$( document ).ready(function() {
    $("div#testok").css({"border":"5px solid black"});

});

In the app.js file jquery working but in my custom file "personnal.js" jquery is undefined

$( document ).ready(function() {
    console.log($('div#testok'));

});
console.log('loading personnal');

I use yarn,

{
  "name": "yarnes6",
  "version": "1.0.0",
  "main": "app.js",
  "license": "MIT",
  "browserify": {
    "transform": [
      [
        "babelify",
        {
          "presets": [
            "es2015"
          ]
        }
      ]
    ]
  },
  "scripts": {
    "build": "browserify app.js -o dist/bundle.js",
    "watch": "watchify app.js -o dist/bundle.js -v"
  },
  "dependencies": {
    "browserify": "^16.2.3",
    "jquery": "^3.4.1",
    "reading-time": "^1.2.0",
    "watchify": "^3.11.1"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-preset-es2015": "^6.24.1",
    "babelify": "^8"
  }
}

It's not possible to use jquery directly on my personnal file? what is the method?

3
  • Your script personnal.js might run before the app.js file Commented Jun 11, 2019 at 10:10
  • before app.js jquery not loading.There must be a possibility to add the whole code in app.js using importation Commented Jun 11, 2019 at 10:20
  • This ok for me, stackoverflow.com/a/39820703/7851271 problem build with es6 et commonJS this solve Commented Jun 11, 2019 at 10:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.