How do I cache bust imported modules in es6?

后端 未结 7 1033
梦谈多话
梦谈多话 2021-01-31 09:21

ES6 modules allows us to create a single point of entry like so:

7条回答
  •  逝去的感伤
    2021-01-31 09:35

    A solution that crossed my mind but I wont use because I don't like it LOL is

    window.version = `1.0.0`;
    
    let { default: fu } = await import( `./bar.js?v=${ window.version }` );
    

    Using the import "method" allows you to pass in a template literal string. I also added it to window so that it can be easily accessible no matter how deep I'm importing js files. The reason I don't like it though is I have to use "await" which means it has to be wrapped in an async method.

提交回复
热议问题