piral-cli-webpack5 0.13.7 → 0.14.0-alpha.3154

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.
Files changed (85) hide show
  1. package/README.md +20 -0
  2. package/extend-config.js +51 -14
  3. package/lib/actions.js +6 -40
  4. package/lib/actions.js.map +1 -1
  5. package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js +5 -5
  6. package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js.map +1 -1
  7. package/lib/enhancers/pilet-webpack-config-enhancer/helpers.d.ts +6 -0
  8. package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js +68 -1
  9. package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js.map +1 -1
  10. package/lib/enhancers/pilet-webpack-config-enhancer/index.d.ts +15 -2
  11. package/lib/enhancers/pilet-webpack-config-enhancer/index.js +86 -59
  12. package/lib/enhancers/pilet-webpack-config-enhancer/index.js.map +1 -1
  13. package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js +3 -3
  14. package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js.map +1 -1
  15. package/lib/helpers.d.ts +1 -1
  16. package/lib/helpers.js +1 -1
  17. package/lib/helpers.js.map +1 -1
  18. package/lib/index.js +1 -1
  19. package/lib/index.js.map +1 -1
  20. package/lib/{configs → plugins}/SheetPlugin.d.ts +3 -1
  21. package/lib/plugins/SheetPlugin.js +38 -0
  22. package/lib/plugins/SheetPlugin.js.map +1 -0
  23. package/lib/webpack/bundler-run.d.ts +2 -21
  24. package/lib/webpack/bundler-run.js +43 -45
  25. package/lib/webpack/bundler-run.js.map +1 -1
  26. package/lib/{configs → webpack}/common.d.ts +0 -0
  27. package/lib/{configs → webpack}/common.js +6 -7
  28. package/lib/webpack/common.js.map +1 -0
  29. package/lib/webpack/pilet.d.ts +19 -0
  30. package/lib/{configs → webpack}/pilet.js +30 -9
  31. package/lib/webpack/pilet.js.map +1 -0
  32. package/lib/webpack/piral.d.ts +16 -0
  33. package/lib/{configs → webpack}/piral.js +27 -9
  34. package/lib/webpack/piral.js.map +1 -0
  35. package/package.json +9 -9
  36. package/src/actions.ts +6 -21
  37. package/src/enhancers/pilet-webpack-config-enhancer/helpers.ts +75 -0
  38. package/src/enhancers/pilet-webpack-config-enhancer/index.ts +140 -68
  39. package/src/helpers.ts +1 -1
  40. package/src/index.ts +1 -1
  41. package/src/plugins/SheetPlugin.ts +37 -0
  42. package/src/webpack/bundler-run.ts +49 -57
  43. package/src/{configs → webpack}/common.ts +3 -4
  44. package/src/{configs → webpack}/pilet.ts +42 -4
  45. package/src/{configs → webpack}/piral.ts +32 -1
  46. package/lib/configs/SheetPlugin.js +0 -23
  47. package/lib/configs/SheetPlugin.js.map +0 -1
  48. package/lib/configs/common.js.map +0 -1
  49. package/lib/configs/index.d.ts +0 -2
  50. package/lib/configs/index.js +0 -15
  51. package/lib/configs/index.js.map +0 -1
  52. package/lib/configs/pilet.d.ts +0 -3
  53. package/lib/configs/pilet.js.map +0 -1
  54. package/lib/configs/piral.d.ts +0 -2
  55. package/lib/configs/piral.js.map +0 -1
  56. package/lib/webpack/bundler-calls.d.ts +0 -3
  57. package/lib/webpack/bundler-calls.js +0 -93
  58. package/lib/webpack/bundler-calls.js.map +0 -1
  59. package/lib/webpack/index.d.ts +0 -1
  60. package/lib/webpack/index.js +0 -14
  61. package/lib/webpack/index.js.map +0 -1
  62. package/lib/webpack/run-build-pilet.d.ts +0 -1
  63. package/lib/webpack/run-build-pilet.js +0 -53
  64. package/lib/webpack/run-build-pilet.js.map +0 -1
  65. package/lib/webpack/run-build-piral.d.ts +0 -1
  66. package/lib/webpack/run-build-piral.js +0 -56
  67. package/lib/webpack/run-build-piral.js.map +0 -1
  68. package/lib/webpack/run-debug-mono-piral.d.ts +0 -1
  69. package/lib/webpack/run-debug-mono-piral.js +0 -61
  70. package/lib/webpack/run-debug-mono-piral.js.map +0 -1
  71. package/lib/webpack/run-debug-pilet.d.ts +0 -1
  72. package/lib/webpack/run-debug-pilet.js +0 -77
  73. package/lib/webpack/run-debug-pilet.js.map +0 -1
  74. package/lib/webpack/run-debug-piral.d.ts +0 -1
  75. package/lib/webpack/run-debug-piral.js +0 -76
  76. package/lib/webpack/run-debug-piral.js.map +0 -1
  77. package/src/configs/SheetPlugin.ts +0 -21
  78. package/src/configs/index.ts +0 -2
  79. package/src/webpack/bundler-calls.ts +0 -107
  80. package/src/webpack/index.ts +0 -1
  81. package/src/webpack/run-build-pilet.ts +0 -81
  82. package/src/webpack/run-build-piral.ts +0 -82
  83. package/src/webpack/run-debug-mono-piral.ts +0 -65
  84. package/src/webpack/run-debug-pilet.ts +0 -93
  85. package/src/webpack/run-debug-piral.ts +0 -84
