Commit 0c085647 authored by Andreas Fernandez's avatar Andreas Fernandez
Browse files

[BUGFIX] Refine build architecture

TypeScript:
Due to issues with upcoming TypeScript versions, the TypeScript sources
are moved into the Build directory before building JavaScript.

The unused Grunt task `tsdev` has been removed.

Additionally, some type defintions have been installed:

  yarn add --dev \
      @types/bootstrap-slider \
      @types/datatables.net \
      @types/chosen-js

Sass:
The Sass sources have been moved into the common "Sources" directory.
Those source files are moved to have a less cluttered Build directory.

Note: With this patch, all TypeScript files must be placed into
`Build/Sources/TypeScript` to be compiled by tsc again.

Resolves: #88043
Releases: master
Change-Id: I4d3e5f69564c38a35bf083652ea7262f5b85e4f3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60335

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 5600691c
......@@ -36,7 +36,6 @@ nbproject
/Build/bower_components/*
/Build/node_modules/*
/Build/JavaScript
/Build/typings/*
!/Build/typings/no-def*
/Build/testing-docker/local/.env
/typo3/sysext/*/Resources/Private/TypeScript/*.js
......
......@@ -46,9 +46,10 @@ module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
paths: {
resources: 'Resources/',
sources: 'Sources/',
root: '../',
sass: '<%= paths.resources %>Public/Sass/',
sass: '<%= paths.sources %>Sass/',
typescript: '<%= paths.sources %>/TypeScript/',
sysext: '<%= paths.root %>typo3/sysext/',
form: '<%= paths.sysext %>form/Resources/',
frontend: '<%= paths.sysext %>frontend/Resources/',
......@@ -199,8 +200,7 @@ module.exports = function (grunt) {
},
files: {
src: [
'<%= paths.sysext %>*/Tests/TypeScript/**/*.ts',
'<%= paths.sysext %>*/Resources/Private/TypeScript/**/*.ts',
'<%= paths.typescript %>/**/*.ts',
'./types/**/*.ts'
]
}
......@@ -225,12 +225,12 @@ module.exports = function (grunt) {
ts_files: {
files: [{
expand: true,
cwd: '<%= paths.root %>Build/JavaScript/typo3/sysext/',
cwd: '<%= paths.root %>Build/JavaScript/',
src: ['**/*.js', '**/*.js.map'],
dest: '<%= paths.sysext %>',
rename: function (dest, src) {
var srccleaned = src.replace('Resources/Private/TypeScript', 'Resources/Public/JavaScript');
srccleaned = srccleaned.replace('Tests/TypeScript', 'Tests/JavaScript');
var srccleaned = src.replace('Resources/Public/TypeScript', 'Resources/Public/JavaScript');
srccleaned = srccleaned.replace('Tests/', 'Tests/JavaScript/');
var destination = dest + srccleaned;
// Apply uglify configuration for regular files only
......@@ -644,25 +644,6 @@ module.exports = function (grunt) {
grunt.file.delete("JavaScript");
});
/**
* grunt tsdev task
*
* call "$ grunt tsdev"
*
* this task copies and modifies the TypeScript configuration for a developer system
* most TypeScript tooling expects tsconfig.json to be in a domineering/root-level position
*/
grunt.task.registerTask('tsdev', function () {
var content = grunt.file.read("tsconfig.json");
content = content.replace(/..\/typo3\//g, 'typo3/');
content = content.replace('"rootDir": "../",', '"rootDir": "./",');
content = content.replace('./JavaScript', './Build/JavaScript');
content = content.replace('"node_modules/@types"', '"Build/node_modules/@types"');
content = content.replace('"types"', '"Build/types"');
grunt.file.write('../tsconfig.json', content);
grunt.file.copy('./tslint.json', '../tslint.json');
});
/**
* grunt tsconfig task
*
......@@ -673,15 +654,15 @@ module.exports = function (grunt) {
grunt.task.registerTask('tsconfig', function () {
var config = grunt.file.readJSON("tsconfig.json");
config.compilerOptions.paths = {};
grunt.file.expand('../typo3/sysext/*/Resources/Public/JavaScript').forEach(function (dir) {
var extname = '_' + dir.match(/sysext\/(.*?)\//)[1],
extname = extname.replace(/_./g, function (match) {
return match.charAt(1).toUpperCase();
});
var namespace = 'TYPO3/CMS/' + extname + '/*',
path = dir + "/*",
typescriptPath = path.replace('Public/JavaScript', 'Private/TypeScript');
config.compilerOptions.paths[namespace] = [path, typescriptPath];
var sysext = grunt.config.get('paths.sysext');
grunt.file.expand(sysext + '*/Resources/Public/JavaScript').forEach(function (dir) {
var extname = ('_' + dir.match(/sysext\/(.*?)\//)[1]).replace(/_./g, function (match) {
return match.charAt(1).toUpperCase();
});
var namespace = 'TYPO3/CMS/' + extname + '/*';
var path = dir + "/*";
var extensionTypeScriptPath = path.replace('Public/JavaScript', 'Public/TypeScript').replace(sysext, '');
config.compilerOptions.paths[namespace] = [path, extensionTypeScriptPath];
});
grunt.file.write('tsconfig.json', JSON.stringify(config, null, 4));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment