Skip to content

Commit

Permalink
chore(build): add parse5 and sizzle to versions export
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Aug 11, 2020
1 parent e0961ed commit e74d04e
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 49 deletions.
44 changes: 33 additions & 11 deletions scripts/utils/options.ts
Expand Up @@ -82,33 +82,48 @@ export function getOptions(rootDir: string, inputOpts: BuildOptions = {}) {
}

export function createReplaceData(opts: BuildOptions) {
const CACHE_BUSTER = 6;
const CACHE_BUSTER = 7;

const typescriptPkg = require(join(opts.typescriptDir, 'package.json'));
opts.typescriptVersion = typescriptPkg.version;
const transpileId = typescriptPkg.name + typescriptPkg.version + '_' + CACHE_BUSTER;

const terserPkg = require(join(opts.nodeModulesDir, 'terser', 'package.json'));
const terserPkg = getPkg(opts, 'terser');
opts.terserVersion = terserPkg.version;
const minifyJsId = terserPkg.name + terserPkg.version + '_' + CACHE_BUSTER;

const rollupPkg = require(join(opts.nodeModulesDir, 'rollup', 'package.json'));
const rollupPkg = getPkg(opts, 'rollup');
opts.rollupVersion = rollupPkg.version;
const bundlerId = rollupPkg.name + rollupPkg.version + '_' + CACHE_BUSTER;

const autoprefixerPkg = require(join(opts.nodeModulesDir, 'autoprefixer', 'package.json'));
const postcssPkg = require(join(opts.nodeModulesDir, 'postcss', 'package.json'));
const autoprefixerPkg = getPkg(opts, 'autoprefixer');
const postcssPkg = getPkg(opts, 'postcss');

const optimizeCssId = autoprefixerPkg.name + autoprefixerPkg.version + '_' + postcssPkg.name + postcssPkg.version + '_' + CACHE_BUSTER;

const parse5Pkg = require(join(opts.nodeModulesDir, 'parse5', 'package.json'));
const parse5Pkg = getPkg(opts, 'parse5');
opts.parse5Verion = parse5Pkg.version;

const sizzlePkg = getPkg(opts, 'sizzle');
opts.sizzleVersion = sizzlePkg.version;

const data = readJSONSync(join(opts.srcDir, 'compiler', 'sys', 'dependencies.json'));
data.dependencies[0].version = opts.version;
data.dependencies[1].version = typescriptPkg.version;
data.dependencies[2].version = rollupPkg.version;
data.dependencies[3].version = terserPkg.version;
for (const dep of data.dependencies) {
switch (dep.name) {
case '@stencil/core':
dep.version = opts.version;
break;
case 'rollup':
dep.version = rollupPkg.version;
break;
case 'terser':
dep.version = terserPkg.version;
break;
case 'typescript':
dep.version = typescriptPkg.version;
break;
}
}
writeJSONSync(join(opts.rootDir, 'dependencies.json'), data, { spaces: 2 });

return {
Expand All @@ -119,14 +134,20 @@ export function createReplaceData(opts: BuildOptions) {
'__BUILDID:TRANSPILE__': transpileId,

'__VERSION:STENCIL__': opts.version,
'__VERSION:PARSE5__': parse5Pkg.version,
'__VERSION:ROLLUP__': rollupPkg.version,
'__VERSION:TYPESCRIPT__': typescriptPkg.version,
'__VERSION:SIZZLE__': rollupPkg.version,
'__VERSION:TERSER__': terserPkg.version,
'__VERSION:TYPESCRIPT__': typescriptPkg.version,

'__VERMOJI__': opts.vermoji,
};
}

function getPkg(opts: BuildOptions, pkgName: string): PackageData {
return require(join(opts.nodeModulesDir, pkgName, 'package.json'));
}

export interface BuildOptions {
ghRepoOrg?: string;
ghRepoName?: string;
Expand Down Expand Up @@ -167,6 +188,7 @@ export interface BuildOptions {
typescriptVersion?: string;
rollupVersion?: string;
parse5Verion?: string;
sizzleVersion?: string;
terserVersion?: string;
}

Expand Down
100 changes: 63 additions & 37 deletions src/compiler/sys/dependencies.json
Expand Up @@ -5,6 +5,63 @@
"version": "__VERSION:STENCIL__",
"main": "compiler/stencil.js",
"resources": [
"compiler/lib.d.ts",
"compiler/lib.dom.d.ts",
"compiler/lib.dom.iterable.d.ts",
"compiler/lib.es5.d.ts",
"compiler/lib.es6.d.ts",
"compiler/lib.es2015.collection.d.ts",
"compiler/lib.es2015.core.d.ts",
"compiler/lib.es2015.d.ts",
"compiler/lib.es2015.generator.d.ts",
"compiler/lib.es2015.iterable.d.ts",
"compiler/lib.es2015.promise.d.ts",
"compiler/lib.es2015.proxy.d.ts",
"compiler/lib.es2015.reflect.d.ts",
"compiler/lib.es2015.symbol.d.ts",
"compiler/lib.es2015.symbol.wellknown.d.ts",
"compiler/lib.es2016.array.include.d.ts",
"compiler/lib.es2016.d.ts",
"compiler/lib.es2016.full.d.ts",
"compiler/lib.es2017.d.ts",
"compiler/lib.es2017.full.d.ts",
"compiler/lib.es2017.intl.d.ts",
"compiler/lib.es2017.object.d.ts",
"compiler/lib.es2017.sharedmemory.d.ts",
"compiler/lib.es2017.string.d.ts",
"compiler/lib.es2017.typedarrays.d.ts",
"compiler/lib.es2018.asyncgenerator.d.ts",
"compiler/lib.es2018.asynciterable.d.ts",
"compiler/lib.es2018.d.ts",
"compiler/lib.es2018.full.d.ts",
"compiler/lib.es2018.intl.d.ts",
"compiler/lib.es2018.promise.d.ts",
"compiler/lib.es2018.regexp.d.ts",
"compiler/lib.es2019.array.d.ts",
"compiler/lib.es2019.d.ts",
"compiler/lib.es2019.full.d.ts",
"compiler/lib.es2019.object.d.ts",
"compiler/lib.es2019.string.d.ts",
"compiler/lib.es2019.symbol.d.ts",
"compiler/lib.es2020.bigint.d.ts",
"compiler/lib.es2020.d.ts",
"compiler/lib.es2020.full.d.ts",
"compiler/lib.es2020.intl.d.ts",
"compiler/lib.es2020.promise.d.ts",
"compiler/lib.es2020.string.d.ts",
"compiler/lib.es2020.symbol.wellknown.d.ts",
"compiler/lib.esnext.array.d.ts",
"compiler/lib.esnext.asynciterable.d.ts",
"compiler/lib.esnext.bigint.d.ts",
"compiler/lib.esnext.d.ts",
"compiler/lib.esnext.full.d.ts",
"compiler/lib.esnext.intl.d.ts",
"compiler/lib.esnext.promise.d.ts",
"compiler/lib.esnext.string.d.ts",
"compiler/lib.esnext.symbol.d.ts",
"compiler/lib.scripthost.d.ts",
"compiler/lib.webworker.d.ts",
"compiler/lib.webworker.importscripts.d.ts",
"internal/index.js",
"internal/index.d.ts",
"internal/package.json",
Expand All @@ -30,51 +87,20 @@
"package.json"
]
},
{
"name": "typescript",
"version": "__VERSION:TYPESCRIPT__",
"main": "lib/typescript.js",
"resources": [
"lib/lib.dom.d.ts",
"lib/lib.es2015.d.ts",
"lib/lib.es5.d.ts",
"lib/lib.es2015.core.d.ts",
"lib/lib.es2015.collection.d.ts",
"lib/lib.es2015.generator.d.ts",
"lib/lib.es2015.iterable.d.ts",
"lib/lib.es2015.symbol.d.ts",
"lib/lib.es2015.promise.d.ts",
"lib/lib.es2015.proxy.d.ts",
"lib/lib.es2015.reflect.d.ts",
"lib/lib.es2015.symbol.wellknown.d.ts",
"lib/lib.es2016.d.ts",
"lib/lib.es2016.array.include.d.ts",
"lib/lib.es2017.d.ts",
"lib/lib.es2017.typedarrays.d.ts",
"lib/lib.es2017.intl.d.ts",
"lib/lib.es2017.object.d.ts",
"lib/lib.es2017.sharedmemory.d.ts",
"lib/lib.es2017.string.d.ts",
"lib/lib.es2018.d.ts",
"lib/lib.es2018.asyncgenerator.d.ts",
"lib/lib.es2018.asynciterable.d.ts",
"lib/lib.es2018.promise.d.ts",
"lib/lib.es2018.regexp.d.ts",
"lib/lib.es2018.intl.d.ts",
"lib/lib.esnext.intl.d.ts",
"lib/lib.es2020.bigint.d.ts",
"package.json"
]
},
{
"name": "rollup",
"version": "__VERSION:ROLLUP__",
"main": "dist/rollup.browser.es.js"
"main": "dist/es/rollup.browser.js"
},
{
"name": "terser",
"version": "__VERSION:TERSER__",
"main": "dist/bundle.min.js"
},
{
"name": "typescript",
"version": "__VERSION:TYPESCRIPT__",
"main": "lib/typescript.js"
}
]
}
6 changes: 5 additions & 1 deletion src/version.ts
@@ -1,15 +1,19 @@
export const buildId = '__BUILDID__';
export const minfyJsId = '__BUILDID:MINIFYJS__';
export const optimizeCssId = '__BUILDID:OPTIMIZECSS__';
export const parse5Version = '__VERSION:PARSE5__';
export const rollupVersion = '__VERSION:ROLLUP__';
export const sizzleVersion = '__VERSION:SIZZLE__';
export const terserVersion = '__VERSION:TERSER__';
export const transpilerId = '__BUILDID:TRANSPILE__';
export const typescriptVersion = '__VERSION:TYPESCRIPT__';
export const vermoji = '__VERMOJI__';
export const version = '__VERSION:STENCIL__';
export const versions = {
stencil: version,
typescript: typescriptVersion,
parse5: parse5Version,
rollup: rollupVersion,
sizzle: sizzleVersion,
terser: terserVersion,
typescript: typescriptVersion,
};

0 comments on commit e74d04e

Please sign in to comment.