-
Notifications
You must be signed in to change notification settings - Fork 96
Enables ESM Modules #3283
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
Merged
Merged
Enables ESM Modules #3283
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
139a832
✨ split exports and install
b1cb571
🩹 add missing functions export
e5ec3ae
🩹 add missing export: NcEmojiPicker
190c7b7
✨ enable esm build
b5cb29d
♻️ extract loadTranslations from webpack.config.js
fe3305a
💚 fix styleguide.config.js
5de9bf2
💚 fix cypress test
3ff23c7
🔧 remove npx reference
43bbd45
📝 update README.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ | |
"scripts": { | ||
"dev": "webpack --node-env development --progress", | ||
"watch": "webpack --node-env development --progress --watch", | ||
"build": "webpack --node-env production --progress", | ||
"build": "webpack --node-env production --progress && npm run build:module", | ||
"build:module": "LIBRARY_TARGET=module webpack --node-env production --progress", | ||
"l10n:extract": "node build/extract-l10n.js", | ||
"lint": "eslint --ext .js,.vue src", | ||
"lint:fix": "eslint --ext .js,.vue src --fix", | ||
|
@@ -30,6 +31,7 @@ | |
"cypress:update-snapshots": "cypress run-ct --env type=base --config screenshotsFolder=cypress/snapshots/base" | ||
}, | ||
"main": "dist/ncvuecomponents.js", | ||
vinicius73 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"module": "dist/index.module.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this an official naming convention? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it is just to keep webpack config simple |
||
"files": [ | ||
"CHANGELOG.md", | ||
"LICENSE", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* @copyright Copyright (c) 2022 Vinicius Reis <[email protected]> | ||
* | ||
* @author Vinicius Reis <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
const { join, basename } = require('path') | ||
const fs = require('fs/promises') | ||
const gettextParser = require('gettext-parser') | ||
|
||
// https://github.com/alexanderwallin/node-gettext#usage | ||
// https://github.com/alexanderwallin/node-gettext#load-and-add-translations-from-mo-or-po-files | ||
const parseFile = async (fileName) => { | ||
const locale = basename(fileName).slice(0, -'.pot'.length) | ||
const po = await fs.readFile(fileName) | ||
|
||
const json = gettextParser.po.parse(po) | ||
|
||
// Compress translations Content | ||
const translations = {} | ||
for (const key in json.translations['']) { | ||
if (key !== '') { | ||
// Plural | ||
if ('msgid_plural' in json.translations[''][key]) { | ||
translations[json.translations[''][key].msgid] = { | ||
pluralId: json.translations[''][key].msgid_plural, | ||
msgstr: json.translations[''][key].msgstr, | ||
} | ||
continue | ||
} | ||
|
||
// Singular | ||
translations[json.translations[''][key].msgid] = json.translations[''][key].msgstr[0] | ||
} | ||
} | ||
|
||
return { | ||
locale, | ||
translations, | ||
} | ||
} | ||
|
||
const loadTranslations = async (baseDir) => { | ||
const files = await fs.readdir(baseDir) | ||
|
||
const promises = files | ||
.filter(name => name !== 'messages.pot' && name.endsWith('.pot')) | ||
.map(file => join(baseDir, file)) | ||
.map(parseFile) | ||
|
||
return Promise.all(promises) | ||
} | ||
|
||
module.exports = { | ||
loadTranslations, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './emoji/index.js' | ||
export { default as usernameToColor } from './usernameToColor/index.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as NcComponents from './components/index.js' | ||
|
||
/** | ||
* @param {object} Vue The vue instance | ||
*/ | ||
function install(Vue) { | ||
Object.values(NcComponents).forEach((component) => { | ||
Vue.component(component.name, component) | ||
}) | ||
} | ||
|
||
if (typeof window !== 'undefined' && window.Vue) { | ||
install(window.Vue) | ||
} | ||
|
||
export default install |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.