npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bluecateng/l10n-swc-plugin

v0.1.1

Published

SWC plugin to compile the l10n macros

Readme

@bluecateng/l10n-swc-plugin

SWC plugin to compile the l10n macros, it can be used instead of babel-plugin-macros with any tool which supports SWC Wasm plugins, such as Rspack's builtin:swc-loader, @swc/core, @swc/cli, or @swc/jest.

The source code keeps importing the macros from @bluecateng/l10n.macro, and the generated code is the same as the one generated by the macro, so both can be used in the same project, e.g. SWC for the build and Babel for the tests.

Installation

npm i -D @bluecateng/l10n-swc-plugin @bluecateng/l10n.macro

@bluecateng/l10n.macro is only required for the type definitions.

Compatibility

SWC Wasm plugins are only compatible with a range of SWC versions, this plugin is built with swc_core 82, and it has been verified with @swc/core 1.16 and @rspack/core 2.2. See selecting the version for more details.

Options

| Option | Description | | ------------ | ----------------------------------------------------------------------------------------------- | | module | Path to the l10n module, relative paths are resolved from the current directory of the process. | | hashLength | The length of the hash used as message key, if not set the ICU string is used as key. |

SWC always passes the current directory of the process to the plugin, the cwd option of @swc/core is ignored, so a relative module only works when the build runs from the directory it is relative to, usually the project root. @bluecateng/l10n-swc-plugin/config always returns an absolute path.

Usage

JavaScript configuration

When the SWC configuration is written in JavaScript, @bluecateng/l10n-swc-plugin/config returns the plugin entry using the values from the l10n configuration (bc-l10n in package.json or .bc-l10nrc), so they don't need to be repeated.

Rspack

import l10nSwcPlugin from '@bluecateng/l10n-swc-plugin/config';

export default {
	module: {
		rules: [
			{
				test: /\.m?js$/,
				exclude: /node_modules/,
				loader: 'builtin:swc-loader',
				options: {
					jsc: {
						parser: {syntax: 'ecmascript', jsx: true},
						transform: {react: {runtime: 'automatic'}},
						experimental: {plugins: [l10nSwcPlugin()]},
					},
				},
			},
			{test: /\.po$/, loader: '@bluecateng/l10n-loader'},
		],
	},
};

@swc/core

import {transformFile} from '@swc/core';
import l10nSwcPlugin from '@bluecateng/l10n-swc-plugin/config';

const {code} = await transformFile('src/index.js', {
	jsc: {
		parser: {syntax: 'ecmascript', jsx: true},
		experimental: {plugins: [l10nSwcPlugin()]},
	},
});

.swcrc

.swcrc is a JSON file, so the options must be specified explicitly, they must match the l10n configuration, and a relative module must be relative to the directory where swc is run. This can be used with @swc/cli for packages which are built without a bundler, e.g. swc src -d dist --strip-leading-paths.

{
	"jsc": {
		"parser": {"syntax": "ecmascript", "jsx": true},
		"transform": {"react": {"runtime": "automatic"}},
		"experimental": {
			"plugins": [["@bluecateng/l10n-swc-plugin", {"module": "src/l10n", "hashLength": 3}]]
		}
	}
}

Differences with the macro

  • Macros used inside a non-macro expression in another macro, e.g. t`Items: ${items.map((i) => t`Item ${i}`)}` , are also compiled, babel-plugin-macros leaves them unchanged.
  • The trailing /*l10n: …*/ comments are always added, the macro omits them when NODE_ENV is production.
  • Duplicated hashes are only detected in the same file, l10n-cli still detects them when extracting the strings.
  • An invalid usage reports an error with the source location instead of throwing.