Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better separate type declarations #5695

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions Makefile.dryice.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
var {
updateDeclarationModuleNames,
generateDeclaration,
SEPARATE_MODULES
bundleDtsFiles,
} = require('./tool/ace_declaration_generator');

var ACE_HOME = __dirname;
Expand Down Expand Up @@ -179,25 +179,16 @@
}
}

function correctDeclarationsForBuild(path, additionalDeclarations) {
function correctDeclarationsForBuild(path) {
var definitions = fs.readFileSync(path, 'utf8');
var newDefinitions = updateDeclarationModuleNames(definitions);
if (additionalDeclarations) {
newDefinitions = newDefinitions + '\n' + additionalDeclarations;
}
fs.writeFileSync(path, newDefinitions);
fs.writeFileSync(path, newDefinitions, "utf-8");
}

function buildTypes() {
// ace-builds package has different structure and can't use mode types defined for the ace-code.
var paths = fs.readdirSync(BUILD_DIR + '/src-noconflict');

var typeDir = BUILD_DIR + "/types";

if (!fs.existsSync(typeDir)) {
fs.mkdirSync(typeDir);
}

fs.readdirSync(BUILD_DIR + '/src-noconflict/snippets').forEach(function(path) {
paths.push("snippets/" + path);
});
Expand All @@ -215,20 +206,11 @@
}
}).filter(Boolean)).join("\n") + "\n";

fs.copyFileSync(ACE_HOME + '/ace-internal.d.ts', BUILD_DIR + '/ace.d.ts');
generateDeclaration(BUILD_DIR + '/ace.d.ts');
generateDeclaration();
fs.copyFileSync(ACE_HOME + '/ace-modes.d.ts', BUILD_DIR + '/ace-modes.d.ts');
correctDeclarationsForBuild(BUILD_DIR + '/ace.d.ts', pathModules);
correctDeclarationsForBuild(BUILD_DIR + '/ace-modes.d.ts');
const finalDeclaration = bundleDtsFiles() + "\n" + pathModules;

let allModules = SEPARATE_MODULES;
allModules.push("modules"); // core modules
allModules.forEach(function (key) {
let fileName = '/ace-' + key + '.d.ts';
fs.copyFileSync(ACE_HOME + '/types' + fileName, BUILD_DIR + '/types' + fileName);
correctDeclarationsForBuild(BUILD_DIR + '/types' + fileName);
});

var esmUrls = [];

var loader = paths.map(function(path) {
Expand All @@ -243,6 +225,7 @@
}).join('\n');
var esmLoader = esmUrls.join('\n');

fs.writeFileSync(BUILD_DIR + '/ace.d.ts', finalDeclaration, "utf8");
fs.writeFileSync(BUILD_DIR + '/webpack-resolver.js', loader, "utf8");
fs.writeFileSync(BUILD_DIR + '/esm-resolver.js', esmLoader, "utf8");
}
Expand Down Expand Up @@ -496,7 +479,7 @@
}

function buildAce(options, callback) {
var snippetFiles = jsFileList("lib/ace/snippets");

Check warning on line 482 in Makefile.dryice.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'snippetFiles' is assigned a value but never used
var modeNames = modeList();

buildCore(options, {outputFile: "ace.js"}, addCb());
Expand Down Expand Up @@ -882,7 +865,7 @@
});
}

function generateThemesModule(themes) {

Check warning on line 868 in Makefile.dryice.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'generateThemesModule' is defined but never used
var themelist = [
'define(function(require, exports, module) {',
'\n\nmodule.exports.themes = ' + JSON.stringify(themes, null, ' '),
Expand Down
Loading
Loading