Skip to content

Commit

Permalink
Build fixes (#6340)
Browse files Browse the repository at this point in the history
* added types to pkg json

* modified examples first build with no engine targets

* transform node_modules folder name to modules for ts-node fix

* converted function to single line

* changed examples build to use unbundled

* fixed types output path
  • Loading branch information
kpal81xd authored May 7, 2024
1 parent 583b8fe commit 9b9285f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ function getEnginePathFiles() {
function checkAppEngine() {
// types
if (!fs.existsSync('../build/playcanvas.d.ts')) {
const cmd = `npm run build:types --prefix ../`;
const cmd = `npm run build target:types --prefix ../`;
console.log("\x1b[32m%s\x1b[0m", cmd);
execSync(cmd);
}

// engine
if (!fs.existsSync('../build/playcanvas/src/index.js')) {
const cmd = `npm run build:esm:release --prefix ../`;
const cmd = `npm run build target:esm:release:unbundled --prefix ../`;
console.log("\x1b[32m%s\x1b[0m", cmd);
execSync(cmd);
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
"types": "build/playcanvas.d.ts",
"exports": {
".": {
"require": "./build/playcanvas.js",
"import": "./build/playcanvas/src/index.js",
"require": "./build/playcanvas.js"
"types": "./build/playcanvas.d.ts"
},
"./build/*": "./build/*"
},
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const BUNDLE_STATES = ['unbundled', 'bundled'];
* @type {RollupOptions[]}
*/
const TYPES_TARGET = [{
input: 'build/playcanvas/index.d.ts',
input: 'build/playcanvas/src/index.d.ts',
output: [{
file: 'build/playcanvas.d.ts',
footer: 'export as namespace pc;\nexport as namespace pcx;',
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "build/playcanvas"
"outDir": "build/playcanvas/src"
}
}
2 changes: 1 addition & 1 deletion utils/plugins/rollup-types-fixup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const GREEN_OUT = '\x1b[32m';
const BOLD_OUT = `\x1b[1m`;
const REGULAR_OUT = `\x1b[22m`;

const TYPES_PATH = './build/playcanvas';
const TYPES_PATH = './build/playcanvas/src';

const STANDARD_MAT_PROPS = [
['alphaFade', 'boolean'],
Expand Down
3 changes: 2 additions & 1 deletion utils/rollup-build-target.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index.
name: 'pc',
preserveModules: !bundled,
file: bundled ? `${dir}/${OUT_PREFIX[buildType]}${isUMD ? '.js' : '.mjs'}` : undefined,
dir: !bundled ? `${dir}/${OUT_PREFIX[buildType]}` : undefined
dir: !bundled ? `${dir}/${OUT_PREFIX[buildType]}` : undefined,
entryFileNames: chunkInfo => `${chunkInfo.name.replace(/node_modules/g, 'modules')}.js`
},
plugins: [
resolve(),
Expand Down

0 comments on commit 9b9285f

Please sign in to comment.