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 all commits
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
2 changes: 1 addition & 1 deletion fluent-bundle/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
esm/
/index.js
/index.cjs
6 changes: 3 additions & 3 deletions fluent-bundle/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ test: esm/.compiled
test/**/*_test.js

.PHONY: build
build: index.js
build: index.cjs

index.js: esm/.compiled
index.cjs: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
Expand All @@ -47,7 +47,7 @@ html:

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js
@rm -f index.cjs
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"

Expand Down
8 changes: 6 additions & 2 deletions fluent-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"email": "[email protected]"
}
],
"type": "commonjs",
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./esm/index.js",
"require": "./index.cjs"
},
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion fluent-dedent/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
esm/
/index.js
/index.cjs
6 changes: 3 additions & 3 deletions fluent-dedent/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ test: esm/.compiled
test/**/*_test.js

.PHONY: build
build: index.js
build: index.cjs

index.js: esm/.compiled
index.cjs: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
Expand All @@ -47,6 +47,6 @@ html:

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js
@rm -f index.cjs
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"
8 changes: 6 additions & 2 deletions fluent-dedent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
"email": "[email protected]"
}
],
"type": "commonjs",
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./esm/index.js",
"require": "./index.cjs"
},
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion fluent-dom/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
esm/
/index.js
/index.cjs
6 changes: 3 additions & 3 deletions fluent-dom/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ test: esm/.compiled
test/**/*_test.js

.PHONY: build
build: index.js
build: index.cjs

index.js: esm/.compiled
index.cjs: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
Expand All @@ -50,6 +50,6 @@ html:

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js
@rm -f index.cjs
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"
8 changes: 6 additions & 2 deletions fluent-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
"email": "[email protected]"
}
],
"type": "commonjs",
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./esm/index.js",
"require": "./index.cjs"
},
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"keywords": [
Expand Down
3 changes: 0 additions & 3 deletions fluent-gecko/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
"email": "[email protected]"
}
],
"directories": {
"lib": "./src"
},
"repository": {
"type": "git",
"url": "https://github.com/projectfluent/fluent.js.git"
Expand Down
2 changes: 1 addition & 1 deletion fluent-langneg/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
esm/
/index.js
/index.cjs
6 changes: 3 additions & 3 deletions fluent-langneg/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ test: esm/.compiled
test/**/*_test.js

.PHONY: build
build: index.js
build: index.cjs

index.js: $(SOURCES)
index.cjs: $(SOURCES)
@rollup $(CURDIR)/esm/index.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
Expand All @@ -47,6 +47,6 @@ html:

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js
@rm -f index.cjs
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"
8 changes: 6 additions & 2 deletions fluent-langneg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"email": "[email protected]"
}
],
"type": "commonjs",
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./esm/index.js",
"require": "./index.cjs"
},
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions fluent-langneg/test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
2 changes: 1 addition & 1 deletion fluent-react/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
esm/
/index.js
/index.cjs
6 changes: 3 additions & 3 deletions fluent-react/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ test: esm/.compiled
@jest --collect-coverage

.PHONY: build
build: index.js
build: index.cjs

index.js: esm/.compiled
index.cjs: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
Expand All @@ -45,6 +45,6 @@ html:

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js
@rm -f index.cjs
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"
8 changes: 6 additions & 2 deletions fluent-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"email": "[email protected]"
}
],
"type": "commonjs",
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./esm/index.js",
"require": "./index.cjs"
},
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion fluent-sequence/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
esm/
/index.js
/index.cjs
6 changes: 3 additions & 3 deletions fluent-sequence/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ test: esm/.compiled
test/**/*_test.js

.PHONY: build
build: index.js
build: index.cjs

index.js: esm/.compiled
index.cjs: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
Expand All @@ -47,6 +47,6 @@ html:

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js
@rm -f index.cjs
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"
8 changes: 6 additions & 2 deletions fluent-sequence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"email": "[email protected]"
}
],
"type": "commonjs",
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./esm/index.js",
"require": "./index.cjs"
},
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"repository": {
Expand Down
3 changes: 2 additions & 1 deletion fluent-syntax/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
esm/
/index.js
/index.cjs
/wrapper.mjs
10 changes: 7 additions & 3 deletions fluent-syntax/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ test: esm/.compiled
test/**/*_test.js

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

index.js: esm/.compiled
index.cjs: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
Expand All @@ -35,6 +35,10 @@ index.js: 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 All @@ -47,7 +51,7 @@ html:

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js
@rm -f index.cjs
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"

Expand Down
8 changes: 6 additions & 2 deletions fluent-syntax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"email": "[email protected]"
}
],
"type": "commonjs",
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./wrapper.mjs",
"require": "./index.cjs"
},
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"repository": {
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);