Comments (3)
@noonian can you please check if issue gone with this branch: https://github.com/steel97/pixi-tilemap/tree/cjs-test
I removed "type": "module"
from package.json
you can install this version by changing your package.json:
"@pixi/tilemap": "github:steel97/pixi-tilemap#cjs-test"
from tilemap.
Can you please check, i just published version for v7?
from tilemap.
FYI: I am also unable to import @pixi/tilemap
in my Pixi v7 application.
Unfortunately I don't have useful logs and I'm using Pixi via ClojureScript so my tooling configuration is unlikely to help in diagnosing the issue.
Update:
I've tracked the issue to differences between node module types. I think the core issue is that @pixi/tilemap
has "type": "module"
in package.json
and other @pixi packages I am using do not.
It appears @pixi/tilemap
works if you import
it from a node project that uses "type": "module
in package.json
, but using require("@pixi/tilemap")
(commonjs) fails.
const { Tilemap } = require("@pixi/tilemap");
console.log("foo", Tilemap);
Results in an error:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/noonian/projects/pixi-tilemap-repro/node_modules/@pixi/tilemap/dist/pixi-tilemap.umd.js from /Users/noonian/projects/pixi-tilemap-repro/index.js not supported.
pixi-tilemap.umd.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename pixi-tilemap.umd.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/noonian/projects/pixi-tilemap-repro/node_modules/@pixi/tilemap/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
The tooling I am using from ClojureScript (shadow-cljs) "guesses" which way to import the library based on the keys "module"
, "browser"
, and "main"
in package.json
, none of which are present in @pixi/tilemap
. So I can work around this issue by hacking the package.json
in my node_modules
before compilation and adding "main": "./dist/pixi-tilemap.js"
or "module": "./dist/pixi-tilemap.es.js",
to my node_modules/@pixi/tilemap/package.json
after installing my dependencies.
I could not get my repro script to run using commonjs requires without removing "type": "module"
from the package.json
in my local node_modules. I have not tried getting this working using a bundler like webpack.
from tilemap.
Related Issues (20)
- Import `PIXI` instead of requiring it to exist globally. HOT 11
- Missing textures crash the renderer HOT 6
- pixi-tilemap assigns wrong width and height to the object when there are empty tiles HOT 8
- LDtk Json support HOT 4
- Feature request: Applying tint HOT 2
- id for tile HOT 7
- CanvasRenderer using incorrect asset from spritesheet HOT 11
- newest pixi-tilemap fails with renderer.plugins.tilemap undefined HOT 16
- CompositeTilemap has no `add` method, despite the example HOT 1
- tileAnim does not work for negative offsets HOT 1
- Tiles are reset to original, after x amount of changes HOT 2
- collision
- Update to newer PIXI version HOT 1
- Not working with new `cullable` property from `PIXI 6.3.0`. HOT 4
- Not working since PIXI 6.4.0 HOT 2
- Not compatible with Pixi 7 HOT 9
- Missing dependencies
- Texture ID is only set when composite parent is true.
- Request for the updating of rpgmaker.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tilemap.