Open ljani opened 3 years ago
Hi @ljani ! Thanks for your feedback. Haven't tried snowpack before, looks like it's quite promising build tool, so ttag plugin will be useful. We have implemented something similar for the webpack - https://github.com/ttag-org/ttag-po-loader.
Good points about improving doc and typings. Going to create separate tickets for that!
Can you, please, explain more about the ESM support? Or to provide a link to some other package that already has it, so it can be taken as an example.
Hey! Good to hear you found it interesting and made some progress already!
Sure, I was a bit plain with ESM:
export
, import
and that stuff), but CommonJS (CJS) (module.export =
, const x = require("...")
, etc) modules are supported via a compatibility workaround (packageOptions.namedExports
above).lodash-es
("module": "lodash.js"
)package.json
: @microsoft/signalr
("main": "./dist/cjs/index.js"
and "module": "./dist/esm/index.js"
)lodash-es
with ttag@1.7.24
we can spot following differences:
package.json
(lodash-es
, ttag
) contains "type": "module"
and "module": "lodash.js"
in addition to normal "main": "lodash.js"
, which is found in both of the packages.ttag
's index.js
contains module.export =
statement(s) (CJS), lodash-es
' index file lodash.js
contains export ...
statements (ESM).ttag
's current src
is already using ESM, but Babel compiles them to CJS for publishing to npmHope this dump gave you at least something.
I'm a Lingui refugee (hi 👋🏻) looking for new home since they removed tagged templates support and I'm looking to localize my Snowpack application as soon as possible.
Here's some context from my Lingui ticket for Snowpack support:
Thus, I started searching for a internalization localization library using tagged templates and found
ttag
.ttag
seems to play nice with Snowpack, because of thepo2json
command. Here's an excerpt from mysnowpack.config.cjs
:I mainly opened this ticket to share my Snowpack config, but I'd like you to consider creating a Snowpack plugin for
ttag
. I thinkpo2json
could be quite easily adapted into a Snowpack plugin.I also noticed a few other points, should I open separate tickets for these?
types/index.d.ts
update
all my.po
files with one command. I scripted this step, but it's something that probably should be built-in. It is not, right?ttag-cli
documentation could be up there in ttag.js.org/docs/Thank you for your work!
EDIT: I forgot that
ttag
didn't support ESM and needsnamedExports