magic-comments-loader 1.4.2 → 1.5.0

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.
@@ -1,83 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.webpackExports = void 0;
7
-
8
- var _util = require("./util");
9
-
10
- const configSchema = {
11
- type: 'object',
12
- properties: {
13
- active: {
14
- oneOf: [{
15
- type: 'boolean'
16
- }, {
17
- instanceof: 'Function'
18
- }]
19
- },
20
- exports: {
21
- instanceof: 'Function'
22
- }
23
- },
24
- required: ['exports'],
25
- additionalProperties: false
26
- };
27
- const schema = {
28
- oneOf: [{
29
- instanceof: 'Function'
30
- }, {
31
- type: 'object',
32
- properties: {
33
- config: configSchema,
34
- overrides: (0, _util.getOverrideSchema)(configSchema)
35
- },
36
- required: ['config'],
37
- additionalProperties: false
38
- }]
39
- };
40
- exports.schema = schema;
41
- const defaultConfig = {
42
- active: true
43
- };
44
-
45
- const getConfig = (value, filepath) => {
46
- if (typeof value === 'function') {
47
- return { ...defaultConfig,
48
- exports: value
49
- };
50
- }
51
-
52
- let config = { ...defaultConfig,
53
- ...value.config
54
- };
55
-
56
- if (Array.isArray(value.overrides)) {
57
- config = (0, _util.getOverrideConfig)(value.overrides, filepath, config);
58
- }
59
-
60
- return config;
61
- };
62
-
63
- const webpackExports = (filepath, importPath, value) => {
64
- let exports = '';
65
- let configExports = [];
66
- const config = getConfig(value, filepath);
67
- const isActive = typeof config.active === 'function' ? config.active(filepath, importPath) : config.active;
68
-
69
- if (!isActive || typeof config.exports !== 'function') {
70
- return '';
71
- }
72
-
73
- configExports = config.exports(filepath, importPath);
74
-
75
- if (!Array.isArray(configExports)) {
76
- return '';
77
- }
78
-
79
- exports = `["${configExports.reduce((curr, next) => `${curr}", "${next}`)}"]`;
80
- return `webpackExports: ${exports}`;
81
- };
82
-
83
- exports.webpackExports = webpackExports;
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.webpackIgnore = void 0;
7
-
8
- var _booleanComment = require("./booleanComment.js");
9
-
10
- const schema = (0, _booleanComment.getSchema)();
11
- exports.schema = schema;
12
-
13
- const webpackIgnore = (filepath, importPath, value, match) => {
14
- const config = (0, _booleanComment.getConfig)(value, match, filepath, importPath);
15
- const isActive = typeof config.active === 'function' ? config.active(filepath, importPath) : config.active;
16
-
17
- if (!isActive) {
18
- return '';
19
- }
20
-
21
- return 'webpackIgnore: true';
22
- };
23
-
24
- exports.webpackIgnore = webpackIgnore;
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.webpackInclude = void 0;
7
-
8
- var _regexComment = require("./regexComment.js");
9
-
10
- const {
11
- comment: webpackInclude,
12
- schema
13
- } = (0, _regexComment.getRegexComment)('include');
14
- exports.schema = schema;
15
- exports.webpackInclude = webpackInclude;
@@ -1,113 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.webpackMode = void 0;
7
-
8
- var _util = require("./util");
9
-
10
- const validModes = ['lazy', 'lazy-once', 'eager', 'weak'];
11
- const configSchema = {
12
- type: 'object',
13
- properties: {
14
- active: {
15
- oneOf: [{
16
- type: 'boolean'
17
- }, {
18
- instanceof: 'Function'
19
- }]
20
- },
21
- mode: {
22
- oneOf: [{
23
- enum: validModes
24
- }, {
25
- instanceof: 'Function'
26
- }]
27
- }
28
- },
29
- additionalProperties: false
30
- };
31
- const schema = {
32
- oneOf: [{
33
- type: 'boolean'
34
- }, {
35
- type: 'string'
36
- }, {
37
- instanceof: 'Function'
38
- }, {
39
- type: 'object',
40
- properties: {
41
- config: configSchema,
42
- overrides: (0, _util.getOverrideSchema)(configSchema)
43
- },
44
- required: ['config'],
45
- additionalProperties: false
46
- }]
47
- };
48
- exports.schema = schema;
49
- const defaultConfig = {
50
- active: true,
51
- mode: 'lazy'
52
- };
53
-
54
- const getConfig = (value, filepath) => {
55
- if (value === true) {
56
- return defaultConfig;
57
- }
58
-
59
- if (value === false) {
60
- return { ...defaultConfig,
61
- active: false
62
- };
63
- }
64
-
65
- if (typeof value === 'string') {
66
- return { ...defaultConfig,
67
- mode: value,
68
- active: validModes.includes(value)
69
- };
70
- }
71
-
72
- if (typeof value === 'function') {
73
- return { ...defaultConfig,
74
- mode: value
75
- };
76
- }
77
-
78
- let config = { ...defaultConfig,
79
- ...value.config
80
- };
81
-
82
- if (Array.isArray(value.overrides)) {
83
- config = (0, _util.getOverrideConfig)(value.overrides, filepath, config);
84
- }
85
-
86
- return config;
87
- };
88
-
89
- const webpackMode = (filepath, importPath, value) => {
90
- let mode = '';
91
- const config = getConfig(value, filepath);
92
- const isActive = typeof config.active === 'function' ? config.active(filepath, importPath) : config.active;
93
-
94
- if (!isActive) {
95
- return '';
96
- }
97
-
98
- if (typeof config.mode === 'function') {
99
- mode = config.mode(filepath, importPath);
100
- }
101
-
102
- if (typeof config.mode === 'string') {
103
- mode = config.mode;
104
- }
105
-
106
- if (!validModes.includes(mode)) {
107
- return '';
108
- }
109
-
110
- return `webpackMode: "${mode}"`;
111
- };
112
-
113
- exports.webpackMode = webpackMode;
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.webpackPrefetch = void 0;
7
-
8
- var _booleanComment = require("./booleanComment.js");
9
-
10
- const schema = (0, _booleanComment.getSchema)();
11
- exports.schema = schema;
12
-
13
- const webpackPrefetch = (filepath, importPath, value, match) => {
14
- const config = (0, _booleanComment.getConfig)(value, match, filepath, importPath);
15
- const isActive = typeof config.active === 'function' ? config.active(filepath, importPath) : config.active;
16
-
17
- if (!isActive) {
18
- return '';
19
- }
20
-
21
- return 'webpackPrefetch: true';
22
- };
23
-
24
- exports.webpackPrefetch = webpackPrefetch;
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.webpackPreload = void 0;
7
-
8
- var _booleanComment = require("./booleanComment.js");
9
-
10
- const schema = (0, _booleanComment.getSchema)();
11
- exports.schema = schema;
12
-
13
- const webpackPreload = (filepath, importPath, value, match) => {
14
- const config = (0, _booleanComment.getConfig)(value, match, filepath, importPath);
15
- const isActive = typeof config.active === 'function' ? config.active(filepath, importPath) : config.active;
16
-
17
- if (!isActive) {
18
- return '';
19
- }
20
-
21
- return 'webpackPreload: true';
22
- };
23
-
24
- exports.webpackPreload = webpackPreload;