Webpack renames variables in imports



  • It's a problem.

    tab.js contains such data:

    let qwerty = 'qwerty'
    

    scripts.js contains:

    'use strict';
    import 'tab.js'
    

    console.log('qwerty', qwerty);

    As a result, a mistake is made on the page:

    Uncaught ReferenceError: qwerty is not defined

    I looked in a computerized file and I see it:

    'use strict';
    let tab_qwerty = 'qwerty';
    console.log('qwerty', qwerty);

    Renamed the variable qwerty Total tab_qwertyso the variable that I want is inaccessible.
    How do you think?



  • In fact, three articles had to be very careful. https://learn.javascript.ru/modules

    tab.js

    export let qwerty = 'qwerty'
    

    scripts.js

    import {qwerty} from 'tab.js'
    

    Thank andreymal



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2