package/README.md CHANGED
@@ -68,6 +68,26 @@ module.exports = function(config) {
68
68
  };
69
69
  ```
70
70
 
71
+ Otherwise, you can also use the `extend-config` helper module to get the job done without having to know the internals:
72
+
73
+ ```js
74
+ const extendConfig = require('piral-cli-webpack5/extend-config');
75
+
76
+ module.exports = extendConfig({
77
+ checkTypes: true, // not only transpiles TS, but also checks the types
78
+ noPresets: true, // removes existing presets from Babel
79
+ rules: [], // adds additional rules
80
+ removeRules: [], // removes the rules mentioned by their loader name
81
+ plugins: [], // adds additional plugins
82
+ removePlugins: [], // removes the plugins mentioned by their class reference
83
+ fileLoaderOptions: {}, // sets the options for the file loader
84
+ tsLoaderOptions: {}, // sets the options for the TS loader
85
+ babelLoaderOptions: {}, // sets the options for the Babel loader
86
+ cssLoaderOptions: {}, // sets the options for the CSS loader
87
+ sassLoaderOptions: {}, // sets the options for the SASS loader
88
+ });
89
+ ```
90
+
71
91
  ## License
72
92
 
73
93
  Piral is released using the MIT license. For more information see the [license file](./LICENSE).
package/extend-config.js CHANGED
@@ -1,14 +1,43 @@
1
+ function changePlugin(config, classRef, cb) {
2
+ config.module.plugins = config.module.plugins
3
+ .map((plugin) => {
4
+ if (plugin instanceof classRef) {
5
+ return cb(plugin);
6
+ }
7
+
8
+ return plugin;
9
+ })
10
+ .filter(Boolean);
11
+ }
12
+
13
+ function changeRule(config, name, cb) {
14
+ const loaderPath = require.resolve(name);
15
+ config.module.rules = config.module.rules
16
+ .map((rule) => {
17
+ const uses = rule.use || [];
18
+
19
+ if (uses.some((m) => m && (m === loaderPath || (typeof m === 'object' && m.loader === loaderPath)))) {
20
+ return cb(rule);
21
+ }
22
+
23
+ return rule;
24
+ })
25
+ .filter(Boolean);
26
+ }
27
+
1
28
  function changeLoader(config, name, cb) {
2
- config.module.rules.forEach((rule) => {
3
- (rule.use || [])
4
- .filter((m) => m && typeof m === 'object')
5
- .forEach((m, i) => {
6
- if (m === name) {
7
- rule.use[i] = cb({ loader: m });
8
- } else if (m.loader === name) {
9
- rule.use[i] = cb(m);
10
- }
11
- });
29
+ changeRule(config, name, (rule) => {
30
+ rule.use = rule.use.map((m) => {
31
+ if (m === loaderPath) {
32
+ return cb({ loader: m });
33
+ } else if (m.loader === loaderPath) {
34
+ return cb(m);
35
+ } else {
36
+ return m;
37
+ }
38
+ });
39
+
40
+ return rule;
12
41
  });
13
42
  }
14
43
 
@@ -63,17 +92,25 @@ module.exports = function (override) {
63
92
  );
64
93
  }
65
94
 
66
- if ('change' in override && typeof override.change === 'function') {
67
- config = override.change(config);
68
- }
69
-
70
95
  if ('rules' in override && Array.isArray(override.rules)) {
71
96
  config.module.rules.push(...rules);
72
97
  }
73
98
 
99
+ if ('removeRules' in override && Array.isArray(override.removeRules)) {
100
+ override.removeRules.forEach((rule) => changeRule(config, rule, () => undefined));
101
+ }
102
+
74
103
  if ('plugins' in override && Array.isArray(override.plugins)) {
75
104
  config.plugins.push(...plugins);
76
105
  }
106
+
107
+ if ('removePlugins' in override && Array.isArray(override.removePlugins)) {
108
+ override.removePlugins.forEach((plugin) => changePlugin(config, plugin, () => undefined));
109
+ }
110
+
111
+ if ('change' in override && typeof override.change === 'function') {
112
+ config = override.change(config);
113
+ }
77
114
  }
78
115
 
79
116
  return config;
package/lib/actions.js CHANGED
@@ -1,54 +1,20 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.buildPilet = exports.debugPilet = exports.buildPiral = exports.watchPiral = exports.debugPiral = void 0;
13
- const webpack_1 = require("./webpack");
4
+ const path_1 = require("path");
14
5
  exports.debugPiral = {
15
- run(args) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const bundler = yield webpack_1.callDynamic('debug-piral', args);
18
- return bundler;
19
- });
20
- },
6
+ path: (0, path_1.resolve)(__dirname, 'webpack', 'piral.js'),
21
7
  };
22
8
  exports.watchPiral = {
23
- run(args) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const bundler = yield webpack_1.callStatic('debug-mono-piral', args);
26
- return bundler;
27
- });
28
- },
9
+ path: (0, path_1.resolve)(__dirname, 'webpack', 'piral.js'),
29
10
  };
30
11
  exports.buildPiral = {
31
- run(args) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const bundler = yield webpack_1.callStatic('build-piral', args);
34
- return bundler.bundle;
35
- });
36
- },
12
+ path: (0, path_1.resolve)(__dirname, 'webpack', 'piral.js'),
37
13
  };
38
14
  exports.debugPilet = {
39
- run(args) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const bundler = yield webpack_1.callDynamic('debug-pilet', args);
42
- return bundler;
43
- });
44
- },
15
+ path: (0, path_1.resolve)(__dirname, 'webpack', 'pilet.js'),
45
16
  };
46
17
  exports.buildPilet = {
47
- run(args) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const bundler = yield webpack_1.callStatic('build-pilet', args);
50
- return bundler.bundle;
51
- });
52
- },
18
+ path: (0, path_1.resolve)(__dirname, 'webpack', 'pilet.js'),
53
19
  };
54
20
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoD;AASvC,QAAA,UAAU,GAAgC;IAC/C,GAAG,CAAC,IAAI;;YACZ,MAAM,OAAO,GAAG,MAAM,qBAAW,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACvD,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,UAAU,GAAgC;IAC/C,GAAG,CAAC,IAAI;;YACZ,MAAM,OAAO,GAAG,MAAM,oBAAU,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;YAC3D,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,UAAU,GAAgC;IAC/C,GAAG,CAAC,IAAI;;YACZ,MAAM,OAAO,GAAG,MAAM,oBAAU,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACtD,OAAO,OAAO,CAAC,MAAM,CAAC;QACxB,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,UAAU,GAAgC;IAC/C,GAAG,CAAC,IAAI;;YACZ,MAAM,OAAO,GAAG,MAAM,qBAAW,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACvD,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,UAAU,GAAgC;IAC/C,GAAG,CAAC,IAAI;;YACZ,MAAM,OAAO,GAAG,MAAM,oBAAU,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACtD,OAAO,OAAO,CAAC,MAAM,CAAC;QACxB,CAAC;KAAA;CACF,CAAC"}
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AASlB,QAAA,UAAU,GAAgC;IACrD,IAAI,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;CAChD,CAAC;AAEW,QAAA,UAAU,GAAgC;IACrD,IAAI,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;CAChD,CAAC;AAEW,QAAA,UAAU,GAAgC;IACrD,IAAI,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;CAChD,CAAC;AAEW,QAAA,UAAU,GAAgC;IACrD,IAAI,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;CAChD,CAAC;AAEW,QAAA,UAAU,GAAgC;IACrD,IAAI,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;CAChD,CAAC"}
@@ -8,17 +8,17 @@ const path_1 = require("path");
8
8
  const helpers_1 = require("./helpers");
9
9
  const html5EntryWebpackConfigEnhancer = (options) => (compilerOptions) => {
10
10
  const entry = compilerOptions.entry;
11
- const [template] = helpers_1.getTemplates(entry);
11
+ const [template] = (0, helpers_1.getTemplates)(entry);
12
12
  if (template) {
13
- const src = path_1.dirname(template);
14
- const templateContent = cheerio_1.load(fs_1.readFileSync(template, 'utf8'));
15
- const entries = helpers_1.extractParts(templateContent).map((entry) => path_1.join(src, entry));
13
+ const src = (0, path_1.dirname)(template);
14
+ const templateContent = (0, cheerio_1.load)((0, fs_1.readFileSync)(template, 'utf8'));
15
+ const entries = (0, helpers_1.extractParts)(templateContent).map((entry) => (0, path_1.join)(src, entry));
16
16
  const plugins = [
17
17
  new HtmlWebpackPlugin(Object.assign(Object.assign({}, options), { templateContent: templateContent.html() })),
18
18
  ];
19
19
  if (!entries.length)
20
20
  throw new Error('Template entries expected to be not empty');
21
- helpers_1.setEntries(compilerOptions, template, entries);
21
+ (0, helpers_1.setEntries)(compilerOptions, template, entries);
22
22
  compilerOptions.plugins = [...compilerOptions.plugins, ...plugins];
23
23
  }
24
24
  return compilerOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/html5-entry-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AAEzD,qCAA+B;AAC/B,2BAAkC;AAClC,+BAAqC;AACrC,uCAAmE;AAI5D,MAAM,+BAA+B,GAAG,CAAC,OAAuC,EAAE,EAAE,CAAC,CAC1F,eAA8B,EAC9B,EAAE;IACF,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;IACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,sBAAY,CAAC,KAAK,CAAC,CAAC;IAEvC,IAAI,QAAQ,EAAE;QACZ,MAAM,GAAG,GAAG,cAAO,CAAC,QAAQ,CAAC,CAAC;QAC9B,MAAM,eAAe,GAAG,cAAI,CAAC,iBAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,sBAAY,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG;YACd,IAAI,iBAAiB,iCAChB,OAAO,KACV,eAAe,EAAE,eAAe,CAAC,IAAI,EAAE,IACvC;SACH,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAElF,oBAAU,CAAC,eAAe,EAAE,QAAQ,EAAE,OAAgC,CAAC,CAAC;QAExE,eAAe,CAAC,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;KACpE;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAzBW,QAAA,+BAA+B,mCAyB1C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/html5-entry-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AAEzD,qCAA+B;AAC/B,2BAAkC;AAClC,+BAAqC;AACrC,uCAAmE;AAI5D,MAAM,+BAA+B,GAAG,CAAC,OAAuC,EAAE,EAAE,CAAC,CAC1F,eAA8B,EAC9B,EAAE;IACF,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;IACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAC;IAEvC,IAAI,QAAQ,EAAE;QACZ,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;QAC9B,MAAM,eAAe,GAAG,IAAA,cAAI,EAAC,IAAA,iBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG;YACd,IAAI,iBAAiB,iCAChB,OAAO,KACV,eAAe,EAAE,eAAe,CAAC,IAAI,EAAE,IACvC;SACH,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAElF,IAAA,oBAAU,EAAC,eAAe,EAAE,QAAQ,EAAE,OAAgC,CAAC,CAAC;QAExE,eAAe,CAAC,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;KACpE;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAzBW,QAAA,+BAA+B,mCAyB1C"}
@@ -1,3 +1,9 @@
1
+ import { SharedDependency } from 'piral-cli';
2
+ import { Configuration } from 'webpack';
1
3
  export declare function getVariables(name: string, version: string, env: string): Record<string, string>;
2
4
  export declare function setEnvironment(variables: Record<string, string>): void;
3
5
  export declare function getDefineVariables(variables: Record<string, string>): {};
6
+ export declare function getExternals(piral: string): any[];
7
+ export declare function getDependencies(importmap: Array<SharedDependency>, compilerOptions: Configuration): {};
8
+ export declare function withSetPath(compilerOptions: Configuration): void;
9
+ export declare function withExternals(compilerOptions: Configuration, externals: Array<string>): void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefineVariables = exports.setEnvironment = exports.getVariables = void 0;
3
+ exports.withExternals = exports.withSetPath = exports.getDependencies = exports.getExternals = exports.getDefineVariables = exports.setEnvironment = exports.getVariables = void 0;
4
+ const path_1 = require("path");
4
5
  function getVariables(name, version, env) {
5
6
  return {
6
7
  NODE_ENV: env,
@@ -22,4 +23,70 @@ function getDefineVariables(variables) {
22
23
  }, {});
23
24
  }
24
25
  exports.getDefineVariables = getDefineVariables;
26
+ function getExternals(piral) {
27
+ var _a, _b;
28
+ const shellPkg = require(`${piral}/package.json`);
29
+ const piralExternals = (_b = (_a = shellPkg.pilets) === null || _a === void 0 ? void 0 : _a.externals) !== null && _b !== void 0 ? _b : [];
30
+ return [
31
+ ...piralExternals,
32
+ '@dbeining/react-atom',
33
+ '@libre/atom',
34
+ 'history',
35
+ 'react',
36
+ 'react-dom',
37
+ 'react-router',
38
+ 'react-router-dom',
39
+ 'tslib',
40
+ 'path-to-regexp',
41
+ ];
42
+ }
43
+ exports.getExternals = getExternals;
44
+ function getDependencies(importmap, compilerOptions) {
45
+ const dependencies = {};
46
+ if (typeof compilerOptions.entry === 'object' && compilerOptions.entry) {
47
+ for (const dep of importmap) {
48
+ dependencies[dep.id] = dep.ref;
49
+ compilerOptions.externals[dep.name] = dep.id;
50
+ if (dep.type === 'local') {
51
+ compilerOptions.entry[dep.ref.replace(/\.js$/, '')] = dep.entry;
52
+ }
53
+ }
54
+ }
55
+ return dependencies;
56
+ }
57
+ exports.getDependencies = getDependencies;
58
+ function withSetPath(compilerOptions) {
59
+ if (typeof compilerOptions.entry === 'object' && compilerOptions.entry) {
60
+ const setPath = (0, path_1.join)(__dirname, '..', '..', 'set-path');
61
+ if (Array.isArray(compilerOptions.entry)) {
62
+ compilerOptions.entry.unshift(setPath);
63
+ }
64
+ else {
65
+ for (const key of Object.keys(compilerOptions.entry)) {
66
+ const entry = compilerOptions.entry[key];
67
+ if (Array.isArray(entry)) {
68
+ entry.unshift(setPath);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ exports.withSetPath = withSetPath;
75
+ function withExternals(compilerOptions, externals) {
76
+ const current = compilerOptions.externals;
77
+ const newExternals = Array.isArray(current)
78
+ ? [...current, ...externals]
79
+ : typeof current === 'string'
80
+ ? [current, ...externals]
81
+ : externals;
82
+ if (newExternals !== externals || typeof compilerOptions.externals !== 'object' || !compilerOptions.externals) {
83
+ compilerOptions.externals = {};
84
+ }
85
+ for (const external of newExternals) {
86
+ if (typeof external === 'string') {
87
+ compilerOptions.externals[external] = external;
88
+ }
89
+ }
90
+ }
91
+ exports.withExternals = withExternals;
25
92
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/enhancers/pilet-webpack-config-enhancer/helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAe,EAAE,GAAW;IACrE,OAAO;QACL,QAAQ,EAAE,GAAG;QACb,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,YAAY,EAAE;QACrC,eAAe,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACzC,kBAAkB,EAAE,OAAO;QAC3B,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC;AARD,oCAQC;AAED,SAAgB,cAAc,CAAC,SAAiC;IAC9D,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAA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AC,QAAQ,CAAC,GAAG,QAAQ,CAAC;SAChD;KACF;AACH,CAAC;AAjBD,sCAiBC"}
@@ -1,9 +1,14 @@
1
+ import type { SharedDependency } from 'piral-cli';
1
2
  import { Configuration } from 'webpack';
2
3
  export interface PiletWebpackConfigEnhancerOptions {
3
4
  /**
4
5
  * The name of the pilet.
5
6
  */
6
7
  name: string;
8
+ /**
9
+ * The name of the entry module.
10
+ */
11
+ entry: string;
7
12
  /**
8
13
  * The version of the pilet.
9
14
  */
@@ -12,10 +17,14 @@ export interface PiletWebpackConfigEnhancerOptions {
12
17
  * The name of the Piral instance / app shell.
13
18
  */
14
19
  piral: string;
20
+ /**
21
+ * The name of the main output file.
22
+ */
23
+ filename: string;
15
24
  /**
16
25
  * The schema version. By default, v1 is used.
17
26
  */
18
- schema?: 'v0' | 'v1' | 'none';
27
+ schema?: 'v0' | 'v1' | 'v2' | 'none';
19
28
  /**
20
29
  * The shared dependencies. By default, these are read from the
21
30
  * Piral instance.
@@ -25,5 +34,9 @@ export interface PiletWebpackConfigEnhancerOptions {
25
34
  * Additional environment variables to define.
26
35
  */
27
36
  variables?: Record<string, string>;
37
+ /**
38
+ * The shared dependencies to consider.
39
+ */
40
+ importmap: Array<SharedDependency>;
28
41
  }
29
- export declare const piletWebpackConfigEnhancer: (options: PiletWebpackConfigEnhancerOptions) => (compilerOptions: Configuration) => Configuration;
42
+ export declare const piletWebpackConfigEnhancer: (details: PiletWebpackConfigEnhancerOptions) => (compiler: Configuration) => Configuration;
@@ -1,71 +1,98 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.piletWebpackConfigEnhancer = void 0;
4
- const path_1 = require("path");
4
+ const SystemJSPublicPathWebpackPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin");
5
5
  const webpack_1 = require("webpack");
6
6
  const helpers_1 = require("./helpers");
7
- function getExternals(piral) {
8
- var _a, _b;
9
- const shellPkg = require(`${piral}/package.json`);
10
- const piralExternals = (_b = (_a = shellPkg.pilets) === null || _a === void 0 ? void 0 : _a.externals) !== null && _b !== void 0 ? _b : [];
11
- return [
12
- ...piralExternals,
13
- '@dbeining/react-atom',
14
- '@libre/atom',
15
- 'history',
16
- 'react',
17
- 'react-dom',
18
- 'react-router',
19
- 'react-router-dom',
20
- 'tslib',
21
- 'path-to-regexp',
22
- ];
7
+ function piletVxWebpackConfigEnhancer(options, compiler) {
8
+ const { variables, externals } = options;
9
+ (0, helpers_1.withSetPath)(compiler);
10
+ (0, helpers_1.setEnvironment)(variables);
11
+ (0, helpers_1.withExternals)(compiler, externals);
12
+ compiler.plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)));
13
+ return compiler;
23
14
  }
24
- const piletWebpackConfigEnhancer = (options) => (compilerOptions) => {
25
- const environment = process.env.NODE_ENV || 'development';
26
- const { name, version, piral, externals = getExternals(piral), schema } = options;
15
+ function piletV0WebpackConfigEnhancer(options, compiler) {
16
+ const { name, variables, externals, file } = options;
27
17
  const shortName = name.replace(/\W/gi, '');
28
18
  const jsonpFunction = `pr_${shortName}`;
29
- const variables = Object.assign(Object.assign({}, helpers_1.getVariables(name, version, environment)), options.variables);
30
- const plugins = [new webpack_1.DefinePlugin(helpers_1.getDefineVariables(variables))];
31
- if (typeof compilerOptions.entry === 'object' && compilerOptions.entry) {
32
- const setPath = path_1.join(__dirname, '..', '..', 'set-path');
33
- if (Array.isArray(compilerOptions.entry)) {
34
- compilerOptions.entry.unshift(setPath);
35
- }
36
- else if (Array.isArray(compilerOptions.entry.main)) {
37
- compilerOptions.entry.main.unshift(setPath);
38
- }
39
- }
40
- if (schema !== 'none') {
41
- const bannerSuffix = schema ? `1(${jsonpFunction})` : `0`;
42
- plugins.push(new webpack_1.BannerPlugin({
43
- banner: `//@pilet v:${bannerSuffix}`,
44
- entryOnly: true,
45
- include: /\.js$/,
46
- raw: true,
47
- }));
48
- }
49
- helpers_1.setEnvironment(variables);
50
- compilerOptions.plugins = [...compilerOptions.plugins, ...plugins];
51
- const current = compilerOptions.externals;
52
- compilerOptions.output.uniqueName = `${jsonpFunction}`;
53
- compilerOptions.output.library = name;
54
- if (schema !== 'none') {
55
- compilerOptions.output.libraryTarget = 'umd';
56
- }
57
- if (schema === 'v1') {
58
- const reset = `delete window.webpackChunk${jsonpFunction};`;
59
- compilerOptions.output.auxiliaryComment = {
60
- commonjs2: `\nfunction define(d,k){${reset}(typeof document!=='undefined')&&(document.currentScript.app=k.apply(null,d.map(window.${jsonpFunction})));}define.amd=!0;`,
61
- };
19
+ (0, helpers_1.withSetPath)(compiler);
20
+ (0, helpers_1.setEnvironment)(variables);
21
+ (0, helpers_1.withExternals)(compiler, externals);
22
+ compiler.plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
23
+ banner: `//@pilet v:0`,
24
+ entryOnly: true,
25
+ include: file,
26
+ raw: true,
27
+ }));
28
+ compiler.output.uniqueName = `${jsonpFunction}`;
29
+ compiler.output.library = name;
30
+ compiler.output.libraryTarget = 'umd';
31
+ return compiler;
32
+ }
33
+ function piletV1WebpackConfigEnhancer(options, compiler) {
34
+ const { name, variables, externals, file } = options;
35
+ const shortName = name.replace(/\W/gi, '');
36
+ const jsonpFunction = `pr_${shortName}`;
37
+ (0, helpers_1.withSetPath)(compiler);
38
+ (0, helpers_1.setEnvironment)(variables);
39
+ (0, helpers_1.withExternals)(compiler, externals);
40
+ compiler.plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
41
+ banner: `//@pilet v:1(${jsonpFunction})`,
42
+ entryOnly: true,
43
+ include: file,
44
+ raw: true,
45
+ }));
46
+ compiler.output.uniqueName = `${jsonpFunction}`;
47
+ compiler.output.library = name;
48
+ compiler.output.libraryTarget = 'umd';
49
+ compiler.output.auxiliaryComment = {
50
+ commonjs2: `\nfunction define(d,k){(typeof document!=='undefined')&&(document.currentScript.app=k.apply(null,d.map(window.${jsonpFunction})));}define.amd=!0;`,
51
+ };
52
+ return compiler;
53
+ }
54
+ function piletV2WebpackConfigEnhancer(options, compiler) {
55
+ const { name, variables, externals, file, importmap } = options;
56
+ const shortName = name.replace(/\W/gi, '');
57
+ const jsonpFunction = `pr_${shortName}`;
58
+ (0, helpers_1.withExternals)(compiler, externals);
59
+ (0, helpers_1.setEnvironment)(variables);
60
+ const dependencies = (0, helpers_1.getDependencies)(importmap, compiler);
61
+ const plugins = [];
62
+ plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
63
+ banner: `//@pilet v:2(webpackChunk${jsonpFunction},${JSON.stringify(dependencies)})`,
64
+ entryOnly: true,
65
+ include: file,
66
+ raw: true,
67
+ }), new SystemJSPublicPathWebpackPlugin());
68
+ compiler.plugins = [...compiler.plugins, ...plugins];
69
+ compiler.module.rules.push({ parser: { system: false } });
70
+ compiler.output.uniqueName = `${jsonpFunction}`;
71
+ compiler.output.library = { type: 'system' };
72
+ return compiler;
73
+ }
74
+ const piletWebpackConfigEnhancer = (details) => (compiler) => {
75
+ const { piral, externals = (0, helpers_1.getExternals)(piral), schema, importmap } = details;
76
+ const environment = process.env.NODE_ENV || 'development';
77
+ const options = {
78
+ entry: details.entry,
79
+ externals,
80
+ file: details.filename,
81
+ name: details.name,
82
+ importmap,
83
+ variables: Object.assign(Object.assign({}, (0, helpers_1.getVariables)(details.name, details.version, environment)), details.variables),
84
+ };
85
+ switch (schema) {
86
+ case 'v0':
87
+ return piletV0WebpackConfigEnhancer(options, compiler);
88
+ case 'v1':
89
+ return piletV1WebpackConfigEnhancer(options, compiler);
90
+ case 'v2':
91
+ return piletV2WebpackConfigEnhancer(options, compiler);
92
+ case 'none':
93
+ default:
94
+ return piletVxWebpackConfigEnhancer(options, compiler);
62
95
  }
63
- compilerOptions.externals = Array.isArray(current)
64
- ? [...current, ...externals]
65
- : current
66
- ? [current, ...externals]
67
- : externals;
68
- return compilerOptions;
69
96
  };
70
97
  exports.piletWebpackConfigEnhancer = piletWebpackConfigEnhancer;
71
98
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/pilet-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,qCAA2F;AAC3F,uCAA6E;AA8B7E,SAAS,YAAY,CAAC,KAAa;;IACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,KAAK,eAAe,CAAC,CAAC;IAClD,MAAM,cAAc,GAAG,MAAA,MAAA,QAAQ,CAAC,MAAM,0CAAE,SAAS,mCAAI,EAAE,CAAC;IACxD,OAAO;QACL,GAAG,cAAc;QACjB,sBAAsB;QACtB,aAAa;QACb,SAAS;QACT,OAAO;QACP,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,OAAO;QACP,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAEM,MAAM,0BAA0B,GAAG,CAAC,OAA0C,EAAE,EAAE,CAAC,CACxF,eAA8B,EAC9B,EAAE;IACF,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;IAC1D,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,MAAM,SAAS,EAAE,CAAC;IACxC,MAAM,SAAS,mCACV,sBAAY,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,GACxC,OAAO,CAAC,SAAS,CACrB,CAAC;IACF,MAAM,OAAO,GAA4B,CAAC,IAAI,sBAAY,CAAC,4BAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAE3F,IAAI,OAAO,eAAe,CAAC,KAAK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AC,CAAC;AA1BW,QAAA,0BAA0B,8BA0BrC"}
@@ -6,9 +6,9 @@ const helpers_1 = require("./helpers");
6
6
  const piralInstanceWebpackConfigEnhancer = (options) => (compilerOptions) => {
7
7
  const { name, version, externals } = options;
8
8
  const environment = process.env.NODE_ENV || 'development';
9
- const variables = Object.assign(Object.assign({}, helpers_1.getVariables(name, version, externals, environment)), options.variables);
10
- const plugins = [new webpack_1.DefinePlugin(helpers_1.getDefineVariables(variables))];
11
- helpers_1.setEnvironment(variables);
9
+ const variables = Object.assign(Object.assign({}, (0, helpers_1.getVariables)(name, version, externals, environment)), options.variables);
10
+ const plugins = [new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables))];
11
+ (0, helpers_1.setEnvironment)(variables);
12
12
  compilerOptions.plugins = [...(compilerOptions.plugins || []), ...plugins];
