next-remove-imports 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,8 @@ import removeImports from 'next-remove-imports'
30
30
 
31
31
  /** @type {function(import("next").NextConfig): import("next").NextConfig}} */
32
32
  const removeImportsFun = removeImports({
33
- options: { },
33
+ // test: /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/,
34
+ // matchImports: "\\.(less|css|scss|sass|styl)$"
34
35
  });
35
36
 
36
37
  export default removeImportsFun({
@@ -83,6 +84,21 @@ module.exports = (phase, { defaultConfig }) => {
83
84
  };
84
85
  ```
85
86
 
87
+ ## Options
88
+
89
+ ```typescript
90
+ export type PluginOptions = {
91
+ /**
92
+ * @default "/node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/"
93
+ */
94
+ test?: RegExp;
95
+ /**
96
+ * @default "\\.(less|css|scss|sass|styl)$"
97
+ */
98
+ matchImports?: string;
99
+ }
100
+ ```
101
+
86
102
  ## License
87
103
 
88
104
  Licensed under the MIT License.
package/lib/index.d.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  import { NextConfig } from 'next';
2
- declare type PluginOptions = {
2
+ export type PluginOptions = {
3
+ /**
4
+ * @default "/node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/"
5
+ */
3
6
  test?: RegExp;
7
+ /**
8
+ * @default "\\.(less|css|scss|sass|styl)$"
9
+ */
4
10
  matchImports?: string;
5
11
  };
6
- declare const _default: (pluginOptions?: PluginOptions) => (nextConfig?: NextConfig) => NextConfig;
7
- export default _default;
12
+ declare const removeImports: (pluginOptions?: PluginOptions) => (nextConfig?: NextConfig) => NextConfig;
13
+ export default removeImports;
14
+ export = removeImports;
package/lib/index.js CHANGED
@@ -1,41 +1,36 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _default = function _default() {
8
- var pluginOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
- return function () {
10
- var nextConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11
- var test = pluginOptions.test || /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/;
12
- var matchImports = pluginOptions.matchImports || "\\.(less|css|scss|sass|styl)$";
2
+ const removeImports = (pluginOptions = {}) => (nextConfig = {}) => {
3
+ const test = pluginOptions.test || /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/;
4
+ const matchImports = pluginOptions.matchImports || "\\.(less|css|scss|sass|styl)$";
13
5
  return Object.assign({}, nextConfig, {
14
- webpack: function webpack(config, options) {
15
- if (!options.isServer) {
16
- config.module.rules.unshift({
17
- test: test,
18
- loader: require.resolve('babel-loader', {
19
- paths: [process.cwd()]
20
- }),
21
- options: {
22
- plugins: [[require.resolve('babel-plugin-transform-remove-imports', {
23
- // https://nodejs.org/api/modules.html#requireresolverequest-options
24
- paths: [process.cwd()]
25
- }), {
26
- "test": matchImports
27
- }]]
6
+ webpack(config, options) {
7
+ if (!options.isServer) {
8
+ config.module.rules.unshift({
9
+ test: test,
10
+ loader: require.resolve('babel-loader', {
11
+ paths: [process.cwd()]
12
+ }),
13
+ options: {
14
+ plugins: [
15
+ [
16
+ require.resolve('babel-plugin-transform-remove-imports', {
17
+ // https://nodejs.org/api/modules.html#requireresolverequest-options
18
+ paths: [process.cwd()]
19
+ }), {
20
+ "test": matchImports
21
+ }
22
+ ]
23
+ ]
24
+ }
25
+ });
28
26
  }
29
- });
30
- }
31
- if (typeof nextConfig.webpack === 'function') {
32
- return nextConfig.webpack(config, options);
33
- }
34
- return config;
35
- }
27
+ if (typeof nextConfig.webpack === 'function') {
28
+ return nextConfig.webpack(config, options);
29
+ }
30
+ return config;
31
+ },
36
32
  });
37
- };
38
33
  };
39
- exports["default"] = _default;
40
- module.exports = exports.default;
34
+ exports.default = removeImports;
35
+ module.exports = removeImports;
41
36
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1,38 +1 @@
1
- {
2
- "version": 3,
3
- "names": [
4
- "_default",
5
- "pluginOptions",
6
- "arguments",
7
- "length",
8
- "undefined",
9
- "nextConfig",
10
- "test",
11
- "matchImports",
12
- "Object",
13
- "assign",
14
- "webpack",
15
- "config",
16
- "options",
17
- "isServer",
18
- "module",
19
- "rules",
20
- "unshift",
21
- "loader",
22
- "require",
23
- "resolve",
24
- "paths",
25
- "process",
26
- "cwd",
27
- "plugins",
28
- "exports",
29
- "default"
30
- ],
31
- "sources": [
32
- "../src/index.ts"
33
- ],
34
- "sourcesContent": [
35
- "import { NextConfig } from 'next';\nimport { WebpackConfigContext } from 'next/dist/server/config-shared';\n\ntype PluginOptions = {\n test?: RegExp;\n matchImports?: string;\n}\n\nexport default (pluginOptions: PluginOptions = {}) => (nextConfig: NextConfig = {}): NextConfig => {\n const test = pluginOptions.test || /node_modules([\\s\\S]*?)\\.(tsx|ts|js|mjs|jsx)$/;\n const matchImports = pluginOptions.matchImports || \"\\\\.(less|css|scss|sass|styl)$\";\n return Object.assign({}, nextConfig, {\n webpack(config: any, options: WebpackConfigContext) {\n if (!options.isServer) {\n config.module.rules.unshift({\n test: test,\n loader: require.resolve('babel-loader', {\n paths: [process.cwd()]\n }),\n options: {\n plugins: [\n [\n require.resolve('babel-plugin-transform-remove-imports', {\n // https://nodejs.org/api/modules.html#requireresolverequest-options\n paths: [process.cwd()]\n }), {\n \"test\": matchImports\n }\n ]\n ]\n }\n });\n }\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(config, options)\n }\n return config\n },\n })\n}\n\n"
36
- ],
37
- "mappings": ";;;;;;eAQe,SAAAA,SAAA;EAAA,IAACC,aAA4B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAAA,OAAK,YAA6C;IAAA,IAA5CG,UAAsB,GAAAH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AM,IAAI,GAAG,aAAa,CAAC,IAAI,IAAI,8CAA8C,CAAC;IAClF,MAAM,YAAY,GAAG,aAAa,CAAC,YAAY,IAAI,+BAA+B,CAAC;IACnF,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE;QACnC,OAAO,CAAC,MAAW,EAAE,OAA6B;YAChD,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACrB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;oBAC1B,IAAI,EAAE,IAAI;oBACV,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE;wBACtC,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;qBACvB,CAAC;oBACF,OAAO,EAAE;wBACP,OAAO,EAAE;4BACP;gCACE,OAAO,CAAC,OAAO,CAAC,uCAAuC,EAAE;oCACvD,oEAAoE;oCACpE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;iCACvB,CAAC,EAAE;oCACF,MAAM,EAAE,YAAY;iCACrB;6BACF;yBACF;qBACF;iBACF,CAAC,CAAC;aACJ;YACD,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,UAAU,EAAE;gBAC5C,OAAO,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;aAC3C;YACD,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,kBAAe,aAAa,CAAA;AAE5B,iBAAS,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-remove-imports",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "The default behavior is to remove all `.less`/`.css`/`.scss`/`.sass`/`.styl` imports from all packages in node_modules.",
5
5
  "homepage": "https://uiwjs.github.io/next-remove-imports/",
6
6
  "main": "./lib/index.js",
@@ -11,8 +11,8 @@
11
11
  "url": "https://github.com/uiwjs/next-remove-imports"
12
12
  },
13
13
  "scripts": {
14
- "watch": "tsbb watch --entry ./src/index.ts --no-esm",
15
- "build": "tsbb build --entry ./src/index.ts --no-esm"
14
+ "watch": "tsbb watch",
15
+ "build": "tsbb build"
16
16
  },
17
17
  "files": [
18
18
  "lib"
@@ -24,8 +24,8 @@
24
24
  "next"
25
25
  ],
26
26
  "dependencies": {
27
- "@babel/core": "^7.14.3",
28
- "babel-loader": "^9.0.0",
29
- "babel-plugin-transform-remove-imports": "^1.5.4"
27
+ "@babel/core": "^7.21.4",
28
+ "babel-loader": "^9.1.2",
29
+ "babel-plugin-transform-remove-imports": "^1.7.0"
30
30
  }
31
31
  }