{"id":22521,"library":"unplugin-obj","title":"unplugin-obj","description":"Import .obj files as strings in Vite, Rollup, Webpack, and more. Version 0.1.2 is the latest stable release. Built on the unplugin framework, it provides seamless integration across multiple build tools with a unified API. The plugin converts .obj files to raw text, enabling use with three.js or custom parsers. It includes TypeScript type declarations and supports SvelteKit, Nuxt, and Vue CLI. Compared to alternatives like raw-loader or asset modules, it offers framework-agnostic zero-config setup and consistent import syntax across bundlers.","status":"active","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/tonyketcham/unplugin-obj","tags":["javascript","unplugin","vite","webpack","rollup","transform","three.js","svelte-cubed","obj","typescript"],"install":[{"cmd":"npm install unplugin-obj","lang":"bash","label":"npm"},{"cmd":"yarn add unplugin-obj","lang":"bash","label":"yarn"},{"cmd":"pnpm add unplugin-obj","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import returns the obj file content as a string. Requires the plugin to be added to your build tool configuration.","wrong":"const obj = require('./model.obj');","symbol":"default","correct":"import obj from './model.obj';"},{"note":"Must import from the tool-specific subpath: /vite, /rollup, /webpack, or /nuxt. Default export from root is not available.","wrong":"import ObjFileImport from 'unplugin-obj';","symbol":"ObjFileImport (plugin factory)","correct":"import ObjFileImport from 'unplugin-obj/vite';"},{"note":"Type declarations are in the 'obj' subpath. Add to a .d.ts file or tsconfig.json types array.","wrong":"/// <reference types=\"unplugin-obj\" />","symbol":"Type reference","correct":"/// <reference types=\"unplugin-obj/obj\" />"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport ObjFileImport from 'unplugin-obj/vite';\n\nexport default defineConfig({\n  plugins: [ObjFileImport()],\n});\n\n// App.ts\nimport obj from './models/Lowpoly_tree_sample.obj';\n\nconsole.log(obj); // outputs the OBJ file content as a string\n\n// Optionally parse with three.js:\n// import { parseOBJ } from 'three/addons/loaders/OBJLoader.js';\n// console.log(parseOBJ(obj));","lang":"typescript","description":"Shows Vite configuration with unplugin-obj and importing an .obj file as a string."},"warnings":[{"fix":"Add type declarations via 'unplugin-obj/obj' in tsconfig.json or a reference directive.","message":"TypeScript and ESLint may complain about non-existent .obj modules before the plugin is configured.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use correct import: import ObjFileImport from 'unplugin-obj/vite';","message":"The plugin must be imported from a tool-specific subpath (e.g., 'unplugin-obj/vite'), not the package root.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use const ObjFileImport = require('unplugin-obj/webpack');","message":"Webpack users must use require() for the plugin in webpack.config.js if using CommonJS.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Pin exact version and test updates carefully.","message":"Version 0.x may introduce breaking changes without notice; no stable release yet.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add 'unplugin-obj/obj' to tsconfig.json types array or add a .d.ts file with /// <reference types=\"unplugin-obj/obj\" />.","cause":"Missing type declarations for .obj files or incorrect import path.","error":"Cannot find module 'unplugin-obj' or its corresponding type declarations."},{"fix":"Change import to e.g. import ObjFileImport from 'unplugin-obj/vite';","cause":"Importing from the package root instead of the tool-specific subpath.","error":"Error: The plugin 'unplugin-obj' doesn't provide a default export."},{"fix":"Add type declarations for .obj files (see above).","cause":"TypeScript does not recognize .obj imports without type declarations.","error":"TypeScript error: Cannot find module './model.obj' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}