13
13
  return compilerOptions;
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/piral-instance-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,uCAA6E;AAStE,MAAM,kCAAkC,GAAG,CAAC,OAA0C,EAAE,EAAE,CAAC,CAChG,eAA8B,EAC9B,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;IAC1D,MAAM,SAAS,mCACV,sBAAY,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,GACnD,OAAO,CAAC,SAAS,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,IAAI,sBAAY,CAAC,4BAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAElE,wBAAc,CAAC,SAAS,CAAC,CAAC;IAE1B,eAAe,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;IAE3E,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAjBW,QAAA,kCAAkC,sCAiB7C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/piral-instance-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,uCAA6E;AAStE,MAAM,kCAAkC,GAAG,CAAC,OAA0C,EAAE,EAAE,CAAC,CAChG,eAA8B,EAC9B,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;IAC1D,MAAM,SAAS,mCACV,IAAA,sBAAY,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,GACnD,OAAO,CAAC,SAAS,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,IAAI,sBAAY,CAAC,IAAA,4BAAkB,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAElE,IAAA,wBAAc,EAAC,SAAS,CAAC,CAAC;IAE1B,eAAe,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;IAE3E,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAjBW,QAAA,kCAAkC,sCAiB7C"}
package/lib/helpers.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { Configuration } from 'webpack';
2
- import { DefaultConfiguration } from './configs/common';
2
+ import { DefaultConfiguration } from './webpack/common';
3
3
  export declare function extendConfig([webPackConfig, enhancer]: DefaultConfiguration, otherConfigPath: string, overrides?: Configuration): Configuration;
