Closed seghier closed 5 months ago
Update, i follow these steps:
1- I install yarn
2- Run yarn install
3- Create rollup.config.mjs
// rollup.config.mjs
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
export default {
input: 'src/index.ts', // Assuming your entry file is named index.ts
output: {
file: 'dist/bundle.js', // The output directory and filename for the bundle
format: 'esm',
},
plugins: [
resolve(),
typescript({ tsconfig: 'tsconfig.json' }), // Use the correct path to your tsconfig.json
],
};
4- Run rollup -c rollup.config.mjs
and i got this error:
src/index.ts → dist/bundle.js...
[!] (plugin rpt2) Error: Could not load C:\Users\archi\source\repos\components\node_modules\three\examples\jsm\renderers\CSS2DRenderer (imported by src/core/SimpleRenderer/index.ts): ENOENT: no such file or directory, open 'C:\Users\archi\source\repos\components\node_modules\three\examples\jsm\renderers\CSS2DRenderer'
Error: Could not load C:\Users\archi\source\repos\components\node_modules\three\examples\jsm\renderers\CSS2DRenderer (imported by src/core/SimpleRenderer/index.ts): ENOENT: no such file or directory, open 'C:\Users\archi\source\repos\components\node_modules\three\examples\jsm\renderers\CSS2DRenderer'
Interesting... I was having a similar problem with web-ifc-three, as illustrated in this issue: web-ifc-three issue #64 Now I've removed web-ifc-three and installed openbim-components and I'm having the same issue as yours.
//app.js
import * as THREE from "three"
import * as OBC from "openbim-components"
const container = document.getElementById('container')
const components = new OBC.Components()
components.scene = new OBC.SimpleScene(components)
components._renderer = new OBC.SimpleRenderer(components,container)
components.camera = new OBC.SimpleCamera(components)
components.raycaster = new OBC.SimpleRaycaster(components)
components.init()
//rollup.config.js
import resolve from "@rollup/plugin-node-resolve"
export default {
input: "./app.js",
output: [
{
format: "esm",
file: "./bundle.js",
},
],
plugins: [resolve()],
}
"package.json"
"scripts": {
"watch": "rollup -w -c ./rollup.config.js"
},
"dependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"openbim-components": "^1.1.5",
"rollup": "^4.0.2",
"three": "^0.152.2"
},
Hey @seghier , can you provide a full minimal repository where we can reproduce this?
Hey @nelsonhp3, are those all the files of your project? For rollup to work with Three.js latest versions (and other libraries), you need to write an extra config file. You can take a look at our config file and our extra config file for reference.
We are now bundling all our libraries, both as modules and as cjs, so this should be solved. Let us know otherwise!
Describe the bug 📝
Hello I try to create a bundle but i got errors.
Reproduction ▶️
No response
Steps to reproduce 🔢
tsc --outFile dist/bundle.js src/index.ts
System Info 💻
Used Package Manager 📦
npm
Error Trace/Logs 📃
src/annotation/DrawManager/index.ts:72:21 - error TS2461: Type 'NodeListOf' is not an array type.
72 group.append(...drawing);
src/core/ScreenCuller/index.ts:258:24 - error TS2802: Type 'IterableIterator' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
258 for (const code of colors.values()) {
src/core/ToolsComponent/index.ts:1:1 - error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'.
1 import * as THREE from "three";
src/core/ToolsComponent/index.ts:104:24 - error TS2802: Type 'IterableIterator<Component>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
104 for (const tool of tools) {
src/fragments/FragmentExploder/index.ts:92:28 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
92 for (const id of ids) {
src/fragments/FragmentHighlighter/index.ts:263:24 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
263 for (const id of ids[fragID]) {
src/fragments/FragmentHighlighter/index.ts:398:24 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
398 for (const id of ids) {
src/ifc/IfcJsonExporter/index.ts:74:22 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
74 for (const id of structures) {
src/ifc/IfcPropertiesFinder/index.ts:200:33 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
200 for (const expressID of groupResult) {
src/ifc/IfcPropertiesFinder/index.ts:247:31 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
247 for (const expressID of matchingEntities) {
src/ifc/IfcPropertiesFinder/index.ts:373:29 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
373 for (const element of uniqueElements) {
src/ifc/IfcPropertiesFinder/src/query-builder.ts:28:34 - error TS2802: Type 'IterableIterator<[number, QueryGroup]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
28 for (const [index, group] of value.entries()) {
src/ifc/IfcPropertiesManager/index.ts:153:33 - error TS2802: Type 'number[] | Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
153 for (const expressID of elementIDs ?? []) {
src/ifc/IfcPropertiesProcessor/index.ts:144:27 - error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
144 for (const index of indices) {
src/ifc/IfcPropertiesProcessor/index.ts:303:24 - error TS2802: Type 'any[] | Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
303 for (const id of elementPropsIndexation) {
src/ifc/IfcPropertiesUtils/index.ts:186:29 - error TS2802: Type 'number[] | Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
186 for (const expressID of expressIDs) {
src/navigation/EdgesClipper/src/clipping-edges.ts:185:24 - error TS2802: Type 'Set<Mesh<BufferGeometry, Material | Material[]>>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
185 for (const mesh of style.meshes) {
src/navigation/EdgesClipper/src/edges-plane.ts:38:18 - error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
38 return super.enabled;
src/navigation/EdgesClipper/src/edges-plane.ts:56:11 - error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
56 super.visible = state;
src/navigation/PostproductionRenderer/src/custom-effects-pass.ts:173:26 - error TS2802: Type 'Set<Mesh<BufferGeometry, Material | Material[]> | InstancedMesh<BufferGeometry, Material | Material[]>>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
173 for (const mesh of style.meshes) {
src/navigation/PostproductionRenderer/src/custom-effects-pass.ts:258:28 - error TS2802: Type 'Set<Mesh<BufferGeometry, Material | Material[]> | InstancedMesh<BufferGeometry, Material | Material[]>>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
258 for (const mesh of style.meshes) {
src/ui/ToastNotification/index.ts:63:13 - error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
63 super.visible = active;
Found 44 errors in 22 files.
Errors Files 1 src/annotation/DrawManager/index.ts:72 1 src/core/MaterialManager/index.ts:57 2 src/core/ScreenCuller/index.ts:258 3 src/core/ToolsComponent/index.ts:1 1 src/fragments/FragmentClassifier/index.ts:80 2 src/fragments/FragmentExploder/index.ts:92 4 src/fragments/FragmentHighlighter/index.ts:263 1 src/ifc/IfcJsonExporter/index.ts:74 7 src/ifc/IfcPropertiesFinder/index.ts:196 1 src/ifc/IfcPropertiesFinder/src/query-builder.ts:28 1 src/ifc/IfcPropertiesFinder/src/query-group.ts:33 2 src/ifc/IfcPropertiesManager/index.ts:153 4 src/ifc/IfcPropertiesProcessor/index.ts:144 1 src/ifc/IfcPropertiesUtils/index.ts:186 1 src/measurement/AngleMeasurement/src/index.ts:91 1 src/navigation/EdgesClipper/src/clipping-edges.ts:185 1 src/navigation/EdgesClipper/src/clipping-fills.ts:351 3 src/navigation/EdgesClipper/src/edges-plane.ts:38 1 src/navigation/EdgesClipper/src/edges-styles.ts:50 3 src/navigation/PostproductionRenderer/src/custom-effects-pass.ts:173 1 src/ui/Dropdown/index.ts:150 2 src/ui/ToastNotification/index.ts:63
Validations ✅