Skip to content
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

ESM #478

Merged
merged 1 commit into from
Nov 8, 2024
Merged

ESM #478

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 .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = (eleventyConfig) => {
export default (eleventyConfig) => {
eleventyConfig.addPassthroughCopy("assets");
eleventyConfig.addPassthroughCopy("favicon*");
return {
Expand Down
4 changes: 2 additions & 2 deletions _data/octicons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const octicons = require("@primer/octicons");
import octicons from "@primer/octicons";

// @ts-check
module.exports = {
export default {
commentDiscussion: octicons["comment-discussion"].heights[16].path,
markGithub: octicons["mark-github"].heights[16].path,
};
4 changes: 2 additions & 2 deletions _data/stages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const EleventyFetch = require("@11ty/eleventy-fetch");
import EleventyFetch from "@11ty/eleventy-fetch";

function arrayEquals(a, b) {
return (
Expand All @@ -9,7 +9,7 @@ function arrayEquals(a, b) {
);
}

module.exports = async () => {
export default async () => {
const json = await EleventyFetch("https://tc39.es/dataset/proposals.json", {
duration: "1h", // 1 day
type: "json", // also supports "text" or "buffer"
Expand Down
6 changes: 5 additions & 1 deletion de/de.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
smorimoto marked this conversation as resolved.
Show resolved Hide resolved

export default {
intro: require("./intro.json"),
proposals: require("./proposals.json"),
site: require("./site.json"),
Expand Down
6 changes: 5 additions & 1 deletion en/en.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

export default {
intro: require("./intro.json"),
proposals: require("./proposals.json"),
site: require("./site.json"),
Expand Down
6 changes: 5 additions & 1 deletion fr/fr.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

export default {
intro: require("./intro.json"),
proposals: require("./proposals.json"),
site: require("./site.json"),
Expand Down
6 changes: 5 additions & 1 deletion ja/ja.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

export default {
intro: require("./intro.json"),
proposals: require("./proposals.json"),
site: require("./site.json"),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"type": "git",
"url": "https://github.com/tc39/tc39.github.io.git"
},
"type": "module",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would have been better to make the files .mjs instead of using type module, ftr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm? Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All type module does is change the parse goal of .js; it's not required for ESM, and using a .mjs extension may even be faster because the looking up the type field takes time.

"scripts": {
"prebuild": "npm run sass",
"build": "eleventy",
Expand Down
6 changes: 5 additions & 1 deletion ru/ru.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

export default {
intro: require("./intro.json"),
proposals: require("./proposals.json"),
site: require("./site.json"),
Expand Down
6 changes: 5 additions & 1 deletion uk/uk.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

export default {
intro: require("./intro.json"),
proposals: require("./proposals.json"),
site: require("./site.json"),
Expand Down
6 changes: 5 additions & 1 deletion zh-Hans/zh-Hans.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

export default {
intro: require("./intro.json"),
proposals: require("./proposals.json"),
site: require("./site.json"),
Expand Down