-
Notifications
You must be signed in to change notification settings - Fork 844
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement core rollup build * Remove old webpack.fesm* configs * Fix process.env.VERSION is exists in result build * Add license banner * Remove unused dep * Implement react build via rollup * Fix replace plugin warning * Fix icons build * Fix icons build (2) * Fix icons build (3) * Fix sourcemaps
- Loading branch information
Showing
15 changed files
with
226 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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 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,56 @@ | ||
const typescript = require("@rollup/plugin-typescript"); | ||
const nodeResolve = require("@rollup/plugin-node-resolve"); | ||
const replace = require("@rollup/plugin-replace"); | ||
const bannerPlugin = require("rollup-plugin-license"); | ||
const path = require("path"); | ||
const VERSION = require("./package.json").version; | ||
const input = { "survey-core": path.resolve(__dirname, "./entries/index.ts") }; | ||
|
||
const banner = [ | ||
"surveyjs - Survey JavaScript library v" + VERSION, | ||
"Copyright (c) 2015-" + new Date().getFullYear() + " Devsoft Baltic OÜ - http://surveyjs.io/", | ||
"License: MIT (http://www.opensource.org/licenses/mit-license.php)", | ||
].join("\n"); | ||
|
||
module.exports = (options) => { | ||
options = options ?? {}; | ||
if(!options.tsconfig) { | ||
options.tsconfig = path.resolve(__dirname, "./tsconfig.fesm.json"); | ||
} | ||
if(!options.dir) { | ||
options.dir = path.resolve(__dirname, "./build/fesm"); | ||
} | ||
return { | ||
input, | ||
context: "this", | ||
|
||
plugins: [ | ||
nodeResolve(), | ||
typescript({ inlineSources: true, sourceMap: true, tsconfig: options.tsconfig, compilerOptions: { | ||
declaration: false, | ||
declarationDir: null | ||
} }), | ||
replace({ | ||
preventAssignment: false, | ||
values: { | ||
"process.env.RELEASE_DATE": JSON.stringify(new Date().toISOString().slice(0, 10)), | ||
"process.env.VERSION": JSON.stringify(VERSION), | ||
} | ||
}), | ||
bannerPlugin({ | ||
banner: { | ||
content: banner, | ||
commentStyle: "ignored", | ||
} | ||
}) | ||
], | ||
output: [ | ||
{ | ||
dir: options.dir, | ||
format: "esm", | ||
exports: "named", | ||
sourcemap: true, | ||
}, | ||
], | ||
}; | ||
}; |
This file contains 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,27 @@ | ||
const defaultConfig = require("./rollup.config"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const input = { | ||
"survey.i18n": path.resolve(__dirname, "./entries/i18n.ts") | ||
}; | ||
|
||
function patchEntries() { | ||
fs.readdirSync(path.resolve(__dirname, "./src/localization")).forEach(file => { | ||
var extension = path.extname(file); | ||
if (extension.toLowerCase() === ".ts") { | ||
input[`i18n/${path.basename(file, extension)}`] = (path.resolve(__dirname, "./src/localization") + "/" + file); | ||
} | ||
}); | ||
input["i18n/index"] = path.resolve(__dirname, "./entries/i18n.ts"); | ||
} | ||
|
||
module.exports = () => { | ||
let options = { | ||
tsconfig: path.resolve(__dirname, "./tsconfig.i18n.json") | ||
}; | ||
const config = defaultConfig(options); | ||
patchEntries(); | ||
config.input = input; | ||
config.external = ["survey-core"]; | ||
return config; | ||
}; |
This file contains 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,39 @@ | ||
const defaultConfig = require("./rollup.config"); | ||
const path = require("path"); | ||
const fg = require("fast-glob"); | ||
const svgLoader = require("svg-inline-loader"); | ||
const readFile = require("fs").readFileSync; | ||
const input = { | ||
"iconsV1": path.resolve(__dirname, "./src/iconsV1-es.ts"), | ||
"iconsV2": path.resolve(__dirname, "./src/iconsV2-es.ts"), | ||
}; | ||
module.exports = () => { | ||
let options = { | ||
dir: path.resolve(__dirname, "./build/fesm/icons"), | ||
tsconfig: path.resolve(__dirname, "./tsconfig.icons.json") | ||
}; | ||
const config = defaultConfig(options); | ||
const iconsMap = { | ||
"iconsV1": fg.convertPathToPattern(path.resolve(__dirname, "./src/images-v1")) + "/*.svg", | ||
"iconsV2": fg.convertPathToPattern(path.resolve(__dirname, "./src/images-v2")) + "/*.svg" | ||
}; | ||
config.plugins.push({ | ||
name: "icons", | ||
resolveId: (id) => { | ||
if (Object.keys(iconsMap).includes(id)) { | ||
return id; | ||
} | ||
}, | ||
load: async (id) => { | ||
if (Object.keys(iconsMap).includes(id)) { | ||
const icons = {}; | ||
for (const iconPath of await fg.glob(iconsMap[id])) { | ||
icons[path.basename(iconPath).replace(/\.svg$/, "").toLocaleLowerCase()] = svgLoader.getExtractedSVG(readFile(iconPath).toString()); | ||
} | ||
return `export default ${JSON.stringify(icons, undefined, "\t")}`; | ||
} | ||
} | ||
}); | ||
config.input = input; | ||
return config; | ||
}; |
This file contains 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,12 @@ | ||
const defaultConfig = require("./rollup.config"); | ||
const path = require("path"); | ||
const input = { index: path.resolve(__dirname, "./src/themes/index.ts") }; | ||
module.exports = () => { | ||
let options = { | ||
dir: path.resolve(__dirname, "./build/fesm/themes"), | ||
tsconfig: path.resolve(__dirname, "./tsconfig.themes.json") | ||
}; | ||
const config = defaultConfig(options); | ||
config.input = input; | ||
return config; | ||
}; |
This file contains 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,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore | ||
import icons from "iconsV1"; | ||
export { icons }; |
This file contains 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,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore | ||
import icons from "iconsV2"; | ||
export { icons }; |
This file contains 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.