Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three-Inspect not working by ImportMap ... Package on JSDelivr says: "Failed to bundle using Rollup v2.79.1: failed to resolve an internal import." Any ideas? #38

Open
jonmdev opened this issue Jul 3, 2024 · 0 comments

Comments

@jonmdev
Copy link

jonmdev commented Jul 3, 2024

I am continuing to need to rely on this package to help me inspect my plain JS Three-JS projects. As noted in the prior thread with 0.5.0 it now works in NPX Vite. However, it still does not work by ImportMap.

To demonstrate I created a simple project you can see here:

https://github.com/jonmdev/inspectorbug

This was made just by copying and pasting in the standard new project configuration here: https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene

Then installing in command prompt:

npm install --save three
npm install --save-dev vite
npm i --save three-inspect

The code to add the Inspector in main.js is:

import { createInspector } from 'three-inspect/vanilla'
function addInspector(){
	document.body.append(renderer.domElement);
        renderer.domElement.style = `
                width: 100%;
                height: 100%;
                position: absolute;
        `;
        createInspector(document.body, {
                scene,
                camera,
         	renderer,
        });
}

addInspector();

If you do this, and run NPX Vite, then enter O, you get the following scene - spinning default cube with inspector overtop:

simple inspector

This allows you to quickly manipulate and test hierarchies, colors, positions, and is very handy for seeing what is or isn't working in a project.

Problem

However, if we instead try to run it off ImportMap (for example by opening in Visual Studio Code, adding the "LiveServer" addon, and clicking its icon in the bottom right) with the following in index.html:

<script type="importmap">
		  {
		    "imports": {
		      	"three": "https://cdn.jsdelivr.net/npm/three@v0.163.0/build/three.module.js",
			"three/addons/": "https://cdn.jsdelivr.net/npm/three@v0.163.0/examples/jsm/",
			"three-inspect/vanilla": "https://cdn.jsdelivr.net/npm/three-inspect@0.5.0/+esm"
		    }
		  }
		</script>

This does not work. It gives the error **Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/three-inspect@0.5.0/+esm' doesn't provide an export named: 'createInspector'**

Do you know why this might be happening? Why would it work perfectly by Vite but not ImportMap?

Issue?

I notice if I go directly in my browser to:

which are working packages they show nice clear pages there that look appropriate. But if I go to:

I get:

So is this then the problem? Is the package on there broken somehow or not generated correctly? If so any chance of a fix? Thanks again.

@michealparks

@jonmdev jonmdev changed the title Three-Inspect not working by ImportMap ... Any ideas? Three-Inspect not working by ImportMap ... Package on JSDelivr says: "Failed to bundle using Rollup v2.79.1: failed to resolve an internal import." Any ideas? Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant