lincd-cli 0.1.6 → 0.1.9

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 (54) hide show
  1. package/{src/cli.js → cli.js} +2 -2
  2. package/config-generator.js +568 -0
  3. package/defaults/app/Gruntfile.js +13 -0
  4. package/defaults/app/index.html +12 -0
  5. package/defaults/{package.json → app/package.json} +4 -2
  6. package/defaults/app/tsconfig-es5.json +18 -0
  7. package/defaults/module/.npmignore +6 -0
  8. package/defaults/module/package.json +14 -6
  9. package/defaults/shape.ts +8 -0
  10. package/{src/index.js → index.js} +9 -5
  11. package/lib/cli.js +362 -107
  12. package/lib/config-grunt.js +34 -30
  13. package/lib/config-webpack.js +9 -7
  14. package/lib/index.js +5 -1
  15. package/lib/plugins/declaration-plugin.js +9 -9
  16. package/lib/plugins/externalise-modules.js +13 -13
  17. package/lib/plugins/watch-run.js +1 -1
  18. package/lib/utils.js +5 -1
  19. package/package.json +12 -10
  20. package/{src/plugins → plugins}/declaration-plugin.js +0 -0
  21. package/{src/plugins → plugins}/externalise-modules.js +0 -0
  22. package/{src/plugins → plugins}/watch-run.js +0 -0
  23. package/utils.js +39 -0
  24. package/defaults/create_migration.js +0 -155
  25. package/defaults/create_migration.ts +0 -7
  26. package/defaults/defaultModule/Index.js +0 -30
  27. package/defaults/defaultModule/Index.scss +0 -19
  28. package/defaults/defaultModule/Index.tsx +0 -25
  29. package/defaults/defaultModule/data.json +0 -56
  30. package/defaults/defaultModule/defaultOntology.json +0 -23
  31. package/defaults/defaultModule/index.ts +0 -12
  32. package/defaults/defaultModule/ontology.js +0 -21
  33. package/defaults/defaultModule/ontology.ts +0 -16
  34. package/defaults/gitignorefile +0 -4
  35. package/defaults/index.ts +0 -13
  36. package/defaults/module/src/components/ExampleComponent.tsx +0 -22
  37. package/defaults/module/src/data/example-ontology.json +0 -20
  38. package/defaults/module/src/data/example-ontology.json.d.ts +0 -1
  39. package/defaults/module/src/index.ts +0 -7
  40. package/defaults/module/src/module.ts +0 -9
  41. package/defaults/module/src/ontologies/example-ontology.ts +0 -33
  42. package/defaults/module/src/shapes/ExampleShapeClass.ts +0 -30
  43. package/defaults/ontology.ts +0 -16
  44. package/defaults/providers.ts +0 -1
  45. package/defaults/site/package.json +0 -40
  46. package/defaults/site/storage/filestores/settings-production-template.jsonld +0 -129
  47. package/defaults/site/web/.htaccess +0 -19
  48. package/defaults/site/web/favicon.png +0 -0
  49. package/defaults/site/web/img/placeholder.jpg +0 -0
  50. package/src/config-grunt.js +0 -263
  51. package/src/config-webpack.js +0 -281
  52. package/src/interfaces.js +0 -2
  53. package/src/plugins/shapes-plugin.js +0 -69
  54. package/src/utils.js +0 -127
