Closed Hopobcn closed 6 years ago
Good catch! I'll go ahead and update those docs now.
@Hopobcn and to answer your question, unfortunately no. Rollup has first-class support for bundling ES6 modules, but screeps-profiler
is a CommonJS module, which means the module along with its named exports need to be resolved using rollup-plugin-commonjs.
Webpack gets around this by making everything a CommonJS module and then reimplementing the CommonJS require()
system client-side, which gets around the namedExports
issue at the expense of larger bundle size (which explains the seemingly boilerplate code it generates).
I could be wrong though, @apemanzilla can probably correct me.
Yeah, this is an issue with the way screeps-profiler
is written and a limitation of rollup
unfortunately.
Anyways, the docs have been updated. This can be closed now.
Still confused on how people got the "Profiler" object without any import after naming the export..... any help here? even the doc isn't clear.
I've found an issue (and a possible solution) when loading
screps-profiler
to a project. I add this issue in case it's useful for others.Use case:
We add screeps-profiler dependency as stated in screeps-typescript-starter/docs/in-depth/module-bundling.md:
npm install screeps-profiler
Then we modify
src/main.js
to insert all required code:Expected behaviour:
Uploaded
dist/main.js
contains a bundled screeps-profilerActual behaviour:
And
dist/main.js
has someundefined
calls:In game console:
Possible Solution:
In
rollup.config.js
, add a namedExprots section tocommonjs
plugin to manually exportenable
andwrap
functions.Maybe screeps-typescript-starter/docs/in-depth/module-bundling.md could be modified to specify the
rollup.config.js
modifications required.Does anyone have a better solution than this?