Skip to content

Commit

Permalink
[Build] Remove tslib reference in es6 packages (First step towards es…
Browse files Browse the repository at this point in the history
…m) (#12897)

* [Build] Remove tslib reference in es6 packages (First step towards esm)
Fixes #12784

* formatting

* fix for constants

* Update packages/dev/core/src/Engines/thinEngine.ts

Former-commit-id: b051ff4521424c8c7306fd509a60ff26c3b3075f
  • Loading branch information
RaananW authored Aug 26, 2022
1 parent b6e9033 commit 77458fc
Show file tree
Hide file tree
Showing 18 changed files with 304 additions and 50 deletions.
298 changes: 289 additions & 9 deletions packages/dev/buildTools/src/pathTransform.ts

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/dev/buildTools/src/prepareEs6Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const prepareES6Build = async () => {
const constFile = checkArgs(["--constFile", "-cf"], false, true);
try {
if (constFile) {
const constantsContent = fs.readFileSync(path.resolve(baseDir, "dist", constFile as string), "utf8").replace("export { Constants };", "Constants;");
const constantsContent = fs.readFileSync(path.resolve(baseDir, "dist", constFile as string), "utf8").replace("export class Constants", "const Constants = ");
// eslint-disable-next-line @typescript-eslint/naming-convention
const Constants = eval(constantsContent);
const Constants = eval(constantsContent + "\nConstants;");
const allSourceFiles = glob.sync(path.resolve(baseDir, "dist", "**", "*.js"));
allSourceFiles.forEach((file) => {
if (file.endsWith(constFile as string)) {
Expand Down Expand Up @@ -45,6 +45,7 @@ export const prepareES6Build = async () => {
});
}
} catch (e) {
console.log(e);
process.exit(1);
}
// this script copies all files from dist to ../
Expand Down
17 changes: 8 additions & 9 deletions packages/dev/core/src/Engines/thinEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ShaderProcessingContext } from "./Processors/shaderProcessingOptio
import type { UniformBuffer } from "../Materials/uniformBuffer";
import type { Nullable, DataArray, IndicesArray } from "../types";
import type { EngineCapabilities } from "./engineCapabilities";
import type { Observer } from "../Misc/observable";
import { Observable } from "../Misc/observable";
import { DepthCullingState } from "../States/depthCullingState";
import { StencilState } from "../States/stencilState";
Expand Down Expand Up @@ -45,15 +46,13 @@ import type { IAudioEngineOptions } from "../Audio/Interfaces/IAudioEngineOption
import type { IStencilState } from "../States/IStencilState";
import type { InternalTextureCreationOptions, TextureSize } from "../Materials/Textures/textureCreationOptions";
import { ShaderLanguage } from "../Materials/shaderLanguage";

declare type WebRequest = import("../Misc/webRequest").WebRequest;
declare type LoadFileError = import("../Misc/fileTools").LoadFileError;
declare type Observer<T> = import("../Misc/observable").Observer<T>;
declare type VideoTexture = import("../Materials/Textures/videoTexture").VideoTexture;
declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTexture").RenderTargetTexture;
declare type Texture = import("../Materials/Textures/texture").Texture;
declare type RenderTargetWrapper = import("./renderTargetWrapper").RenderTargetWrapper;
declare type WebGLRenderTargetWrapper = import("./WebGL/webGLRenderTargetWrapper").WebGLRenderTargetWrapper;
import type { RenderTargetWrapper } from "./renderTargetWrapper";
import type { WebGLRenderTargetWrapper } from "./WebGL/webGLRenderTargetWrapper";
import type { VideoTexture } from "../Materials/Textures/videoTexture";
import type { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
import type { WebRequest } from "../Misc/webRequest";
import type { LoadFileError } from "../Misc/fileTools";
import type { Texture } from "../Materials/Textures/texture";

/**
* Defines the interface used by objects working like Scene
Expand Down
3 changes: 0 additions & 3 deletions packages/public/@babylonjs/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"postcompile": "build-tools -c declarations-es6 -r ../../../lts/core/generated/LibDeclarations -atf ./dist/Engines/engine.d.ts && build-tools -c add-js-to-es6",
"prepublishOnly": "build-tools -c prepare-es6-build -cf Engines/constants.js"
},
"dependencies": {
"tslib": "^2.4.0"
},
"devDependencies": {
"@dev/build-tools": "^1.0.0",
"@lts/core": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/public/@babylonjs/core/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "./dist",
"rootDir": "../../../lts/core/generated",
"declaration": true,
"target": "es5",
"target": "ES2021",
"importHelpers": true,
"plugins": [
{ "transform": "../../../dev/buildTools/src/pathTransform.ts", "buildType": "es6", "basePackage": "@babylonjs/core", "appendJS": true },
Expand Down
3 changes: 0 additions & 3 deletions packages/public/@babylonjs/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"postcompile": "build-tools -c add-js-to-es6",
"prepublishOnly": "build-tools -c prepare-es6-build"
},
"dependencies": {
"tslib": "^2.4.0"
},
"devDependencies": {
"@babylonjs/core": "^5.21.0",
"@dev/build-tools": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/public/@babylonjs/gui/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "./dist",
"rootDir": "../../../lts/gui/generated",
"declaration": true,
"target": "es5",
"target": "ES2021",
"importHelpers": true,
"plugins": [
{ "transform": "../../../dev/buildTools/src/pathTransform.ts", "buildType": "es6", "basePackage": "@babylonjs/gui", "appendJS": true },
Expand Down
3 changes: 0 additions & 3 deletions packages/public/@babylonjs/loaders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"postcompile": "build-tools -c add-js-to-es6",
"prepublishOnly": "build-tools -c prepare-es6-build"
},
"dependencies": {
"tslib": "^2.4.0"
},
"devDependencies": {
"@babylonjs/core": "^5.21.0",
"@dev/build-tools": "^1.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/public/@babylonjs/loaders/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"outDir": "./dist",
"rootDir": "../../../lts/loaders/generated",
"declaration": true,
"target": "es5",
"importHelpers": true,
"plugins": [
{ "transform": "../../../dev/buildTools/src/pathTransform.ts", "buildType": "es6", "basePackage": "@babylonjs/loaders", "appendJS": true },
Expand Down
3 changes: 0 additions & 3 deletions packages/public/@babylonjs/materials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"postcompile": "build-tools -c add-js-to-es6",
"prepublishOnly": "build-tools -c prepare-es6-build"
},
"dependencies": {
"tslib": "^2.4.0"
},
"devDependencies": {
"@babylonjs/core": "^5.21.0",
"@dev/build-tools": "^1.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/public/@babylonjs/materials/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"outDir": "./dist",
"rootDir": "../../../lts/materials/generated",
"declaration": true,
"target": "es5",
"importHelpers": true,
"plugins": [{ "transform": "../../../dev/buildTools/src/pathTransform.ts", "buildType": "es6", "basePackage": "@babylonjs/materials", "appendJS": true }],
"paths": {
Expand Down
3 changes: 0 additions & 3 deletions packages/public/@babylonjs/post-processes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"postcompile": "build-tools -c add-js-to-es6",
"prepublishOnly": "build-tools -c prepare-es6-build"
},
"dependencies": {
"tslib": "^2.4.0"
},
"devDependencies": {
"@babylonjs/core": "^5.21.0",
"@dev/build-tools": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"outDir": "./dist",
"rootDir": "../../../lts/postProcesses/generated",
"declaration": true,
"target": "es5",
"importHelpers": true,
"plugins": [{ "transform": "../../../dev/buildTools/src/pathTransform.ts", "buildType": "es6", "basePackage": "@babylonjs/post-processes", "appendJS": true }],
"paths": {
Expand Down
3 changes: 0 additions & 3 deletions packages/public/@babylonjs/procedural-textures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"postcompile": "build-tools -c add-js-to-es6",
"prepublishOnly": "build-tools -c prepare-es6-build"
},
"dependencies": {
"tslib": "^2.4.0"
},
"devDependencies": {
"@babylonjs/core": "^5.21.0",
"@dev/build-tools": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"outDir": "./dist",
"rootDir": "../../../lts/proceduralTextures/generated",
"declaration": true,
"target": "es5",
"importHelpers": true,
"plugins": [
{ "transform": "../../../dev/buildTools/src/pathTransform.ts", "buildType": "es6", "basePackage": "@babylonjs/procedural-textures", "appendJS": true },
Expand Down
3 changes: 0 additions & 3 deletions packages/public/@babylonjs/serializers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"postcompile": "build-tools -c add-js-to-es6",
"prepublishOnly": "build-tools -c prepare-es6-build"
},
"dependencies": {
"tslib": "^2.4.0"
},
"devDependencies": {
"@babylonjs/core": "^5.21.0",
"@dev/build-tools": "^1.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/public/@babylonjs/serializers/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"outDir": "./dist",
"rootDir": "../../../lts/serializers/generated",
"declaration": true,
"target": "es5",
"importHelpers": true,
"plugins": [
{ "transform": "../../../dev/buildTools/src/pathTransform.ts", "buildType": "es6", "basePackage": "@babylonjs/serializers", "appendJS": true },
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"baseUrl": "packages",
"importHelpers": true,
"moduleResolution": "node",
"module": "es2020",
"target": "es2017", // esnext has an issue with class generation and our decoders. TODO - avoid using decorators until in standard
"module": "ES2020",
"target": "es2021", // esnext has an issue with class generation and our decoders. TODO - avoid using decorators until in standard
"declaration": true,
"sourceMap": true,
"inlineSources": true,
Expand Down

0 comments on commit 77458fc

Please sign in to comment.