Git Product home page Git Product logo

Comments (8)

bashmish avatar bashmish commented on July 23, 2024

Is this just confusing code or it's broken too?

It's indeed confusing, but IIRC we process all import.meta.url and add extra URL wrapper to resolve it relatively to the original file location after bundling, where the JS file location often changes, so the extra wrapper is necessary in a general case.

from web.

emosheeep avatar emosheeep commented on July 23, 2024

It's broken in rspack, but I think of it as a flaw of rspack after your explanation, I have filed an issue to their team.

from web.

bashmish avatar bashmish commented on July 23, 2024

Oh, actually, I just looked once more at the screenshot. After bundling the wrapper should contain the original file name, and not just import.meta.url twice, e.g. smth like this - a rewritten example from my app bundle, but should be clear I think:

new URL("./../../../assets/images/",new URL("./node_modules/path/to/my/original/file.js",import.meta.url).href).href;

Looks like smth is not working correctly in Vite.
Maybe our plugin is not Vite compatible, not sure if anyone ever tested it with it.
IIRC, Vite plugins are an extension of rollup API and should be working fine with most of rollup plugins, but I can imagine it's not always guaranteed.

from web.

emosheeep avatar emosheeep commented on July 23, 2024

emm, actually the output result is working fine in webpack where the double URL would be replaced with the real path. 🤔🤔

from web.

bashmish avatar bashmish commented on July 23, 2024

emm, actually the output result is working fine in webpack where the double URL would be replaced with the real path. 🤔🤔

if it's working, then probably your JS files remain on the same location in the folder structure, otherwise won't work, but if so, you might not need this plugin, I think the main goal of it is to be able to bundle JS and extract assets

on a different note: why do you need this plugin in Vite? I think Vite has it's own assets handling guidelines?

from web.

emosheeep avatar emosheeep commented on July 23, 2024

in vite's library mode,all assets will be inlined,which causes a long time cost.unfortunately It doesn't support to extract assets now...

from web.

bergwerf avatar bergwerf commented on July 23, 2024

Pure Rollup gives me:

const program_path = new URL(new URL('asset/program.wasm', import.meta.url).href, import.meta.url);

The second URL constructor looks pointless to me.

from web.

emosheeep avatar emosheeep commented on July 23, 2024

Pure Rollup gives me:

const program_path = new URL(new URL('asset/program.wasm', import.meta.url).href, import.meta.url);

The second URL constructor looks pointless to me.
Does it mean you can remove the double wrap?🤔

from web.

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.