Registry / web-framework / liferay-npm-bundler-loader-json-loader

liferay-npm-bundler-loader-json-loader

JSON →
library2.32.2jsnpmunverified

The `liferay-npm-bundler-loader-json-loader` package, currently at version 2.32.2, is a specialized build-time loader designed for the Liferay npm bundler ecosystem. Its core function is to transform JSON files into standard JavaScript modules, where the content of the JSON file is directly exported as a parsed JavaScript object. This enables developers to seamlessly integrate and import static JSON data within their Liferay frontend projects. As an integral component of the larger `liferay-frontend-projects` monorepo, its release schedule is aligned with broader Liferay frontend tooling updates, which occur frequently, with several related packages seeing multiple updates annually. This loader's key differentiator is its deep integration with Liferay's specific bundling and module resolution mechanisms, providing a tailored solution for Liferay-based development environments, unlike generic JSON loaders used in other bundlers like Webpack or Rollup.

npm install liferay-npm-bundler-loader-json-loader
INSTALL
IMPORT
SIG · LIFERAY-NPM-BUNDLE
L
liferay-npm-bundler-loader-json-loader
web-frameworkjavascriptv2.32.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

json-loader (config identifier)
// .npmbundlerrc { "rules": [ { "test": "\\.json$", "use": ["json-loader"] } ] }
import jsonLoader from 'liferay-npm-bundler-loader-json-loader';
This package is a `liferay-npm-bundler` loader. It is referenced by its short string name 'json-loader' within the `use` array of build rules in `.npmbundlerrc` files, not through direct JavaScript `import` or `require` statements. Attempting to import it in JS will fail.
(Loader rule configuration)
const bundlerConfig = { "rules": [ { "test": "\\.json$", "use": ["json-loader"] } ] }; // This configuration object is placed directly into .npmbundlerrc
import { configureJsonLoader } from 'liferay-npm-bundler-loader-json-loader'; configureJsonLoader(...);
The loader's functionality is activated by configuring a rule object directly within the `rules` array of the `.npmbundlerrc` file. There are no exposed JavaScript functions for programmatic configuration of this loader.
(Loader invocation)
The `liferay-npm-bundler` automatically applies the configured 'json-loader' when it processes a file matching the 'test' regex (e.g., a '.json' file) during the build process.
require('liferay-npm-bundler-loader-json-loader').runLoader(fileContent);
Developers do not directly call API functions from this package. It operates as a build-time plugin or middleware invoked implicitly by the `liferay-npm-bundler`.

This `.npmbundlerrc` configuration snippet demonstrates how to enable the JSON loader, allowing `.json` files to be imported directly into JavaScript modules within a Liferay project's build process.

{ "rules": [ { "test": "\\.json$", "use": ["json-loader"] } ] } // To use this loader, place the above JSON configuration into your project's .npmbundlerrc file. // Then, in a JavaScript module, you can import JSON files like so: // import myData from './path/to/my-data.json'; // console.log(myData.someProperty);
Debug
Known issues
gotchaThis loader is tightly coupled with the `liferay-npm-bundler` build system. Ensure compatibility between the loader version and your `liferay-npm-bundler` version to avoid unexpected build errors or incorrect module transformations.
fix
Always refer to the official Liferay frontend documentation for recommended versions of core tooling. If issues arise, try updating both the loader and `liferay-npm-bundler` to their latest compatible versions.
affects: >=2.0.0
gotchaThis package is a build-time asset and does not export any JavaScript modules for direct `import` or `require`. Attempting to import it in your runtime code will lead to module resolution errors or undefined behavior.
fix
Do not add `liferay-npm-bundler-loader-json-loader` as a runtime dependency or attempt to import it directly into your application's JavaScript code. It is solely configured via `.npmbundlerrc`.
affects: *
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:1) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
A JSON file was imported into a JavaScript module, but the `liferay-npm-bundler-loader-json-loader` was not correctly configured or enabled in the `.npmbundlerrc` file.
fix
Add or verify the presence of the JSON loader rule in your project's `.npmbundlerrc` file, ensuring the `test` regex matches your JSON files (e.g., `"test": "\\.json$"`).
Error: Cannot find module 'json-loader' in [...].npmbundlerrc
While `json-loader` is the common name used in the configuration, there might be a mismatch in how `liferay-npm-bundler` resolves or registers its internal loaders, or an external `json-loader` package is incorrectly assumed to be necessary.
fix
Ensure `liferay-npm-bundler` is correctly installed. The `json-loader` string in `.npmbundlerrc` refers to this specific Liferay-provided loader, and no separate `npm install json-loader` is typically needed for the Liferay ecosystem.
Upgrade
Version history
2.32.2latest on npm
Audit
Dependencies
liferay-npm-bundlerrequiredThis package functions as a loader for `liferay-npm-bundler` and requires it for operation.
Agent activity
4 hits · last 30 days
node
4
Resources
liferay-npm-bundler-loader-json-loader — npm install liferay-npm-bundler-loader-json-loader · libregistry