Skip to content

Commit

Permalink
chore(release): release vue3, svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodNeck committed Nov 23, 2021
1 parent 58cc4e3 commit ecffc01
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ egjs-view360 has the dependencies for the following libraries:
|[**@egjs/ngx-view360**](https://github.com/naver/egjs-view360/blob/master/packages/ngx-view360/README.md)|<a href="https://www.npmjs.com/package/@egjs/ngx-view360" target="_blank"><img src="https://img.shields.io/npm/v/@egjs/ngx-view360.svg?style=flat-square&color=dd0031&label=%F0%9F%94%96" alt="version" /></a>|[Angular](https://angular.io/) port of @egjs/view360|
|[**@egjs/react-view360**](https://github.com/naver/egjs-view360/blob/master/packages/react-view360/README.md)|<a href="https://www.npmjs.com/package/@egjs/react-view360" target="_blank"><img src="https://img.shields.io/npm/v/@egjs/react-view360.svg?style=flat-square&color=00d8ff&label=%F0%9F%94%96" alt="version" /></a>|[React](https://reactjs.org/) port of @egjs/view360|
|[**@egjs/vue-view360**](https://github.com/naver/egjs-view360/blob/master/packages/vue-view360/README.md)|<a href="https://www.npmjs.com/package/@egjs/vue-view360" target="_blank"><img src="https://img.shields.io/npm/v/@egjs/vue-view360.svg?style=flat-square&color=42b883&label=%F0%9F%94%96" alt="version" /></a>|[Vue.js@2](https://vuejs.org/v2/guide/index.html) port of @egjs/view360|
|[**@egjs/vue3-view360**](https://github.com/naver/egjs-view360/blob/master/packages/vue3-view360/README.md)|<a href="https://www.npmjs.com/package/@egjs/vue3-view360" target="_blank"><img src="https://img.shields.io/npm/v/@egjs/vue3-view360.svg?style=flat-square&color=42b883&label=%F0%9F%94%96" alt="version" /></a>|[Vue.js@3](https://v3.vuejs.org/) port of @egjs/view360|
|[**@egjs/svelte-view360**](https://github.com/naver/egjs-view360/blob/master/packages/svelte-view360/README.md)|<a href="https://www.npmjs.com/package/@egjs/svelte-view360" target="_blank"><img src="https://img.shields.io/npm/v/@egjs/svelte-view360.svg?style=flat-square&color=FF3E00&label=%F0%9F%94%96" alt="version" /></a>|[Svelte](https://svelte.dev/) port of @egjs/view360|

## How to start developing egjs-view360?

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"commitmsg": "node config/validate-commit-msg.js",
"changelog": "node config/changelog.js",
"packages": "npm run packages:update && npm run packages:build && npm run packages:publish",
"packages:update": "pvu --update=react-view360,ngx-view360/projects/ngx-view360,vue-view360",
"packages:build": "pvu --build=react-view360,ngx-view360,vue-view360",
"packages:publish": "pvu --publish=react-view360,ngx-view360/dist/ngx-view360,vue-view360"
"packages:update": "pvu --update=react-view360,ngx-view360/projects/ngx-view360,vue-view360,vue3-view360,svelte-view360",
"packages:build": "pvu --build=react-view360,ngx-view360,vue-view360,vue3-view360,svelte-view360",
"packages:publish": "pvu --publish=react-view360,ngx-view360/dist/ngx-view360,vue-view360,vue3-view360,svelte-view360"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions packages/svelte-view360/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules/
/public/build/
lib/

.DS_Store
3 changes: 3 additions & 0 deletions packages/svelte-view360/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ public/
.env
rollup.config.js
rollup.config.build.js
build.js
replace.js
tsconfig.json
tsconfig.declaration.json
51 changes: 51 additions & 0 deletions packages/svelte-view360/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const path = require("path");

const fs = require("fs-extra");
const svelte = require("svelte/compiler");
const { typescript } = require("svelte-preprocess");
const ts = require("typescript");

const tsconfig = require("./tsconfig.json");

const files = fs.readdirSync(path.resolve(__dirname, "./src"), { withFileTypes: true });

const tsFiles = files
.filter(file => file.isFile() && file.name.endsWith(".ts") && !file.name.endsWith(".d.ts"))
.map(file => file.name);
const jsFiles = files
.filter(file => file.isFile() && file.name.endsWith(".js"))
.map(file => file.name);
const svelteFiles = fs.readdirSync(path.resolve(__dirname, "./src"), { withFileTypes: true })
.filter(file => file.isFile() && file.name.endsWith(".svelte"))
.map(file => file.name);

fs.ensureDirSync(path.resolve(__dirname, "./lib"));

tsFiles.forEach(async fileName => {
const filePath = path.resolve(__dirname, "./src", fileName);
const file = await fs.readFile(filePath);
const { outputText } = ts.transpileModule(file.toString(), tsconfig);

await fs.writeFile(path.resolve(__dirname, "./lib", `${path.basename(fileName, ".ts")}.js`), outputText);
});

jsFiles.forEach(async fileName => {
await fs.copyFile(path.resolve(__dirname, "./src", fileName), path.resolve(__dirname, "./lib", fileName));
});

svelteFiles.forEach(async fileName => {
const filePath = path.resolve(__dirname, "./src", fileName);
const file = await fs.readFile(filePath);

const { code } = await svelte.preprocess(file.toString(), [
typescript({
tsconfigDirectory: ".",
tsconfigFile: "./tsconfig.json",
handleMixedImports: true
})
], {
filename: fileName
});

await fs.writeFile(path.resolve(__dirname, "./lib", fileName), code.replace("<script lang=\"ts\">", "<script>"));
});
7 changes: 4 additions & 3 deletions packages/svelte-view360/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"sideEffects": false,
"es2015": "dist/view360.esm.js",
"types": "declaration/index.d.ts",
"svelte": "dist/view360.esm.js",
"svelte": "lib/index.js",
"scripts": {
"build": "rm -rf dist && rollup -c ./rollup.config.build.js && npm run declaration",
"dev": "rollup -c -w",
"build": "rm -rf dist && rollup -c ./rollup.config.build.js && npm run build:lib && npm run declaration",
"build:lib": "rm -rf lib && node ./build",
"declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
"postdeclaration": "cpx './src/**.d.ts' 'declaration'",
"dev": "rollup -c -w",
"start": "sirv public --no-clear",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
Expand Down
11 changes: 6 additions & 5 deletions packages/svelte-view360/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"include": ["src/**/*"],
"exclude": ["node_modules/*"],
"compilerOptions": {
"target": "ESNEXT",
"target": "ES2017",
"module": "ESNEXT",
"noImplicitAny": false,
"strict": true,
"allowJs": true,
"outDir": "lib",
"moduleResolution": "node",
"types": ["svelte"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true
}
},
"include": ["src/**/*"],
"exclude": ["node_modules/*"]
}

0 comments on commit ecffc01

Please sign in to comment.