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

magic-comments-loader

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magic-comments-loader - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

dist/regexComment.js

3

dist/package.json
{
"name": "magic-comments-loader",
"version": "1.3.2",
"version": "1.4.0",
"description": "Add webpack magic comments to your dynamic imports during build time",

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

"@babel/preset-env": "^7.15.0",
"codecov": "^3.8.3",
"eslint": "^7.32.0",

@@ -42,0 +43,0 @@ "eslint-config-prettier": "^8.3.0",

@@ -20,2 +20,6 @@ "use strict";

var _webpackInclude = require("./webpackInclude.js");
var _webpackExclude = require("./webpackExclude.js");
const schema = {

@@ -35,3 +39,5 @@ type: 'object',

webpackPreload: _webpackPreload.schema,
webpackExports: _webpackExports.schema
webpackExports: _webpackExports.schema,
webpackInclude: _webpackInclude.schema,
webpackExclude: _webpackExclude.schema
},

@@ -38,0 +44,0 @@ additionalProperties: false

@@ -20,2 +20,6 @@ "use strict";

var _webpackInclude = require("./webpackInclude.js");
var _webpackExclude = require("./webpackExclude.js");
const commentFor = {

@@ -27,4 +31,6 @@ webpackChunkName: _webpackChunkName.webpackChunkName,

webpackPrefetch: _webpackPrefetch.webpackPrefetch,
webpackExports: _webpackExports.webpackExports
webpackExports: _webpackExports.webpackExports,
webpackInclude: _webpackInclude.webpackInclude,
webpackExclude: _webpackExclude.webpackExclude
};
exports.commentFor = commentFor;
{
"name": "magic-comments-loader",
"version": "1.3.2",
"version": "1.4.0",
"description": "Add webpack magic comments to your dynamic imports during build time",

@@ -41,2 +41,3 @@ "main": "dist",

"@babel/preset-env": "^7.15.0",
"codecov": "^3.8.3",
"eslint": "^7.32.0",

@@ -43,0 +44,0 @@ "eslint-config-prettier": "^8.3.0",

# [`magic-comments-loader`](https://www.npmjs.com/package/magic-comments-loader)
![CI](https://github.com/morganney/magic-comments-loader/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/morganney/magic-comments-loader/branch/master/graph/badge.svg?token=1DWQL43B8V)](https://codecov.io/gh/morganney/magic-comments-loader)
Keep your source code clean, add [magic coments](https://webpack.js.org/api/module-methods/#magic-comments) to your dynamic `import()` statements at build time.

@@ -7,3 +10,3 @@

Magic comments supported:
All magic comments are supported:
* `webpackChunkName`

@@ -14,2 +17,4 @@ * `webpackMode`

* [`webpackPrefetch`](https://webpack.js.org/guides/code-splitting/#prefetchingpreloading-modules)
* `webpackInclude`
* `webpackExclude`
* `webpackExports`

@@ -26,9 +31,7 @@

// import('some-ignored-module')
/* Some comment about a dynamic import('module') */
```
If you must have a multiline comment then this style is ok (only one `import()` per comment line preceded by an asterisk):
```js
/**
* Some multiline comment, only use one import() per line.
* Comment about import('module/one')

@@ -40,3 +43,3 @@ * Comment about import('module/two')

This module uses a RegExp not a parser. If you would like to add better support for ignoring `import()` behind multiline comments please open a pull request. See some more [examples on regexr](https://regexr.com/65fg0).
This module uses a RegExp not a parser. If you would like to add better support for ignoring `import()` behind multiline comments please open a pull request.

@@ -49,3 +52,3 @@ ### Configuration

Adds `webpackChunkName` to all dynamic imports (same as `webpackChunkName: true` when using options).
Adds `/* webpackChunkName: "path-to-module" */` to all dynamic imports (same as `webpackChunkName: true` when using options).

@@ -80,3 +83,3 @@ ```js

webpackIgnore: 'src/ignore/**/*.js',
webpackPrefetch: 'src/prefetch/**/*.js'
webpackPrefetch: 'src/prefetch/**/*.js',
webpackPreload: [

@@ -120,5 +123,9 @@ 'src/preload/**/*.js',

},
webpackIgnore: {
webpackInclude: {
config: {
active: false
include: (modulePath, importPath) => {
if (/locales\/\${language}/.test(importPath)) {
return /\.json$/
}
}
}

@@ -286,1 +293,9 @@ }

* `config.exports`: `(modulePath, importPath) => [String(<module names|default>)]`. Return falsy value to skip.
* `webpackInclude`
* `Function`: `(modulePath, importPath) => RegExp`. Return falsy value to skip.
* `config.active`: Boolean | `(modulePath, importPath) => Boolean`. Returning `false` does not add the comment.
* `config.include`: `(modulePath, importPath) => RegExp`. Return falsy value to skip.
* `webpackExclude`
* `Function`: `(modulePath, importPath) => RegExp`. Return falsy value to skip.
* `config.active`: Boolean | `(modulePath, importPath) => Boolean`. Returning `false` does not add the comment.
* `config.exclude`: `(modulePath, importPath) => RegExp`. Return falsy value to skip.
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