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

feat(build)!: Introduce exports section in package.json #7822

Merged
merged 10 commits into from
Mar 15, 2024
47 changes: 39 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,45 @@
"test:compile:advanced": "gulp buildAdvancedCompilationTest --debug",
"updateGithubPages": "npm ci && gulp gitUpdateGithubPages"
},
"main": "./index.js",
"umd": "./blockly.min.js",
"unpkg": "./blockly.min.js",
"types": "./index.d.ts",
"browser": {
"./node.js": "./browser.js",
"./core.js": "./core-browser.js",
"./blockly-node.js": "./blockly.js"
"exports": {
".": {
"types": "./index.d.ts",
"umd": "./blockly.min.js",
"default": "./index.js"
},
"./core": {
"types": "./core.d.ts",
"node": "./core-node.js",
"default": "./blockly_compressed.js"
},
"./blocks": {
"types": "./blocks.d.ts",
"default": "./blocks_compressed.js"
},
"./dart": {
"types": "./dart.d.ts",
"default": "./dart_compressed.js"
},
"./lua": {
"types": "./lua.d.ts",
"default": "./lua_compressed.js"
},
"./javascript": {
"types": "./javascript.d.ts",
"default": "./javascript_compressed.js"
},
"./php": {
"types": "./php.d.ts",
"default": "./php_compressed.js"
},
"./python": {
"types": "./python.d.ts",
"default": "./python_compressed.js"
},
"./msg/*": {
"types": "./msg/*.d.ts",
"default": "./msg/*.js"
}
},
"license": "Apache-2.0",
"devDependencies": {
Expand Down
7 changes: 3 additions & 4 deletions scripts/gulpfiles/build_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const closureCompiler = require('google-closure-compiler').gulp();
const argv = require('yargs').argv;
const {rimraf} = require('rimraf');

const {BUILD_DIR, RELEASE_DIR, TSC_OUTPUT_DIR, TYPINGS_BUILD_DIR} = require('./config');
const {BUILD_DIR, LANG_BUILD_DIR, RELEASE_DIR, TSC_OUTPUT_DIR, TYPINGS_BUILD_DIR} = require('./config');
const {getPackageJson} = require('./helper_tasks');

const {posixPath, quote} = require('../helpers');
Expand Down Expand Up @@ -350,8 +350,7 @@ this removal!
*/
function buildLangfiles(done) {
// Create output directory.
const outputDir = path.join(BUILD_DIR, 'msg');
fs.mkdirSync(outputDir, {recursive: true});
fs.mkdirSync(LANG_BUILD_DIR, {recursive: true});

// Run create_messages.py.
let json_files = fs.readdirSync(path.join('msg', 'json'));
Expand All @@ -364,7 +363,7 @@ function buildLangfiles(done) {
--source_synonym_file ${path.join('msg', 'json', 'synonyms.json')} \
--source_constants_file ${path.join('msg', 'json', 'constants.json')} \
--key_file ${path.join('msg', 'json', 'keys.json')} \
--output_dir ${outputDir} \
--output_dir ${LANG_BUILD_DIR} \
--quiet ${json_files.join(' ')}`;
execSync(createMessagesCmd, {stdio: 'inherit'});

Expand Down
3 changes: 3 additions & 0 deletions scripts/gulpfiles/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ exports.BUILD_DIR = 'build';
// Directory to write typings output to.
exports.TYPINGS_BUILD_DIR = path.join(exports.BUILD_DIR, 'declarations');

// Directory to write langfile output to.
exports.LANG_BUILD_DIR = path.join(exports.BUILD_DIR, 'msg');

// Directory where typescript compiler output can be found.
// Matches the value in tsconfig.json: outDir
exports.TSC_OUTPUT_DIR = path.join(exports.BUILD_DIR, 'src');
Expand Down
Loading