Skip to content

Commit

Permalink
[BUGFIX] Refine build architecture
Browse files Browse the repository at this point in the history
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: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
andreaskienast committed Apr 5, 2019
1 parent 5600691 commit 0c08564
Show file tree
Hide file tree
Showing 292 changed files with 80 additions and 109 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -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
Expand Down
51 changes: 16 additions & 35 deletions Build/Gruntfile.js
Expand Up @@ -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/',
Expand Down Expand Up @@ -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'
]
}
Expand All @@ -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
Expand Down Expand Up @@ -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
*
Expand All @@ -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));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -182,7 +182,7 @@ class LiveSearch {
$searchField.val('').trigger('change');
});
if ($searchField.length) {
const $autocompleteContainer = $('.' + $searchField.autocomplete().options.containerClass);
const $autocompleteContainer = $('.' + Identifiers.toolbarItem.substr(1, Identifiers.toolbarItem.length));
$autocompleteContainer.on('click.autocomplete', '.dropdown-list-link', (evt: JQueryEventObject): void => {
evt.preventDefault();

Expand Down
2 changes: 2 additions & 0 deletions Build/package.json
Expand Up @@ -14,8 +14,10 @@
"devDependencies": {
"@claviska/jquery-minicolors": "^2.2.6",
"@types/bootstrap": "^3.3.34",
"@types/chosen-js": "^1.8.1",
"@types/chrome": "^0.0.69",
"@types/ckeditor": "4.9.1",
"@types/datatables.net": "^1.10.17",
"@types/imagesloaded": "^4.1.1",
"@types/jasmine": "^2.5.53",
"@types/jquery": "2.0.47",
Expand Down
59 changes: 27 additions & 32 deletions Build/tsconfig.json
Expand Up @@ -2,10 +2,10 @@
"compilerOptions": {
"target": "es5",
"lib": [
"DOM",
"ES5",
"ScriptHost",
"ES6"
"dom",
"es5",
"scripthost",
"es6"
],
"module": "amd",
"sourceMap": false,
Expand All @@ -17,102 +17,97 @@
"noImplicitThis": true,
"noImplicitReturns": true,
"pretty": true,
"baseUrl": ".",
"rootDir": "../",
"baseUrl": "Sources/TypeScript",
"paths": {
"TYPO3/CMS/Adminpanel/*": [
"../typo3/sysext/adminpanel/Resources/Public/JavaScript/*",
"../typo3/sysext/adminpanel/Resources/Private/TypeScript/*"
"adminpanel/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Backend/*": [
"../typo3/sysext/backend/Resources/Public/JavaScript/*",
"../typo3/sysext/backend/Resources/Private/TypeScript/*"
"backend/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Beuser/*": [
"../typo3/sysext/beuser/Resources/Public/JavaScript/*",
"../typo3/sysext/beuser/Resources/Private/TypeScript/*"
"beuser/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Core/*": [
"../typo3/sysext/core/Resources/Public/JavaScript/*",
"../typo3/sysext/core/Resources/Private/TypeScript/*"
"core/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Extensionmanager/*": [
"../typo3/sysext/extensionmanager/Resources/Public/JavaScript/*",
"../typo3/sysext/extensionmanager/Resources/Private/TypeScript/*"
"extensionmanager/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Filelist/*": [
"../typo3/sysext/filelist/Resources/Public/JavaScript/*",
"../typo3/sysext/filelist/Resources/Private/TypeScript/*"
"filelist/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Form/*": [
"../typo3/sysext/form/Resources/Public/JavaScript/*",
"../typo3/sysext/form/Resources/Private/TypeScript/*"
"form/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Impexp/*": [
"../typo3/sysext/impexp/Resources/Public/JavaScript/*",
"../typo3/sysext/impexp/Resources/Private/TypeScript/*"
"impexp/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Info/*": [
"../typo3/sysext/info/Resources/Public/JavaScript/*",
"../typo3/sysext/info/Resources/Private/TypeScript/*"
"info/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Install/*": [
"../typo3/sysext/install/Resources/Public/JavaScript/*",
"../typo3/sysext/install/Resources/Private/TypeScript/*"
"install/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Linkvalidator/*": [
"../typo3/sysext/linkvalidator/Resources/Public/JavaScript/*",
"../typo3/sysext/linkvalidator/Resources/Private/TypeScript/*"
"linkvalidator/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Lowlevel/*": [
"../typo3/sysext/lowlevel/Resources/Public/JavaScript/*",
"../typo3/sysext/lowlevel/Resources/Private/TypeScript/*"
"lowlevel/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Opendocs/*": [
"../typo3/sysext/opendocs/Resources/Public/JavaScript/*",
"../typo3/sysext/opendocs/Resources/Private/TypeScript/*"
"opendocs/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Recordlist/*": [
"../typo3/sysext/recordlist/Resources/Public/JavaScript/*",
"../typo3/sysext/recordlist/Resources/Private/TypeScript/*"
"recordlist/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Recycler/*": [
"../typo3/sysext/recycler/Resources/Public/JavaScript/*",
"../typo3/sysext/recycler/Resources/Private/TypeScript/*"
"recycler/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/RteCkeditor/*": [
"../typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/*",
"../typo3/sysext/rte_ckeditor/Resources/Private/TypeScript/*"
"rte_ckeditor/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Scheduler/*": [
"../typo3/sysext/scheduler/Resources/Public/JavaScript/*",
"../typo3/sysext/scheduler/Resources/Private/TypeScript/*"
"scheduler/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/T3editor/*": [
"../typo3/sysext/t3editor/Resources/Public/JavaScript/*",
"../typo3/sysext/t3editor/Resources/Private/TypeScript/*"
"t3editor/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Tstemplate/*": [
"../typo3/sysext/tstemplate/Resources/Public/JavaScript/*",
"../typo3/sysext/tstemplate/Resources/Private/TypeScript/*"
"tstemplate/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Viewpage/*": [
"../typo3/sysext/viewpage/Resources/Public/JavaScript/*",
"../typo3/sysext/viewpage/Resources/Private/TypeScript/*"
"viewpage/Resources/Public/TypeScript/*"
],
"TYPO3/CMS/Workspaces/*": [
"../typo3/sysext/workspaces/Resources/Public/JavaScript/*",
"../typo3/sysext/workspaces/Resources/Private/TypeScript/*"
"workspaces/Resources/Public/TypeScript/*"
]
},
"outDir": "./JavaScript/",
"typeRoots": [
"node_modules/@types",
"types"
]
},
"include": [
"../typo3/sysext/*/Resources/Private/TypeScript/**/*.ts",
"../typo3/sysext/*/Tests/TypeScript/**/*.ts"
]
}
}
5 changes: 0 additions & 5 deletions Build/types/TYPO3/index.d.ts
Expand Up @@ -131,8 +131,6 @@ interface JQueryTypedEvent<T extends Event> extends JQueryEventObject {
interface JQuery {
clearable(options?: any): JQuery;

chosen(options?: any): JQuery;

datetimepicker(options?: any): JQuery;

dragUploader(options?: any): JQuery;
Expand All @@ -144,7 +142,4 @@ interface JQuery {

// To be able to use jquery/autocomplete-slider we have to override the definition of jquerui
autocomplete(options?: { [key: string]: any }): any;

DataTable(options?: any): JQuery;
}

14 changes: 14 additions & 0 deletions Build/yarn.lock
Expand Up @@ -16,6 +16,13 @@
dependencies:
"@types/jquery" "*"

"@types/chosen-js@^1.8.1":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@types/chosen-js/-/chosen-js-1.8.1.tgz#4be61fe71e499317ad93251678899eb85d56dea9"
integrity sha512-K078GYGgiCdNmp25YlamkwP77L7MRqvH90mTpwL6DnHsen9snpvgzOqrH5kxKaDvxnHBAV1YKFRPLMbaYGoP3Q==
dependencies:
"@types/jquery" "*"

"@types/chrome@^0.0.69":
version "0.0.69"
resolved "https://registry.yarnpkg.com/@types/chrome/-/chrome-0.0.69.tgz#1d45bb79dd712b05704e4411f9eff3f270e19651"
Expand All @@ -28,6 +35,13 @@
resolved "https://registry.yarnpkg.com/@types/ckeditor/-/ckeditor-4.9.1.tgz#d8e81fb840c3f248772ab90efd508b6061cbd138"
integrity sha512-32BCMWLSSSkBKXf57cN/1Xv7VKXNOKXW5YPo3D2igCaevDAiiVtuMwPOFzOeO+5/CkGd4zt/Rf9RXl1J/vUsRA==

"@types/datatables.net@^1.10.17":
version "1.10.17"
resolved "https://registry.yarnpkg.com/@types/datatables.net/-/datatables.net-1.10.17.tgz#41343c8c9d7c0844f5c2400a6e11eca51250a82f"
integrity sha512-vyZkkzmRYIgE7Xu0bb4Icozn1/+P15g/3LxWCyIl8Xe8rw/1SMGoQozwt11qIzUVJwUQagFo6iBrMQjAp5GKuA==
dependencies:
"@types/jquery" "*"

"@types/filesystem@*":
version "0.0.28"
resolved "https://registry.yarnpkg.com/@types/filesystem/-/filesystem-0.0.28.tgz#3fd7735830f2c7413cb5ac45780bc45904697b0e"
Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/about/.gitattributes
@@ -1,3 +1,2 @@
/.gitattributes export-ignore
/Resources/Private/TypeScript/ export-ignore
/Tests/ export-ignore
1 change: 0 additions & 1 deletion typo3/sysext/adminpanel/.gitattributes
@@ -1,3 +1,2 @@
/.gitattributes export-ignore
/Resources/Private/TypeScript/ export-ignore
/Tests/ export-ignore
1 change: 0 additions & 1 deletion typo3/sysext/backend/.gitattributes
@@ -1,3 +1,2 @@
/.gitattributes export-ignore
/Resources/Private/TypeScript/ export-ignore
/Tests/ export-ignore

0 comments on commit 0c08564

Please sign in to comment.