Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-import-loader

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-import-loader - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

4

lib/loader.d.ts

@@ -0,1 +1,3 @@

/// <reference types="webpack" />
import * as webpack from 'webpack';
/**

@@ -5,2 +7,2 @@ * Allows you to import external files into a json value.

*/
export default function (this: any, content: string): void;
export default function (this: webpack.loader.LoaderContext, content: string): void;

@@ -20,3 +20,3 @@ "use strict";

loaderContext.cacheable();
var newContent = content.replace(/"import!(.*?)"/gi, function (_, group) {
var newContent = content.replace(/(["'])import!(.*?)\1/gi, function (_, __, group) {
return "(\n function() {\n var result = require(" + loaderUtils.stringifyRequest(loaderContext, group) + ")\n if (typeof result === 'function') {\n result = result();\n }\n return result;\n }\n)()";

@@ -23,0 +23,0 @@ });

{
"name": "json-import-loader",
"version": "1.2.0",
"version": "1.2.1",
"description": "Allows import files into a json file, contains webpack-loader and node API.",

@@ -77,2 +77,3 @@ "main": "./index.js",

"@types/sinon-chai": "^2.7.29",
"@types/webpack": "^4.4.21",
"babel-eslint": "^8.0.3",

@@ -79,0 +80,0 @@ "babel-plugin-istanbul": "^4.1.5",

@@ -7,3 +7,3 @@ # json-import-loader

This module also contains a util function that works in plain node, in case you need to use the json
or yaml file outside of webpack. Keep in mind that you use full and relative imports.
or yaml file outside of webpack. Keep in mind that you can use full and relative imports.

@@ -40,2 +40,6 @@ [![Travis](https://img.shields.io/travis/mediamonks/json-import-loader.svg?maxAge=2592000)](https://travis-ci.org/mediamonks/json-import-loader)

**Note:** When importing JS files, if you want to support the `import!` syntax there as well, you
have to use this loader for those JS files as well. Do this in the webpack config, and make sure
to only include specific paths, so it won't be active for all JS files.
**Note:** When used on an empty file, it will return an empty object.

@@ -94,5 +98,12 @@

{
test: /\.js$/,
// include: /regexp-pattern-for-just-data-files/,
use: [
{ loader: 'json-import-loader' }
]
},
{
test: /\.json$/,
type: 'javascript/dynamic', // only for webpack 4+
use: [{ loader: 'json-partial-loader' }, { loader: 'json-loader' }],
use: [{ loader: 'json-import-loader' }, { loader: 'json-loader' }],
},

@@ -103,3 +114,3 @@ {

use: [
{ loader: 'json-partial-loader' },
{ loader: 'json-import-loader' },
{ loader: 'json-loader' },

@@ -106,0 +117,0 @@ { loader: 'yaml-loader' },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc