@zohodesk/client_build_tool 0.0.6-exp.23 → 0.0.6-exp.24
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/lib/schemas/defaultConfigValues.js +7 -1
- package/lib/shared/babel/babelWebConfig.js +4 -1
- package/lib/shared/babel/runBabelForTsFile.js +30 -0
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +99 -0
- package/lib/shared/bundler/webpack/resolvers.js +2 -1
- package/lib/shared/bundler/webpack/tsLoaders.js +17 -0
- package/lib/shared/bundler/webpack/webpackConfig.js +3 -1
- package/lib/shared/fileUtils/watchRun.js +13 -1
- package/npm-shrinkwrap.json +412 -7328
- package/package.json +5 -2
|
@@ -323,6 +323,12 @@ var _default = {
|
|
|
323
323
|
cssAttributes: null,
|
|
324
324
|
i18nAttributes: null
|
|
325
325
|
},
|
|
326
|
-
externals: null
|
|
326
|
+
externals: null,
|
|
327
|
+
typeScript: {
|
|
328
|
+
enable: {
|
|
329
|
+
value: false,
|
|
330
|
+
cli: 'type_script_enable'
|
|
331
|
+
}
|
|
332
|
+
}
|
|
327
333
|
};
|
|
328
334
|
exports.default = _default;
|
|
@@ -25,8 +25,11 @@ function babelWebConfig(options, mode) {
|
|
|
25
25
|
plugins: babelPlugins,
|
|
26
26
|
browserList
|
|
27
27
|
} = options.babelCustomizations;
|
|
28
|
+
const {
|
|
29
|
+
enable: typeScriptEnable
|
|
30
|
+
} = options.typeScript;
|
|
28
31
|
return {
|
|
29
|
-
presets: [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react')],
|
|
32
|
+
presets: typeScriptEnable ? [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react'), require.resolve('@babel/preset-typescript')] : [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react')],
|
|
30
33
|
plugins: customBabelPlugins(babelPlugins).concat((0, _getBabelPlugin.getBabelPlugin)(options)).filter(Boolean)
|
|
31
34
|
};
|
|
32
35
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runBabelForTSFile = runBabelForTSFile;
|
|
7
|
+
|
|
8
|
+
var _core = require("@babel/core");
|
|
9
|
+
|
|
10
|
+
var _babelWebConfig = require("./babelWebConfig");
|
|
11
|
+
|
|
12
|
+
var _copyFile = require("../fileUtils/copyFile");
|
|
13
|
+
|
|
14
|
+
function runBabelForTSFile({
|
|
15
|
+
filename,
|
|
16
|
+
outputFile,
|
|
17
|
+
options,
|
|
18
|
+
mode = 'es'
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
enable
|
|
22
|
+
} = options.typeScript;
|
|
23
|
+
|
|
24
|
+
if (enable) {
|
|
25
|
+
// const jsSourceCode = readFileSync(filename).toString();
|
|
26
|
+
const babelConfig = (0, _babelWebConfig.babelWebConfig)(options, mode);
|
|
27
|
+
const result = (0, _core.transformFileSync)(filename, babelConfig);
|
|
28
|
+
(0, _copyFile.writeFile)(outputFile.replace('.tsx', '.js'), result.code);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
9
|
+
|
|
10
|
+
var _nameTemplates = require("../common/nameTemplates");
|
|
11
|
+
|
|
12
|
+
var _modeUtils = require("../common/modeUtils");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
// import { RuntimeGlobals, RuntimeModule } from 'webpack';
|
|
17
|
+
// import { Template } from 'webpack';
|
|
18
|
+
const pluginName = 'CdnChangePlugin'; // const MODULE_TYPE = 'css/mini-extract';
|
|
19
|
+
// class CdnChangeRuntimePlugin extends RuntimeModule {
|
|
20
|
+
// constructor(compiler, { variableName }) {
|
|
21
|
+
// super('cdn loading', 10);
|
|
22
|
+
// this.variableName = variableName;
|
|
23
|
+
// }
|
|
24
|
+
// generate() {
|
|
25
|
+
// return `${RuntimeGlobals.getChunkCssFilename} = function(chunkId) {
|
|
26
|
+
// const cssCdnUrl = window[${this.variableName}] || chunkId;
|
|
27
|
+
// return cssCdnUrl;
|
|
28
|
+
// }`;
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
31
|
+
|
|
32
|
+
class CdnChangePlugin {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.createSeparateSMap = options.createSeparateSMap;
|
|
35
|
+
this.i18nTemplate = options.i18nTemplate || '{{__I18N_CDN__}}';
|
|
36
|
+
this.variableName = options.variableName || '__CSS_CDN__';
|
|
37
|
+
this.cssTemplate = options.cssTemplate || '{{__CSS_CDN__}}';
|
|
38
|
+
this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
|
|
39
|
+
this.mode = options.mode || 'prod';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
apply(compiler) {
|
|
43
|
+
// compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
44
|
+
// const enabledChunks = new WeakSet();
|
|
45
|
+
// const handler = (entryRuntimeChunk, set) => {
|
|
46
|
+
// if (enabledChunks.has(entryRuntimeChunk)) {
|
|
47
|
+
// return;
|
|
48
|
+
// }
|
|
49
|
+
// enabledChunks.add(entryRuntimeChunk);
|
|
50
|
+
// set.add(RuntimeGlobals.getFullHash);
|
|
51
|
+
// set.add(RuntimeGlobals.getChunkCssFilename);
|
|
52
|
+
// compilation.addRuntimeModule(
|
|
53
|
+
// entryRuntimeChunk,
|
|
54
|
+
// new CdnChangeRuntimePlugin(set, {
|
|
55
|
+
// compiler,
|
|
56
|
+
// variableName: this.variableName
|
|
57
|
+
// })
|
|
58
|
+
// );
|
|
59
|
+
// };
|
|
60
|
+
// compilation.hooks.runtimeRequirementInTree
|
|
61
|
+
// .for(RuntimeGlobals.ensureChunkHandlers)
|
|
62
|
+
// .tap(pluginName, handler);
|
|
63
|
+
// });
|
|
64
|
+
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
65
|
+
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, (data, cb) => {
|
|
66
|
+
const {
|
|
67
|
+
createSeparateSMap,
|
|
68
|
+
mode
|
|
69
|
+
} = this; // eslint-disable-next-line no-param-reassign
|
|
70
|
+
|
|
71
|
+
data.assets = { ...data.assets,
|
|
72
|
+
css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
|
|
73
|
+
js: data.assets.js.map(js => {
|
|
74
|
+
if (((0, _modeUtils.isProductionMode)(mode) || createSeparateSMap) && !(0, _nameTemplates.isI18nFile)(js)) {
|
|
75
|
+
js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return `${(0, _nameTemplates.isI18nFile)(js) ? this.i18nTemplate : this.jsTemplate}${js}`;
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
cb && cb(null, data);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var _default = CdnChangePlugin; // Cdn Change Plugin for runtime chunks???
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* the filename of the script part of the chunk
|
|
92
|
+
*/
|
|
93
|
+
// exports.getChunkScriptFilename = "__webpack_require__.u";
|
|
94
|
+
// /**
|
|
95
|
+
// * the filename of the css part of the chunk
|
|
96
|
+
// */
|
|
97
|
+
// exports.getChunkCssFilename = "__webpack_require__.k";
|
|
98
|
+
|
|
99
|
+
exports.default = _default;
|
|
@@ -62,7 +62,8 @@ function moduleResolver(options) {
|
|
|
62
62
|
modules: useAppNodeModulesAsPreferred(preferLocalFirst, [nodeModulesPath, _constants.cliNodeModulesPath].filter(Boolean)),
|
|
63
63
|
alias: { ...(defaultAlias ? _libAlias.libAlias : {}),
|
|
64
64
|
...(alias || {})
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
|
+
extensions: ['.ts', '.js', '.json', '.tsx']
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tsLoaders = tsLoaders;
|
|
7
|
+
|
|
8
|
+
var _babelLoaderConfig = require("./loaderConfigs/babelLoaderConfig");
|
|
9
|
+
|
|
10
|
+
function tsLoaders(options) {
|
|
11
|
+
return [{
|
|
12
|
+
test: /\.tsx$/,
|
|
13
|
+
exclude: /node_modules/,
|
|
14
|
+
use: [(0, _babelLoaderConfig.babelLoaderConfig)(options)] // include: path.join(appPath, folder)
|
|
15
|
+
|
|
16
|
+
}];
|
|
17
|
+
}
|
|
@@ -11,6 +11,8 @@ var _outputConfig = require("./outputConfig");
|
|
|
11
11
|
|
|
12
12
|
var _jsLoaders = require("./jsLoaders");
|
|
13
13
|
|
|
14
|
+
var _tsLoaders = require("./tsLoaders");
|
|
15
|
+
|
|
14
16
|
var _cssLoaders = require("./cssLoaders");
|
|
15
17
|
|
|
16
18
|
var _assetLoaders = require("./loaderConfigs/assetLoaders");
|
|
@@ -46,7 +48,7 @@ function webpackConfigCreator(options) {
|
|
|
46
48
|
module: {
|
|
47
49
|
/* strictExportPresence for break the build when imported module not present in respective file */
|
|
48
50
|
// strictExportPresence: true,
|
|
49
|
-
rules: [...(0, _jsLoaders.jsLoaders)(options), ...(0, _cssLoaders.cssLoaders)(options), (0, _configWebWorkerLoader.configWebWorkerLoader)(options), (0, _configHtmlTemplateLoader.configHtmlTemplateLoader)(options), ...(0, _assetLoaders.assetLoaders)(options), ...(0, _configCustomLoaders.configCustomLoaders)(options)]
|
|
51
|
+
rules: [...(0, _jsLoaders.jsLoaders)(options), ...(0, _tsLoaders.tsLoaders)(options), ...(0, _cssLoaders.cssLoaders)(options), (0, _configWebWorkerLoader.configWebWorkerLoader)(options), (0, _configHtmlTemplateLoader.configHtmlTemplateLoader)(options), ...(0, _assetLoaders.assetLoaders)(options), ...(0, _configCustomLoaders.configCustomLoaders)(options)]
|
|
50
52
|
},
|
|
51
53
|
plugins: (0, _plugins.plugins)(options),
|
|
52
54
|
externals: (0, _externals.externals)(options),
|
|
@@ -11,6 +11,8 @@ var _watcher = _interopRequireDefault(require("watcher"));
|
|
|
11
11
|
|
|
12
12
|
var _runBabelForJSFile = require("../babel/runBabelForJSFile");
|
|
13
13
|
|
|
14
|
+
var _runBabelForTsFile = require("../babel/runBabelForTsFile");
|
|
15
|
+
|
|
14
16
|
var _runPostCssForCssFile = require("../postcss/runPostCssForCssFile");
|
|
15
17
|
|
|
16
18
|
var _directoryIterator = require("./directoryIterator");
|
|
@@ -23,6 +25,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
25
|
|
|
24
26
|
const isJs = ext => ext === '.js';
|
|
25
27
|
|
|
28
|
+
const isTs = ext => ext === '.ts' || ext === '.tsx';
|
|
29
|
+
|
|
26
30
|
const isCss = ext => ext === '.css';
|
|
27
31
|
|
|
28
32
|
function watchRun({
|
|
@@ -54,6 +58,13 @@ function watchRun({
|
|
|
54
58
|
outputFile,
|
|
55
59
|
options
|
|
56
60
|
});
|
|
61
|
+
} else if (isTs(ext)) {
|
|
62
|
+
(0, _runBabelForTsFile.runBabelForTSFile)({
|
|
63
|
+
filename,
|
|
64
|
+
outputFile,
|
|
65
|
+
options,
|
|
66
|
+
mode
|
|
67
|
+
});
|
|
57
68
|
} else {
|
|
58
69
|
(0, _copyFile.copyFile)(filename, outputFile);
|
|
59
70
|
}
|
|
@@ -81,7 +92,8 @@ function watchRun({
|
|
|
81
92
|
const watcher = new _watcher.default(src, {
|
|
82
93
|
recursive: true,
|
|
83
94
|
ignoreInitial: true,
|
|
84
|
-
ignore: filename => filename.indexOf('__tests__') !== -1
|
|
95
|
+
ignore: filename => filename.indexOf('__tests__') !== -1 // remove the test cases
|
|
96
|
+
|
|
85
97
|
});
|
|
86
98
|
watcher.on('all', (event, filename) => {
|
|
87
99
|
if (event === 'unlink' || event === 'unlinkDir') {
|