Skip to content

Index.cjs #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
WIP wrap_as_esm in @fluent/syntax
  • Loading branch information
stasm committed May 4, 2020
commit f1ed99475eb0212d441fe9b1dfd65d1497859526
1 change: 1 addition & 0 deletions fluent-syntax/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
esm/
/index.cjs
/wrapper.mjs
6 changes: 5 additions & 1 deletion fluent-syntax/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test: esm/.compiled
test/**/*_test.js

.PHONY: build
build: index.cjs
build: index.cjs wrapper.mjs

index.cjs: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
Expand All @@ -35,6 +35,10 @@ index.cjs: esm/.compiled
--output.file $@
@echo -e " $(OK) $@ built"

wrapper.mjs: index.cjs
@node ../wrap_as_esm.cjs $< > $@
@echo -e " $(OK) $@ built"

html:
@typedoc src \
--out ../html/syntax \
Expand Down
2 changes: 1 addition & 1 deletion fluent-syntax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./esm/index.js",
"import": "./wrapper.mjs",
"require": "./index.cjs"
},
"module": "./esm/index.js",
Expand Down
9 changes: 9 additions & 0 deletions wrap_as_esm.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require("path");
const index_cjs= process.argv[2];
const cjs = require(path.join(process.cwd(), index_cjs));

let wrapper = `import cjs from "./index.cjs";`;
for (let name in cjs) {
wrapper += `\nexport const ${name} = cjs.${name};`
}
console.log(wrapper);