@@ -1,263 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- exports.__esModule = true;
12
- exports.setupGrunt = void 0;
13
- var config_webpack_1 = require("./config-webpack");
14
- var fs = require('fs');
15
- var chalk = require('chalk');
16
- var path = require('path');
17
- var utils_1 = require("./utils");
18
- function generateGruntConfig(moduleName, config) {
19
- if (config === void 0) { config = {}; }
20
- return function (grunt) {
21
- setupGrunt(grunt, moduleName, config);
22
- };
23
- }
24
- exports["default"] = generateGruntConfig;
25
- function setupGrunt(grunt, moduleName, config) {
26
- var buildServer = !config.environment || config.environment == 'server';
27
- var buildFrontend = !config.environment || config.environment == 'frontend';
28
- //when not specified and we ARe building frontend OR we are compiling the server for es5.. or if simply specified, then es5 is targeted
29
- var targetES5 = (!config.target && (buildFrontend || config.es5Server)) ||
30
- config.target == 'es5';
31
- var targetES6 = !config.target || config.target == 'es6';
32
- var targets = [];
33
- if (targetES5)
34
- targets.push('es5');
35
- if (targetES6)
36
- targets.push('es6');
37
- var targetLog = 'building ' + targets.join(', ');
38
- if (buildServer && !buildFrontend) {
39
- (0, utils_1.log)(targetLog + ' lib only');
40
- }
41
- else if (!buildServer && buildFrontend) {
42
- (0, utils_1.log)(targetLog + ' dist bundles only');
43
- }
44
- else if (buildServer && buildFrontend) {
45
- if (config.es5Server) {
46
- (0, utils_1.log)(targetLog + ' lib files & dist bundles');
47
- }
48
- else {
49
- (0, utils_1.log)(targetLog + ' dist bundles and es6 lib files');
50
- }
51
- }
52
- else {
53
- (0, utils_1.log)('invalid configuration combination');
54
- }
55
- require('load-grunt-tasks')(grunt);
56
- //defaults
57
- grunt.registerTask('default', ['prepare-build', 'concurrent:dev']);
58
- grunt.registerTask('dev', targetES6 ? ['prepare-build', 'dev-es6'] : ['prepare-build', 'dev-es5']);
59
- grunt.registerTask('build', targets.map(function (target) { return 'build-' + target; }));
60
- if (buildFrontend) {
61
- grunt.registerTask('build-frontend', __spreadArray([
62
- 'prepare-build'
63
- ], targets.map(function (target) { return 'webpack:build-' + target; }), true));
64
- }
65
- grunt.registerTask('build-production', (0, utils_1.flatten)([
66
- 'clean:lib',
67
- 'prepare-build',
68
- buildFrontend ? targets.map(function (target) { return 'webpack:prod-' + target; }) : null,
69
- buildServer ? ['exec:build-lib'] : null,
70
- ]));
71
- var prepareBuild = ['postcss:cssjson'];
72
- if (config.beforeBuildCommand) {
73
- prepareBuild.push('exec:beforeBuildCommand');
74
- }
75
- //specific tasks
76
- grunt.registerTask('prepare-build', prepareBuild);
77
- grunt.registerTask('dev-es6-production', [
78
- 'prepare-build',
79
- 'concurrent:dev-prod',
80
- ]);
81
- grunt.registerTask('dev-es6', ['prepare-build', 'concurrent:dev']);
82
- grunt.registerTask('dev-es5', ['prepare-build', 'concurrent:dev-es5']);
83
- //build-es5 is by default just the frontend because the server is es6
84
- //however some specific modules (like @dacore/module) require the typescript compiler ('build-lib') to run for es5
85
- //so that core-es5 or browser-core-es5 can internalise its files
86
- //this can by triggered with es5Server
87
- grunt.registerTask('build-es5', (0, utils_1.flatten)([
88
- 'postcss',
89
- buildFrontend ? 'webpack:build-es5' : null,
90
- config.es5Server ? ['exec:build-lib-es5', 'copy:lib'] : null,
91
- ]));
92
- grunt.registerTask('build-es6', (0, utils_1.flatten)([
93
- 'prepare-build',
94
- buildFrontend ? 'webpack:build-es6' : null,
95
- buildServer ? ['clean:lib', 'exec:build-lib'] : null,
96
- // 'exec:shapes',
97
- ]));
98
- grunt.registerTask('build-lib', [
99
- 'prepare-build',
100
- 'exec:build-lib',
101
- 'copy:lib',
102
- ]);
103
- grunt.registerTask('build-production-es5', [
104
- 'prepare-build',
105
- 'webpack:prod-es5',
106
- // 'exec:shapes',
107
- ]);
108
- grunt.registerTask('build-production-es6', [
109
- 'prepare-build',
110
- 'webpack:prod-es6',
111
- // 'exec:shapes',
112
- ]);
113
- // log('setting grunt config');
114
- grunt.initConfig({
115
- exec: {
116
- 'build-lib': 'tsc --pretty',
117
- 'build-lib-es5': 'tsc --pretty -p tsconfig-es5.json',
118
- beforeBuildCommand: config.beforeBuildCommand,
119
- 'server-dev': 'tsc -w',
120
- test: 'tsc -w',
121
- // shapes: 'lincd shapes',
122
- 'css-declarations': 'tcm -p **/*.scss',
123
- 'postcss-modules': 'yarn postcss --use postcss-import postcss-cssnext postcss-nested postcss-modules -o build/draft.css -i scss/*'
124
- },
125
- copy: {
126
- lib: {
127
- files: [
128
- // copy json files in src over to lib
129
- {
130
- expand: true,
131
- src: ['**/*.json', '**/*.json.d.ts'],
132
- dest: 'lib/',
133
- cwd: 'src/',
134
- filter: 'isFile'
135
- },
136
- ]
137
- }
138
- },
139
- postcss: {
140
- options: {
141
- map: true,
142
- processors: [require('postcss-modules')({ generateScopedName: utils_1.generateScopedName })],
143
- syntax: require('postcss-scss'),
144
- writeDest: false
145
- },
146
- cssjson: {
147
- src: 'src/**/*.scss'
148
- }
149
- },
150
- clean: {
151
- lib: ['lib/']
152
- },
153
- concurrent: {
154
- dev: (0, utils_1.flatten)([
155
- buildFrontend ? 'webpack:dev' : null,
156
- buildServer ? 'exec:server-dev' : null,
157
- // buildServer ? 'watch:css-module-transforms' : null,
158
- // 'exec:css-declarations-watch'
159
- ]),
160
- 'dev-prod': (0, utils_1.flatten)([
161
- buildFrontend ? 'webpack:dev-prod' : null,
162
- buildServer ? 'exec:server-dev' : null,
163
- // buildServer ? 'watch:css-module-transforms' : null,
164
- // 'exec:css-declarations-watch'
165
- ]),
166
- 'dev-es5': (0, utils_1.flatten)([
167
- buildFrontend ? 'webpack:dev-es5' : null,
168
- buildServer ? 'exec:server-dev' : null,
169
- // buildServer ? 'watch:css-module-transforms' : null,
170
- // 'exec:css-declarations-watch'
171
- ]),
172
- options: {
173
- logConcurrentOutput: true,
174
- logTaskName: 3,
175
- logBlacklist: []
176
- }
177
- },
178
- webpack: {
179
- options: {
180
- stats: {
181
- chunks: false,
182
- version: false,
183
- warningsFilter: function (warning) {
184
- return warning.indexOf('There are multiple modules') !== -1;
185
- }
186
- }
187
- },
188
- dev: (0, config_webpack_1.generateWebpackConfig)('dev', moduleName, Object.assign({
189
- target: 'es6',
190
- watch: true
191
- }, config, config.es6, config.dev)),
192
- 'dev-prod': (0, config_webpack_1.generateWebpackConfig)('dev', moduleName, Object.assign({
193
- target: 'es6',
194
- watch: true,
195
- productionMode: true
196
- }, config, config.es6, config.prod)),
197
- 'dev-es5': (0, config_webpack_1.generateWebpackConfig)('dev-es5', moduleName, Object.assign({
198
- target: 'es5',
199
- watch: true
200
- }, config, config.es5, config.dev)),
201
- 'build-es6': (0, config_webpack_1.generateWebpackConfig)('build-es6', moduleName, Object.assign({
202
- target: 'es6',
203
- watch: false
204
- }, config, config.es6, config.dev)),
205
- 'build-es5': (0, config_webpack_1.generateWebpackConfig)('build-es5', moduleName, Object.assign({
206
- target: 'es5',
207
- watch: false
208
- }, config, config.es5, config.dev)),
209
- 'prod-es5': (0, config_webpack_1.generateWebpackConfig)('prod-es5', moduleName, Object.assign({
210
- target: 'es5',
211
- watch: false,
212
- productionMode: true
213
- }, config, config.es5, config.prod)),
214
- 'prod-es6': (0, config_webpack_1.generateWebpackConfig)('prod-es6', moduleName, Object.assign({
215
- target: 'es6',
216
- watch: false,
217
- productionMode: true
218
- }, config, config.es6, config.prod))
219
- }
220
- });
221
- grunt.config.init.exec = {
222
- test: 'echo "yey"'
223
- };
224
- //load the npm grunt task modules
225
- [
226
- 'grunt-webpack',
227
- 'grunt-exec',
228
- 'grunt-concurrent',
229
- 'grunt-contrib-clean',
230
- 'grunt-contrib-copy',
231
- '@lodder/grunt-postcss',
232
- ].forEach(function (taskName) {
233
- (0, utils_1.debug)(config, 'loading grunt task ' + taskName);
234
- var localPath = path.resolve(__dirname, 'node_modules', taskName, 'tasks');
235
- var localPath2 = path.resolve(__dirname, '..', 'node_modules', taskName, 'tasks');
236
- var workspacePath = path.resolve(__dirname, '..', '..', 'node_modules', taskName, 'tasks');
237
- var nestedWorkspacePath = path.resolve(__dirname, '..', '..', '..', 'node_modules', taskName, 'tasks');
238
- if (fs.existsSync(localPath)) {
239
- // grunt.loadNpmTasks(taskName);
240
- (0, utils_1.debug)('Loading from ' + localPath);
241
- grunt.task.loadTasks(localPath);
242
- }
243
- else if (fs.existsSync(localPath2)) {
244
- // grunt.loadNpmTasks(taskName);
245
- (0, utils_1.debug)('Loading from ' + localPath2);
246
- grunt.task.loadTasks(localPath2);
247
- }
248
- else if (fs.existsSync(workspacePath)) {
249
- //windows, so it seems
250
- (0, utils_1.debug)('Loading from ' + workspacePath);
251
- grunt.task.loadTasks(workspacePath);
252
- }
253
- else if (fs.existsSync(nestedWorkspacePath)) {
254
- //mac / linux
255
- (0, utils_1.debug)('Loading from ' + nestedWorkspacePath);
256
- grunt.task.loadTasks(nestedWorkspacePath);
257
- }
258
- else {
259
- (0, utils_1.warn)("Could not load grunt task module ".concat(taskName, "\nCould not find task at any of these paths:\n").concat(localPath, "\n").concat(localPath2, "\n").concat(workspacePath, "\n").concat(nestedWorkspacePath));
260
- }
261
- });
262
- }
263
- exports.setupGrunt = setupGrunt;
@@ -1,281 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- exports.__esModule = true;
17
- exports.generateWebpackConfig = void 0;
18
- var declaration_plugin_1 = __importDefault(require("./plugins/declaration-plugin"));
19
- var externalise_modules_1 = __importDefault(require("./plugins/externalise-modules"));
20
- var watch_run_1 = __importDefault(require("./plugins/watch-run"));
21
- var utils_1 = require("./utils");
22
- var colors = require("colors");
23
- var shared_1 = require("./shared");
24
- var fs = require('fs');
25
- var MiniCssExtractPlugin = require('mini-css-extract-plugin');
26
- var chalk = require('chalk');
27
- var webpack = require('webpack');
28
- var path = require('path');
29
- var ExtractTextPlugin = require('extract-text-webpack-plugin');
30
- var WebpackLicencePlugin = require('webpack-license-plugin');
31
- var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
32
- var BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
33
- .BundleAnalyzerPlugin;
34
- var TerserPlugin = require('terser-webpack-plugin');
35
- var exec = require('child_process').exec;
36
- var NODE_ENV = process.env.NODE_ENV;
37
- var nodeProduction = NODE_ENV == 'production';
38
- var libraryName = 'lincd';
39
- function generateWebpackConfig(buildName, moduleName, config) {
40
- if (config === void 0) { config = {}; }
41
- if (!config.externals)
42
- config.externals = {};
43
- if (!config.internals)
44
- config.internals = [];
45
- var watch = config.watch;
46
- var productionMode = nodeProduction || config.productionMode;
47
- var es5 = config.target == 'es5';
48
- var es6 = config.target == 'es6';
49
- var configFile;
50
- if (es5 && fs.existsSync('tsconfig-es5.json')) {
51
- configFile = 'tsconfig-es5.json';
52
- }
53
- else {
54
- configFile = 'tsconfig.json';
55
- }
56
- if (!fs.existsSync(configFile)) {
57
- (0, utils_1.warn)('Cannot find ' + configFile);
58
- process.exit();
59
- }
60
- var tsConfig = JSON.parse(fs.readFileSync(configFile));
61
- //Because it's not for webpack, and its breaks ts-loader, here we undo the tsc setting that would copy all json files to lib folder, see https://github.com/swimauger/tsc-hooks
62
- // delete tsConfig['hooks'];
63
- // delete tsConfig['files'];
64
- var pack = (0, utils_1.getPackageJSON)();
65
- var plugins = [
66
- new webpack.DefinePlugin({
67
- 'process.env.BROWSER': JSON.stringify(true),
68
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
69
- }),
70
- new webpack.NoEmitOnErrorsPlugin(),
71
- new ExtractTextPlugin(config.cssFileName
72
- ? config.cssFileName
73
- : libraryName + '.' + moduleName + '.css'),
74
- new MiniCssExtractPlugin({
75
- // linkType: false,
76
- filename: config.cssFileName
77
- ? config.cssFileName
78
- : libraryName + '.' + moduleName + '.css'
79
- }),
80
- new WebpackLicencePlugin({
81
- excludedPackageTest: function (packageName, version) {
82
- return packageName.indexOf('lincd') !== -1;
83
- }
84
- }),
85
- //output sometimes includes things like webpack, which seems not needed? this doesn't work though
86
- // {
87
- // excludedPackageTest:((packageName, packageVersion) => {
88
- // return pack.devDependencies && packageName in pack.devDependencies;
89
- // })
90
- // }
91
- ];
92
- if (config.debug) {
93
- plugins.push(new watch_run_1["default"]());
94
- }
95
- if (config.afterBuildCommand) {
96
- plugins.push({
97
- apply: function (compiler) {
98
- compiler.hooks.afterEmit.tap('AfterEmitPlugin', function (compilation) {
99
- exec(config.afterBuildCommand, function (err, stdout, stderr) {
100
- if (stdout)
101
- process.stdout.write(stdout);
102
- if (stderr)
103
- process.stderr.write(stderr);
104
- });
105
- });
106
- }
107
- });
108
- }
109
- if (config.analyse) {
110
- plugins.push(new BundleAnalyzerPlugin());
111
- }
112
- if (es6 || config.declarations === true) {
113
- plugins.push(new declaration_plugin_1["default"]({
114
- out: (config.filename ? config.filename : libraryName + '.' + moduleName) +
115
- '.d.ts',
116
- root: config.outputPath ? config.outputPath : './lib/',
117
- debug: 'debug' in config ? config.debug : false
118
- }));
119
- }
120
- var resolvePlugins = [
121
- new TsconfigPathsPlugin({
122
- configFile: configFile,
123
- silent: true
124
- }),
125
- ];
126
- var aliases = config.alias || {};
127
- var rules = [
128
- {
129
- test: /\.(scss|css)$/,
130
- use: [
131
- MiniCssExtractPlugin.loader,
132
- {
133
- loader: 'css-loader',
134
- options: {
135
- url: false
136
- }
137
- },
138
- {
139
- loader: 'postcss-loader',
140
- options: {
141
- postcssOptions: {
142
- plugins: {
143
- 'postcss-import': {},
144
- 'postcss-cssnext': {},
145
- 'postcss-nested': {},
146
- // "postcss-scss": {}, //<-- only add this back if the build gets stuck on //comments in scss files, but I dont think that will be the case anymore
147
- 'postcss-modules': {
148
- //by default postcss-modules will put out a json file right next to the original css / scss file, this method defines what classnames to use
149
- generateScopedName: shared_1.generateScopedName,
150
- globalModulePaths: [/tailwind/]
151
- },
152
- tailwindcss: {
153
- purge: {
154
- enabled: productionMode,
155
- content: [
156
- './src/**/*.tsx',
157
- './src/**/*.ts',
158
- //also include @dacore modules which are internalized with the "internal" config option
159
- //imports like ... from '@dacore/module/lib/views/SomeView' will
160
- //these modules should live in the node_modules folder of the root of the site
161
- //TODO: remake this with multiple lincd modules
162
- // '../../node_modules/@dacore/*/lib/**/*.js',
163
- // './node_modules/@dacore/*/lib/**/*.js',
164
- ]
165
- }
166
- }
167
- }
168
- }
169
- }
170
- },
171
- {
172
- loader: 'sass-loader',
173
- options: { sourceMap: true }
174
- },
175
- ]
176
- },
177
- {
178
- test: /\.tsx?$/,
179
- use: [
180
- {
181
- loader: 'ts-loader?' +
182
- JSON.stringify(__assign(__assign(__assign({}, tsConfig), { compilerOptions: {
183
- declaration: !es5,
184
- /*
185
- for webpack we overwrite the module settings of the modules' tsconfig file
186
- because we NEED esnext for code splitting. But the VM we currently use for the registry does not support esnext modules
187
- */
188
- module: 'esnext',
189
- moduleResolution: 'node'
190
- } }), config.tsConfigOverwrites))
191
- },
192
- ]
193
- },
194
- {
195
- enforce: 'pre',
196
- test: /\.js$/,
197
- use: [
198
- {
199
- loader: 'source-map-loader'
200
- },
201
- ]
202
- },
203
- ];
204
- if (es5 && config.internalsources && config.internalsources.length > 0) {
205
- //usually a module that transpiles to es5 will only have es5 code in the bundle.
206
- //however a module that INTERNALISES other dacore modules will directly include es6 code from @dacore/other_modules/lib
207
- //which eventually results in an import of @dacore/core being bundled as 'const =', which trips up old browsers
208
- //so we fix that here by just referring directly to the typescript source instead of the transpiled js for internalised modules
209
- //however this means that for internalised modules THE SOURCE CODE NEEDS TO BE AVAILABLE. This is currently NOT the case with how we publish modules to yarn
210
- //so that means internalised modules need to be LOCALLY AVAILABLE with yarn workspaces
211
- plugins.push(new webpack.NormalModuleReplacementPlugin(/\lincd\/lib\//, function (resource, match) {
212
- var moduleName = resource.request.match(/lincd\/lib\//)[1];
213
- if (config.internalsources.indexOf(moduleName) !== -1) {
214
- console.log(colors.magenta('internal sources + ES5: Replacing /lib/ with /src/ for source-internalised module ' +
215
- moduleName));
216
- resource.request = resource.request.replace('/lib/', '/src/');
217
- console.log(colors.magenta('internal sources + ES5: ' + resource.request));
218
- console.log(colors.red("WARNING: Make sure you have the TYPESCRIPT SOURCE FILES of the modules listed as 'internal' AVAILABLE ON YOUR LOCAL MACHINE. So if you check in node_modules/your-internalised-module - that should be a symbolic link and you will find a 'src' folder with typescript files there."));
219
- }
220
- }));
221
- }
222
- return {
223
- entry: config.entry ? config.entry : './src/index.ts',
224
- output: {
225
- filename: (config.filename ? config.filename : libraryName + '.' + moduleName) +
226
- (es5 ? '.es5' : '') +
227
- '.js',
228
- path: path.resolve(process.cwd(), config.bundlePath || 'dist'),
229
- devtoolModuleFilenameTemplate: moduleName + '/[resource-path]'
230
- },
231
- devtool: productionMode ? 'cheap-source-map' : 'cheap-source-map',
232
- mode: productionMode ? 'production' : 'development',
233
- //fixing a persistent but strange build error here that showed up once, this is a workaround. See: https://github.com/webpack-contrib/css-loader/issues/447
234
- node: {
235
- fs: 'empty',
236
- child_process: 'empty'
237
- },
238
- resolve: {
239
- extensions: ['.webpack.js', '.js', '.ts', '.tsx', '.json'],
240
- alias: aliases,
241
- plugins: resolvePlugins
242
- },
243
- resolveLoader: {
244
- modules: [
245
- path.join(__dirname, 'plugins'),
246
- path.join(__dirname, 'node_modules'),
247
- 'node_modules',
248
- ]
249
- },
250
- optimization: {
251
- minimize: productionMode,
252
- minimizer: [
253
- new TerserPlugin({
254
- extractComments: {
255
- condition: /^\**!|@preserve|@license|@cc_on/i,
256
- banner: function (licenseFile) {
257
- return "License information can be found in ".concat(licenseFile, " and oss-licences.json");
258
- }
259
- }
260
- }),
261
- ]
262
- },
263
- watch: watch,
264
- module: {
265
- rules: rules
266
- },
267
- //See plugins/externalise-modules.ts We're passing in a function here that determines what to exclude from the bundle and what not
268
- //See also https://webpack.js.org/configuration/externals/
269
- externals: (0, externalise_modules_1["default"])(config, es5),
270
- plugins: plugins,
271
- stats: {
272
- errorDetails: config.debug,
273
- chunks: false,
274
- children: false,
275
- version: true,
276
- hash: false,
277
- modules: false
278
- }
279
- };
280
- }
281
- exports.generateWebpackConfig = generateWebpackConfig;
package/src/interfaces.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- /// <reference path="colors.d.ts" />
4
- var colors = require("colors");
5
- var ShapesPlugin = /** @class */ (function () {
6
- function ShapesPlugin(options) {
7
- if (options === void 0) { options = {}; }
8
- this.shapeFiles = [];
9
- this.logMessages = true;
10
- this.exportRoot = '/lib';
11
- this.logMessages = options.debug ? options.debug : false;
12
- }
13
- ShapesPlugin.prototype.apply = function (compiler) {
14
- var _this = this;
15
- this.debug('applying');
16
- //when the compiler is ready to emit files
17
- // compiler.plugin('emit', (compilation,callback) =>
18
- compiler.hooks.emit.tapAsync('DeclarationPlugin', function (compilation, callback) {
19
- // this.debug('emitted');
20
- _this.debug(Object.keys(compilation.assets));
21
- //collect all generated shape files
22
- //NOTE: at some point we decided to overwrite declaration files between emits because sometimes only one new declaration file is emitted
23
- //this may cause issues when you remove a file during the continuous building process, but better than the other way around for now
24
- for (var filename in compilation.assets) {
25
- if (filename.indexOf('.js') !== -1 &&
26
- filename.indexOf('.map') === -1) {
27
- _this.debug(filename, Object.keys(compilation.assets[filename]));
28
- // require(filename);
29
- // this.declarationFiles[filename] = compilation.assets[filename];
30
- // this.debug('not using: '+filename);
31
- // delete compilation.assets[filename];
32
- }
33
- }
34
- //and insert that back into the assets
35
- // compilation.assets[this.options.out] = {
36
- // source: function () {
37
- // return combinedDeclaration;
38
- // },
39
- // size: function () {
40
- // return combinedDeclaration.length;
41
- // },
42
- // };
43
- //webpack may continue now
44
- callback();
45
- });
46
- };
47
- ShapesPlugin.prototype.debug = function () {
48
- var msgs = [];
49
- for (var _i = 0; _i < arguments.length; _i++) {
50
- msgs[_i] = arguments[_i];
51
- }
52
- msgs.unshift('shapes:');
53
- // if (this.logMessages) {
54
- msgs = msgs.map(function (msg) { return colors.blue(msg); });
55
- console.log.apply(null, msgs);
56
- // }
57
- };
58
- ShapesPlugin.prototype.log = function () {
59
- var msgs = [];
60
- for (var _i = 0; _i < arguments.length; _i++) {
61
- msgs[_i] = arguments[_i];
62
- }
63
- msgs.unshift('shapes:');
64
- msgs = msgs.map(function (msg) { return colors.blue(msg); });
65
- console.log.apply(null, msgs);
66
- };
67
- return ShapesPlugin;
68
- }());
69
- exports["default"] = ShapesPlugin;