{"id":25355,"library":"esbuild-plugin-import-assertions","title":"esbuild import assertions plugin","description":"A plugin for esbuild that enables import assertion syntax (e.g. `import json from './foo.json' assert { type: 'json' }`) in your builds. Current stable version is 1.0.1. This plugin adds the ability to use the TC39 proposal for import assertions, which esbuild does not natively support. It works only with synchronous imports and requires `bundle: true`. Key differentiator: it fills a gap for users who need import assertions without switching to a different bundler like Webpack or Rollup.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","esbuild","import","import-assertions","import-assert","plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-import-assertions","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-import-assertions","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-import-assertions","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a named export, not a default. CommonJS require will not work as the package is ESM-only. Use dynamic import() if needed in CJS.","wrong":"const { importAssertPlugin } = require('esbuild-plugin-import-assertions')","symbol":"importAssertPlugin","correct":"import { importAssertPlugin } from 'esbuild-plugin-import-assertions'"},{"note":"There is no default export. Attempting to import it as default will result in undefined.","wrong":"import importAssertPlugin from 'esbuild-plugin-import-assertions'","symbol":"default export","correct":"Not available. Use named import."}],"quickstart":{"code":"import { importAssertPlugin } from 'esbuild-plugin-import-assertions';\nimport { build } from 'esbuild';\n\nbuild({\n  entryPoints: ['./app.ts'],\n  bundle: true,\n  outfile: './lib/out.js',\n  plugins: [importAssertPlugin],\n  target: ['chrome100']\n}).catch(() => process.exit(1));","lang":"typescript","description":"Demonstrates basic esbuild build with the import assertions plugin, requiring bundle: true."},"warnings":[{"fix":"Rewrite dynamic import() calls with assertions as static imports if possible, or use an alternative approach.","message":"Asynchronous imports are not supported. Only static import statements with assertions will be handled.","severity":"gotcha","affected_versions":"*"},{"fix":"Set 'bundle: true' in the esbuild options.","message":"The plugin requires that esbuild's 'bundle' option is set to true. Without it, the plugin will not transform imports.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import() or change the project to ESM (type: 'module' in package.json).","cause":"Attempting to require the package in a CommonJS environment without using dynamic import.","error":"Error: The package \"esbuild-plugin-import-assertions\" is not a CommonJS module, use dynamic import() instead."},{"fix":"Use named import: import { importAssertPlugin } from 'esbuild-plugin-import-assertions';","cause":"Importing the default export instead of the named export 'importAssertPlugin'.","error":"TypeError: importAssertPlugin is not a function"},{"fix":"Convert to static import statements.","cause":"Using dynamic import() with import assertions, which the plugin does not support.","error":"Error: Import assertions are not supported with dynamic imports"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}