package/lib/helpers.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extendConfig = void 0;
4
4
  const fs_1 = require("fs");
5
5
  function extendConfig([webPackConfig, enhancer], otherConfigPath, overrides = {}) {
6
- if (fs_1.existsSync(otherConfigPath)) {
6
+ if ((0, fs_1.existsSync)(otherConfigPath)) {
7
7
  const otherConfig = require(otherConfigPath);
8
8
  if (typeof otherConfig === 'function') {
9
9
  webPackConfig = otherConfig(webPackConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,2BAAgC;AAIhC,SAAgB,YAAY,CAC1B,CAAC,aAAa,EAAE,QAAQ,CAAuB,EAC/C,eAAuB,EACvB,YAA2B,EAAE;IAE7B,IAAI,eAAU,CAAC,eAAe,CAAC,EAAE;QAC/B,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;QAE7C,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;YACrC,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;SAC5C;aAAM,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YAC1C,OAAO,QAAQ,+CACV,aAAa,GACb,WAAW,GACX,SAAS,EACZ,CAAC;SACJ;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,sCAAsC,eAAe,cAAc,CAAC,CAAC;SACnF;KACF;IAED,OAAO,QAAQ,iCACV,aAAa,GACb,SAAS,EACZ,CAAC;AACL,CAAC;AAzBD,oCAyBC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,2BAAgC;AAIhC,SAAgB,YAAY,CAC1B,CAAC,aAAa,EAAE,QAAQ,CAAuB,EAC/C,eAAuB,EACvB,YAA2B,EAAE;IAE7B,IAAI,IAAA,eAAU,EAAC,eAAe,CAAC,EAAE;QAC/B,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;QAE7C,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;YACrC,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;SAC5C;aAAM,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YAC1C,OAAO,QAAQ,+CACV,aAAa,GACb,WAAW,GACX,SAAS,EACZ,CAAC;SACJ;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,sCAAsC,eAAe,cAAc,CAAC,CAAC;SACnF;KACF;IAED,OAAO,QAAQ,iCACV,aAAa,GACb,SAAS,EACZ,CAAC;AACL,CAAC;AAzBD,oCAyBC"}
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const actions = require("./actions");
4
4
  const plugin = (cli) => {
5
- cli.withBundler('webpack', actions);
5
+ cli.withBundler('webpack5', actions);
6
6
  };
7
7
  module.exports = plugin;
8
8
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qCAAqC;AAGrC,MAAM,MAAM,GAAc,CAAC,GAAG,EAAE,EAAE;IAChC,GAAG,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qCAAqC;AAGrC,MAAM,MAAM,GAAc,CAAC,GAAG,EAAE,EAAE;IAChC,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import InjectPlugin from 'webpack-inject-plugin';
2
2
  export default class SheetPlugin extends InjectPlugin {
3
- constructor(cssName: string);
3
+ private cssName;
4
+ constructor(cssName: string, name: string);
5
+ apply(compiler: any): void;
4
6
  }