lincd-cli 0.1.2 → 0.1.4
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 +24 -23
- package/defaults/defaultModule/Index.tsx +24 -24
- package/defaults/defaultModule/index.ts +1 -1
- package/defaults/defaultModule/ontology.ts +1 -1
- package/defaults/index.ts +1 -1
- package/defaults/module/Gruntfile.js +16 -0
- package/defaults/module/package.json +29 -0
- package/defaults/module/src/components/ExampleComponent.tsx +22 -0
- package/defaults/module/src/data/example-ontology.json +20 -0
- package/defaults/module/src/data/example-ontology.json.d.ts +1 -0
- package/defaults/module/src/index.ts +7 -0
- package/defaults/module/src/module.ts +9 -0
- package/defaults/module/src/ontologies/example-ontology.ts +33 -0
- package/defaults/module/src/shapes/ExampleShapeClass.ts +30 -0
- package/defaults/module/tsconfig-es5.json +19 -0
- package/defaults/module/tsconfig.json +19 -0
- package/defaults/ontology.ts +1 -1
- package/defaults/package.json +28 -24
- package/defaults/site/.gitignore +8 -0
- package/defaults/site/.npmignore +10 -0
- package/defaults/site/lib/start-server.js +22 -0
- package/defaults/site/lib/test-server.js +10 -0
- package/defaults/site/package.json +40 -0
- package/defaults/site/storage/filestores/settings-development.jsonld +117 -0
- package/defaults/site/storage/filestores/settings-production-template.jsonld +129 -0
- package/defaults/site/web/.htaccess +19 -0
- package/defaults/site/web/favicon.png +0 -0
- package/defaults/site/web/img/placeholder.jpg +0 -0
- package/defaults/tsconfig-es5.json +18 -19
- package/defaults/tsconfig.json +20 -21
- package/lib/cli.js +1074 -0
- package/lib/config-grunt.js +254 -0
- package/lib/config-webpack.js +273 -0
- package/{index.js → lib/index.js} +8 -4
- package/lib/interfaces.js +2 -0
- package/{plugins → lib/plugins}/declaration-plugin.js +3 -3
- package/lib/plugins/externalise-modules.js +165 -0
- package/{plugins → lib/plugins}/watch-run.js +0 -0
- package/lib/utils.js +127 -0
- package/package.json +71 -68
- package/{cli.js → src/cli.js} +54 -93
- package/src/config-grunt.js +263 -0
- package/src/config-webpack.js +281 -0
- package/src/index.js +22 -0
- package/src/interfaces.js +2 -0
- package/src/plugins/declaration-plugin.js +248 -0
- package/{plugins → src/plugins}/externalise-modules.js +8 -6
- package/src/plugins/shapes-plugin.js +69 -0
- package/src/plugins/watch-run.js +47 -0
- package/src/utils.js +127 -0
- package/config-generator.js +0 -545
- package/utils.js +0 -17
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
3
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
4
|
+
to[j] = from[i];
|
|
5
|
+
return to;
|
|
6
|
+
};
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
var config_webpack_1 = require("./config-webpack");
|
|
9
|
+
var fs = require('fs');
|
|
10
|
+
var chalk = require('chalk');
|
|
11
|
+
var path = require('path');
|
|
12
|
+
var utils_1 = require("./utils");
|
|
13
|
+
function generateGruntConfig(moduleName, config) {
|
|
14
|
+
if (config === void 0) { config = {}; }
|
|
15
|
+
return function (grunt) {
|
|
16
|
+
setupGrunt(grunt, moduleName, config);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports["default"] = generateGruntConfig;
|
|
20
|
+
function setupGrunt(grunt, moduleName, config) {
|
|
21
|
+
var buildServer = !config.environment || config.environment == 'server';
|
|
22
|
+
var buildFrontend = !config.environment || config.environment == 'frontend';
|
|
23
|
+
//when not specified and we ARe building frontend OR we are compiling the server for es5.. or if simply specified, then es5 is targeted
|
|
24
|
+
var targetES5 = (!config.target && (buildFrontend || config.es5Server)) ||
|
|
25
|
+
config.target == 'es5';
|
|
26
|
+
var targetES6 = !config.target || config.target == 'es6';
|
|
27
|
+
var targets = [];
|
|
28
|
+
if (targetES5)
|
|
29
|
+
targets.push('es5');
|
|
30
|
+
if (targetES6)
|
|
31
|
+
targets.push('es6');
|
|
32
|
+
var targetLog = 'building ' + targets.join(', ');
|
|
33
|
+
if (buildServer && !buildFrontend) {
|
|
34
|
+
utils_1.log(targetLog + ' lib only');
|
|
35
|
+
}
|
|
36
|
+
else if (!buildServer && buildFrontend) {
|
|
37
|
+
utils_1.log(targetLog + ' dist bundles only');
|
|
38
|
+
}
|
|
39
|
+
else if (buildServer && buildFrontend) {
|
|
40
|
+
if (config.es5Server) {
|
|
41
|
+
utils_1.log(targetLog + ' lib files & dist bundles');
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
utils_1.log(targetLog + ' dist bundles and es6 lib files');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
utils_1.log('invalid configuration combination');
|
|
49
|
+
}
|
|
50
|
+
require('load-grunt-tasks')(grunt);
|
|
51
|
+
//defaults
|
|
52
|
+
grunt.registerTask('default', ['prepare-build', 'concurrent:dev']);
|
|
53
|
+
grunt.registerTask('dev', targetES6 ? ['prepare-build', 'dev-es6'] : ['prepare-build', 'dev-es5']);
|
|
54
|
+
grunt.registerTask('build', targets.map(function (target) { return 'build-' + target; }));
|
|
55
|
+
if (buildFrontend) {
|
|
56
|
+
grunt.registerTask('build-frontend', __spreadArray([
|
|
57
|
+
'prepare-build'
|
|
58
|
+
], targets.map(function (target) { return 'webpack:build-' + target; })));
|
|
59
|
+
}
|
|
60
|
+
grunt.registerTask('build-production', utils_1.flatten([
|
|
61
|
+
'clean:lib',
|
|
62
|
+
'prepare-build',
|
|
63
|
+
buildFrontend ? targets.map(function (target) { return 'webpack:prod-' + target; }) : null,
|
|
64
|
+
buildServer ? ['exec:build-lib', 'copy:lib'] : null,
|
|
65
|
+
]));
|
|
66
|
+
var prepareBuild = ['postcss:cssjson'];
|
|
67
|
+
if (config.beforeBuildCommand) {
|
|
68
|
+
prepareBuild.push('exec:beforeBuildCommand');
|
|
69
|
+
}
|
|
70
|
+
//specific tasks
|
|
71
|
+
grunt.registerTask('prepare-build', prepareBuild);
|
|
72
|
+
grunt.registerTask('dev-es6-production', [
|
|
73
|
+
'prepare-build',
|
|
74
|
+
'concurrent:dev-prod',
|
|
75
|
+
]);
|
|
76
|
+
grunt.registerTask('dev-es6', ['prepare-build', 'concurrent:dev']);
|
|
77
|
+
grunt.registerTask('dev-es5', ['prepare-build', 'concurrent:dev-es5']);
|
|
78
|
+
//build-es5 is by default just the frontend because the server is es6
|
|
79
|
+
//however some specific modules (like @dacore/module) require the typescript compiler ('build-lib') to run for es5
|
|
80
|
+
//so that core-es5 or browser-core-es5 can internalise its files
|
|
81
|
+
//this can by triggered with es5Server
|
|
82
|
+
grunt.registerTask('build-es5', utils_1.flatten([
|
|
83
|
+
'postcss',
|
|
84
|
+
buildFrontend ? 'webpack:build-es5' : null,
|
|
85
|
+
config.es5Server ? ['exec:build-lib-es5', 'copy:lib'] : null,
|
|
86
|
+
]));
|
|
87
|
+
grunt.registerTask('build-es6', utils_1.flatten([
|
|
88
|
+
'prepare-build',
|
|
89
|
+
buildFrontend ? 'webpack:build-es6' : null,
|
|
90
|
+
buildServer ? ['clean:lib', 'exec:build-lib', 'copy:lib'] : null,
|
|
91
|
+
// 'exec:shapes',
|
|
92
|
+
]));
|
|
93
|
+
grunt.registerTask('build-lib', [
|
|
94
|
+
'prepare-build',
|
|
95
|
+
'exec:build-lib',
|
|
96
|
+
'copy:lib',
|
|
97
|
+
]);
|
|
98
|
+
grunt.registerTask('build-production-es5', [
|
|
99
|
+
'prepare-build',
|
|
100
|
+
'webpack:prod-es5',
|
|
101
|
+
// 'exec:shapes',
|
|
102
|
+
]);
|
|
103
|
+
grunt.registerTask('build-production-es6', [
|
|
104
|
+
'prepare-build',
|
|
105
|
+
'webpack:prod-es6',
|
|
106
|
+
// 'exec:shapes',
|
|
107
|
+
]);
|
|
108
|
+
// log('setting grunt config');
|
|
109
|
+
grunt.initConfig({
|
|
110
|
+
exec: {
|
|
111
|
+
'build-lib': 'tsc --pretty',
|
|
112
|
+
'build-lib-es5': 'tsc --pretty -p tsconfig-es5.json',
|
|
113
|
+
beforeBuildCommand: config.beforeBuildCommand,
|
|
114
|
+
'server-dev': 'tsc -w',
|
|
115
|
+
test: 'tsc -w',
|
|
116
|
+
// shapes: 'lincd shapes',
|
|
117
|
+
'css-declarations': 'tcm -p **/*.scss',
|
|
118
|
+
'postcss-modules': 'yarn postcss --use postcss-import postcss-cssnext postcss-nested postcss-modules -o build/draft.css -i scss/*'
|
|
119
|
+
},
|
|
120
|
+
copy: {
|
|
121
|
+
lib: {
|
|
122
|
+
files: [
|
|
123
|
+
// copy json files in src over to lib
|
|
124
|
+
{
|
|
125
|
+
expand: true,
|
|
126
|
+
src: ['**/*.json', '**/*.json.d.ts'],
|
|
127
|
+
dest: 'lib/',
|
|
128
|
+
cwd: 'src/',
|
|
129
|
+
filter: 'isFile'
|
|
130
|
+
},
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
postcss: {
|
|
135
|
+
options: {
|
|
136
|
+
map: true,
|
|
137
|
+
processors: [require('postcss-modules')({ generateScopedName: utils_1.generateScopedName })],
|
|
138
|
+
syntax: require('postcss-scss'),
|
|
139
|
+
writeDest: false
|
|
140
|
+
},
|
|
141
|
+
cssjson: {
|
|
142
|
+
src: 'src/**/*.scss'
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
clean: {
|
|
146
|
+
lib: ['lib/']
|
|
147
|
+
},
|
|
148
|
+
concurrent: {
|
|
149
|
+
dev: utils_1.flatten([
|
|
150
|
+
buildFrontend ? 'webpack:dev' : null,
|
|
151
|
+
buildServer ? 'exec:server-dev' : null,
|
|
152
|
+
// buildServer ? 'watch:css-module-transforms' : null,
|
|
153
|
+
// 'exec:css-declarations-watch'
|
|
154
|
+
]),
|
|
155
|
+
'dev-prod': utils_1.flatten([
|
|
156
|
+
buildFrontend ? 'webpack:dev-prod' : null,
|
|
157
|
+
buildServer ? 'exec:server-dev' : null,
|
|
158
|
+
// buildServer ? 'watch:css-module-transforms' : null,
|
|
159
|
+
// 'exec:css-declarations-watch'
|
|
160
|
+
]),
|
|
161
|
+
'dev-es5': utils_1.flatten([
|
|
162
|
+
buildFrontend ? 'webpack:dev-es5' : null,
|
|
163
|
+
buildServer ? 'exec:server-dev' : null,
|
|
164
|
+
// buildServer ? 'watch:css-module-transforms' : null,
|
|
165
|
+
// 'exec:css-declarations-watch'
|
|
166
|
+
]),
|
|
167
|
+
options: {
|
|
168
|
+
logConcurrentOutput: true,
|
|
169
|
+
logTaskName: 3,
|
|
170
|
+
logBlacklist: []
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
webpack: {
|
|
174
|
+
options: {
|
|
175
|
+
stats: {
|
|
176
|
+
chunks: false,
|
|
177
|
+
version: false,
|
|
178
|
+
warningsFilter: function (warning) {
|
|
179
|
+
return warning.indexOf('There are multiple modules') !== -1;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
dev: config_webpack_1.generateWebpackConfig('dev', moduleName, Object.assign({
|
|
184
|
+
target: 'es6',
|
|
185
|
+
watch: true
|
|
186
|
+
}, config, config.es6, config.dev)),
|
|
187
|
+
'dev-prod': config_webpack_1.generateWebpackConfig('dev', moduleName, Object.assign({
|
|
188
|
+
target: 'es6',
|
|
189
|
+
watch: true,
|
|
190
|
+
productionMode: true
|
|
191
|
+
}, config, config.es6, config.prod)),
|
|
192
|
+
'dev-es5': config_webpack_1.generateWebpackConfig('dev-es5', moduleName, Object.assign({
|
|
193
|
+
target: 'es5',
|
|
194
|
+
watch: true
|
|
195
|
+
}, config, config.es5, config.dev)),
|
|
196
|
+
'build-es6': config_webpack_1.generateWebpackConfig('build-es6', moduleName, Object.assign({
|
|
197
|
+
target: 'es6',
|
|
198
|
+
watch: false
|
|
199
|
+
}, config, config.es6, config.dev)),
|
|
200
|
+
'build-es5': config_webpack_1.generateWebpackConfig('build-es5', moduleName, Object.assign({
|
|
201
|
+
target: 'es5',
|
|
202
|
+
watch: false
|
|
203
|
+
}, config, config.es5, config.dev)),
|
|
204
|
+
'prod-es5': config_webpack_1.generateWebpackConfig('prod-es5', moduleName, Object.assign({
|
|
205
|
+
target: 'es5',
|
|
206
|
+
watch: false,
|
|
207
|
+
productionMode: true
|
|
208
|
+
}, config, config.es5, config.prod)),
|
|
209
|
+
'prod-es6': config_webpack_1.generateWebpackConfig('prod-es6', moduleName, Object.assign({
|
|
210
|
+
target: 'es6',
|
|
211
|
+
watch: false,
|
|
212
|
+
productionMode: true
|
|
213
|
+
}, config, config.es6, config.prod))
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
//load the npm grunt task modules
|
|
217
|
+
[
|
|
218
|
+
'grunt-webpack',
|
|
219
|
+
'grunt-exec',
|
|
220
|
+
'grunt-concurrent',
|
|
221
|
+
'grunt-contrib-clean',
|
|
222
|
+
'grunt-contrib-copy',
|
|
223
|
+
'@lodder/grunt-postcss',
|
|
224
|
+
].forEach(function (taskName) {
|
|
225
|
+
utils_1.debug(config, 'loading grunt task ' + taskName);
|
|
226
|
+
var localPath = path.resolve(__dirname, '..', 'node_modules', taskName, 'tasks');
|
|
227
|
+
var localPath2 = path.resolve(__dirname, '..', '..', 'node_modules', taskName, 'tasks');
|
|
228
|
+
var workspacePath = path.resolve(__dirname, '..', '..', '..', 'node_modules', taskName, 'tasks');
|
|
229
|
+
var nestedWorkspacePath = path.resolve(__dirname, '..', '..', '..', '..', 'node_modules', taskName, 'tasks');
|
|
230
|
+
if (fs.existsSync(localPath)) {
|
|
231
|
+
// grunt.loadNpmTasks(taskName);
|
|
232
|
+
utils_1.debug('Loading from ' + localPath);
|
|
233
|
+
grunt.task.loadTasks(localPath);
|
|
234
|
+
}
|
|
235
|
+
else if (fs.existsSync(localPath2)) {
|
|
236
|
+
// grunt.loadNpmTasks(taskName);
|
|
237
|
+
utils_1.debug('Loading from ' + localPath2);
|
|
238
|
+
grunt.task.loadTasks(localPath2);
|
|
239
|
+
}
|
|
240
|
+
else if (fs.existsSync(workspacePath)) {
|
|
241
|
+
//windows, so it seems
|
|
242
|
+
utils_1.debug('Loading from ' + workspacePath);
|
|
243
|
+
grunt.task.loadTasks(workspacePath);
|
|
244
|
+
}
|
|
245
|
+
else if (fs.existsSync(nestedWorkspacePath)) {
|
|
246
|
+
//mac / linux
|
|
247
|
+
utils_1.debug('Loading from ' + nestedWorkspacePath);
|
|
248
|
+
grunt.task.loadTasks(nestedWorkspacePath);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
utils_1.warn("Could not load grunt task module " + taskName + "\nCould not find task at any of these paths:\n" + localPath + "\n" + localPath2 + "\n" + workspacePath + "\n" + nestedWorkspacePath);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
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 fs = require('fs');
|
|
24
|
+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
25
|
+
var chalk = require('chalk');
|
|
26
|
+
var webpack = require('webpack');
|
|
27
|
+
var path = require('path');
|
|
28
|
+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
29
|
+
var WebpackLicencePlugin = require('webpack-license-plugin');
|
|
30
|
+
var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
31
|
+
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
|
|
32
|
+
.BundleAnalyzerPlugin;
|
|
33
|
+
var TerserPlugin = require('terser-webpack-plugin');
|
|
34
|
+
var exec = require('child_process').exec;
|
|
35
|
+
var NODE_ENV = process.env.NODE_ENV;
|
|
36
|
+
var nodeProduction = NODE_ENV == 'production';
|
|
37
|
+
var libraryName = 'lincd';
|
|
38
|
+
function generateWebpackConfig(buildName, moduleName, config) {
|
|
39
|
+
if (config === void 0) { config = {}; }
|
|
40
|
+
if (!config.externals)
|
|
41
|
+
config.externals = {};
|
|
42
|
+
if (!config.internals)
|
|
43
|
+
config.internals = [];
|
|
44
|
+
var watch = config.watch;
|
|
45
|
+
var productionMode = nodeProduction || config.productionMode;
|
|
46
|
+
var es5 = config.target == 'es5';
|
|
47
|
+
var es6 = config.target == 'es6';
|
|
48
|
+
var cleanModuleName = moduleName.replace(/@\w+\//, '');
|
|
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
|
+
utils_1.warn('Cannot find ' + configFile);
|
|
58
|
+
process.exit();
|
|
59
|
+
}
|
|
60
|
+
var plugins = [
|
|
61
|
+
new webpack.DefinePlugin({
|
|
62
|
+
'process.env.BROWSER': JSON.stringify(true),
|
|
63
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
|
64
|
+
}),
|
|
65
|
+
new webpack.NoEmitOnErrorsPlugin(),
|
|
66
|
+
new ExtractTextPlugin(config.cssFileName
|
|
67
|
+
? config.cssFileName
|
|
68
|
+
: libraryName + '.' + cleanModuleName + '.css'),
|
|
69
|
+
new MiniCssExtractPlugin({
|
|
70
|
+
// linkType: false,
|
|
71
|
+
filename: config.cssFileName
|
|
72
|
+
? config.cssFileName
|
|
73
|
+
: libraryName + '.' + cleanModuleName + '.css'
|
|
74
|
+
}),
|
|
75
|
+
new WebpackLicencePlugin({
|
|
76
|
+
excludedPackageTest: function (packageName, version) {
|
|
77
|
+
return packageName.indexOf('lincd') !== -1;
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
];
|
|
81
|
+
if (config.debug) {
|
|
82
|
+
plugins.push(new watch_run_1["default"]());
|
|
83
|
+
}
|
|
84
|
+
if (config.afterBuildCommand) {
|
|
85
|
+
plugins.push({
|
|
86
|
+
apply: function (compiler) {
|
|
87
|
+
compiler.hooks.afterEmit.tap('AfterEmitPlugin', function (compilation) {
|
|
88
|
+
exec(config.afterBuildCommand, function (err, stdout, stderr) {
|
|
89
|
+
if (stdout)
|
|
90
|
+
process.stdout.write(stdout);
|
|
91
|
+
if (stderr)
|
|
92
|
+
process.stderr.write(stderr);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (config.analyse) {
|
|
99
|
+
plugins.push(new BundleAnalyzerPlugin());
|
|
100
|
+
}
|
|
101
|
+
if (es6 || config.declarations === true) {
|
|
102
|
+
plugins.push(new declaration_plugin_1["default"]({
|
|
103
|
+
out: (config.filename
|
|
104
|
+
? config.filename
|
|
105
|
+
: libraryName + '.' + cleanModuleName) + '.d.ts',
|
|
106
|
+
root: config.outputPath ? config.outputPath : './lib/',
|
|
107
|
+
debug: 'debug' in config ? config.debug : false
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
var resolvePlugins = [
|
|
111
|
+
new TsconfigPathsPlugin({
|
|
112
|
+
configFile: configFile,
|
|
113
|
+
silent: true
|
|
114
|
+
}),
|
|
115
|
+
];
|
|
116
|
+
var aliases = config.alias || {};
|
|
117
|
+
var rules = [
|
|
118
|
+
{
|
|
119
|
+
test: /\.(scss|css)$/,
|
|
120
|
+
use: [
|
|
121
|
+
MiniCssExtractPlugin.loader,
|
|
122
|
+
{
|
|
123
|
+
loader: 'css-loader',
|
|
124
|
+
options: {
|
|
125
|
+
url: false
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
loader: 'postcss-loader',
|
|
130
|
+
options: {
|
|
131
|
+
postcssOptions: {
|
|
132
|
+
plugins: {
|
|
133
|
+
'postcss-import': {},
|
|
134
|
+
'postcss-cssnext': {},
|
|
135
|
+
'postcss-nested': {},
|
|
136
|
+
// "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
|
|
137
|
+
'postcss-modules': {
|
|
138
|
+
//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
|
|
139
|
+
generateScopedName: utils_1.generateScopedName,
|
|
140
|
+
globalModulePaths: [/tailwind/]
|
|
141
|
+
},
|
|
142
|
+
tailwindcss: {
|
|
143
|
+
purge: {
|
|
144
|
+
enabled: productionMode,
|
|
145
|
+
content: [
|
|
146
|
+
'./src/**/*.tsx',
|
|
147
|
+
'./src/**/*.ts',
|
|
148
|
+
//also include @dacore modules which are internalized with the "internal" config option
|
|
149
|
+
//imports like ... from '@dacore/module/lib/views/SomeView' will
|
|
150
|
+
//these modules should live in the node_modules folder of the root of the site
|
|
151
|
+
//TODO: remake this with multiple lincd modules
|
|
152
|
+
// '../../node_modules/@dacore/*/lib/**/*.js',
|
|
153
|
+
// './node_modules/@dacore/*/lib/**/*.js',
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
loader: 'sass-loader',
|
|
163
|
+
options: { sourceMap: true }
|
|
164
|
+
},
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
test: /\.tsx?$/,
|
|
169
|
+
use: [
|
|
170
|
+
{
|
|
171
|
+
loader: 'ts-loader?' +
|
|
172
|
+
JSON.stringify(__assign({ configFile: configFile, compilerOptions: {
|
|
173
|
+
declaration: !es5,
|
|
174
|
+
/*
|
|
175
|
+
for webpack we overwrite the module settings of the modules' tsconfig file
|
|
176
|
+
because we NEED esnext for code splitting. But the VM we currently use for the registry does not support esnext modules
|
|
177
|
+
*/
|
|
178
|
+
module: 'esnext',
|
|
179
|
+
moduleResolution: 'node'
|
|
180
|
+
} }, config.tsConfigOverwrites))
|
|
181
|
+
},
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
enforce: 'pre',
|
|
186
|
+
test: /\.js$/,
|
|
187
|
+
use: [
|
|
188
|
+
{
|
|
189
|
+
loader: 'source-map-loader'
|
|
190
|
+
},
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
];
|
|
194
|
+
if (es5 && config.internalsources && config.internalsources.length > 0) {
|
|
195
|
+
//usually a module that transpiles to es5 will only have es5 code in the bundle.
|
|
196
|
+
//however a module that INTERNALISES other dacore modules will directly include es6 code from @dacore/other_modules/lib
|
|
197
|
+
//which eventually results in an import of @dacore/core being bundled as 'const =', which trips up old browsers
|
|
198
|
+
//so we fix that here by just referring directly to the typescript source instead of the transpiled js for internalised modules
|
|
199
|
+
//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
|
|
200
|
+
//so that means internalised modules need to be LOCALLY AVAILABLE with yarn workspaces
|
|
201
|
+
plugins.push(new webpack.NormalModuleReplacementPlugin(/\lincd\/lib\//, function (resource, match) {
|
|
202
|
+
var moduleName = resource.request.match(/lincd\/lib\//)[1];
|
|
203
|
+
if (config.internalsources.indexOf(moduleName) !== -1) {
|
|
204
|
+
console.log(colors.magenta('internal sources + ES5: Replacing /lib/ with /src/ for source-internalised module ' +
|
|
205
|
+
moduleName));
|
|
206
|
+
resource.request = resource.request.replace('/lib/', '/src/');
|
|
207
|
+
console.log(colors.magenta('internal sources + ES5: ' + resource.request));
|
|
208
|
+
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."));
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
entry: config.entry ? config.entry : './src/index.ts',
|
|
214
|
+
output: {
|
|
215
|
+
filename: (config.filename
|
|
216
|
+
? config.filename
|
|
217
|
+
: libraryName + '.' + cleanModuleName) +
|
|
218
|
+
(es5 ? '.es5' : '') +
|
|
219
|
+
'.js',
|
|
220
|
+
path: path.resolve(process.cwd(), config.bundlePath || 'dist'),
|
|
221
|
+
devtoolModuleFilenameTemplate: moduleName + '/[resource-path]'
|
|
222
|
+
},
|
|
223
|
+
devtool: productionMode ? 'cheap-source-map' : 'cheap-source-map',
|
|
224
|
+
mode: productionMode ? 'production' : 'development',
|
|
225
|
+
//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
|
|
226
|
+
node: {
|
|
227
|
+
fs: 'empty',
|
|
228
|
+
child_process: 'empty'
|
|
229
|
+
},
|
|
230
|
+
resolve: {
|
|
231
|
+
extensions: ['.webpack.js', '.js', '.ts', '.tsx', '.json'],
|
|
232
|
+
alias: aliases,
|
|
233
|
+
plugins: resolvePlugins
|
|
234
|
+
},
|
|
235
|
+
resolveLoader: {
|
|
236
|
+
modules: [
|
|
237
|
+
path.join(__dirname, 'plugins'),
|
|
238
|
+
path.join(__dirname, 'node_modules'),
|
|
239
|
+
'node_modules',
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
optimization: {
|
|
243
|
+
minimize: productionMode,
|
|
244
|
+
minimizer: [
|
|
245
|
+
new TerserPlugin({
|
|
246
|
+
extractComments: {
|
|
247
|
+
condition: /^\**!|@preserve|@license|@cc_on/i,
|
|
248
|
+
banner: function (licenseFile) {
|
|
249
|
+
return "License information can be found in " + licenseFile + " and oss-licences.json";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}),
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
watch: watch,
|
|
256
|
+
module: {
|
|
257
|
+
rules: rules
|
|
258
|
+
},
|
|
259
|
+
//See plugins/externalise-modules.ts We're passing in a function here that determines what to exclude from the bundle and what not
|
|
260
|
+
//See also https://webpack.js.org/configuration/externals/
|
|
261
|
+
externals: externalise_modules_1["default"](config, es5),
|
|
262
|
+
plugins: plugins,
|
|
263
|
+
stats: {
|
|
264
|
+
errorDetails: config.debug,
|
|
265
|
+
chunks: false,
|
|
266
|
+
children: false,
|
|
267
|
+
version: true,
|
|
268
|
+
hash: false,
|
|
269
|
+
modules: false
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
exports.generateWebpackConfig = generateWebpackConfig;
|
|
@@ -6,13 +6,17 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
9
12
|
exports.__esModule = true;
|
|
10
13
|
exports.generateWebpackConfig = exports.generateGruntConfig = exports.externaliseModules = exports.DeclarationPlugin = void 0;
|
|
11
14
|
var declaration_plugin_1 = require("./plugins/declaration-plugin");
|
|
12
15
|
__createBinding(exports, declaration_plugin_1, "default", "DeclarationPlugin");
|
|
13
16
|
var externalise_modules_1 = require("./plugins/externalise-modules");
|
|
14
17
|
__createBinding(exports, externalise_modules_1, "default", "externaliseModules");
|
|
15
|
-
var
|
|
16
|
-
__createBinding(exports,
|
|
17
|
-
var
|
|
18
|
-
exports.generateWebpackConfig =
|
|
18
|
+
var config_grunt_1 = require("./config-grunt");
|
|
19
|
+
__createBinding(exports, config_grunt_1, "default", "generateGruntConfig");
|
|
20
|
+
var config_webpack_1 = require("./config-webpack");
|
|
21
|
+
exports.generateWebpackConfig = config_webpack_1.generateWebpackConfig;
|
|
22
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -163,9 +163,9 @@ var DeclarationPlugin = /** @class */ (function () {
|
|
|
163
163
|
}
|
|
164
164
|
//exclude re-exports
|
|
165
165
|
//excludeLine = excludeLine || (/export ([a-z0-9A-Z_-\{\}\s,\*]+) from/).test(line);
|
|
166
|
-
//exclude local
|
|
166
|
+
//exclude unnamed local imports like: import "./some.scss" or import "./someFile"t
|
|
167
167
|
excludeLine =
|
|
168
|
-
excludeLine || /import ["'][a-z0-9A-Z_\-.\/\\]
|
|
168
|
+
excludeLine || /import ["'][a-z0-9A-Z_\-.\/\\]+["']/.test(line);
|
|
169
169
|
//if defined, check for excluded references
|
|
170
170
|
if (!excludeLine &&
|
|
171
171
|
this.excludedReferences &&
|
|
@@ -173,7 +173,7 @@ var DeclarationPlugin = /** @class */ (function () {
|
|
|
173
173
|
excludeLine = this.excludedReferences.some(function (reference) { return line.indexOf(reference) !== -1; });
|
|
174
174
|
}
|
|
175
175
|
if (excludeLine) {
|
|
176
|
-
|
|
176
|
+
this.debug('Excluding line ' + i + ': ' + line);
|
|
177
177
|
lines.splice(i, 1);
|
|
178
178
|
}
|
|
179
179
|
else {
|