Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bc19095869 | |||
| 970a9bcbf8 | |||
| e03deffb2d | |||
| a15810c195 | |||
| 84281590a9 | |||
| 33e73e9959 | |||
| a265493eba | |||
| 05a0552fe3 | |||
| 292c99e9d9 | |||
| 4dc71ce246 | |||
| 7e2961bc84 | |||
| ac34c908a4 | |||
| 92604a87a0 | |||
| 1b35948d70 | |||
| 264a21ab4b | |||
| d472e18ff0 | |||
| dbff40819f | |||
| 67822b36d3 |
@@ -19,23 +19,36 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
audit:
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@@ -50,9 +63,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@@ -63,9 +74,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@@ -85,6 +94,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -15,7 +15,7 @@
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31831
package-lock.json
generated
31831
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartparcel",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.13",
|
||||
"private": false,
|
||||
"description": "a wrapper for parcel",
|
||||
"main": "dist_ts/index.js",
|
||||
@@ -12,17 +12,17 @@
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.11.7",
|
||||
"tslint": "^5.11.0",
|
||||
"@gitzone/tsbuild": "^2.1.29",
|
||||
"@gitzone/tstest": "^1.0.64",
|
||||
"@pushrocks/tapbundle": "^4.0.8",
|
||||
"@types/node": "^17.0.21",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpath": "^4.0.3",
|
||||
"parcel-bundler": "^1.12.4",
|
||||
"@types/parcel-bundler": "^1.12.1"
|
||||
"@parcel/config-default": "^2.3.2",
|
||||
"@parcel/core": "^2.3.2",
|
||||
"@pushrocks/smartpath": "^4.0.3"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
@@ -35,5 +35,8 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartparcel from '../ts/index';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './parcel.classes.parcel';
|
||||
export * from './parcel.classes.parcel';
|
||||
|
||||
@@ -1,62 +1,92 @@
|
||||
import * as plugins from './smartparcel.plugins';
|
||||
|
||||
export class Parcel {
|
||||
private defaultOptions: plugins.parcel.ParcelOptions = {
|
||||
outDir: plugins.path.join(process.cwd(), './dist_watch'), // The out directory to put the build files in, defaults to dist
|
||||
outFile: 'index.html', // The name of the outputFile
|
||||
publicUrl: '/', // The url to serve on, defaults to '/'
|
||||
watch: true, // Whether to watch the files and rebuild them on change, defaults to process.env.NODE_ENV !== 'production'
|
||||
cache: true, // Enabled or disables caching, defaults to true
|
||||
cacheDir: '.nogit/.parcelcache', // The directory cache gets put in, defaults to .cache
|
||||
contentHash: false, // Disable content hash from being included on the filename
|
||||
global: 'moduleName', // Expose modules as UMD under this name, disabled by default
|
||||
minify: false, // Minify files, enabled if process.env.NODE_ENV === 'production'
|
||||
scopeHoist: false, // Turn on experimental scope hoisting/tree shaking flag, for smaller production bundles
|
||||
target: 'browser', // Browser/node/electron, defaults to browser
|
||||
bundleNodeModules: true, // By default, package.json dependencies are not included when using 'node' or 'electron' with 'target' option above. Set to true to adds them to the bundle, false by default
|
||||
https: null,
|
||||
logLevel: 3, // 5 = save everything to a file, 4 = like 3, but with timestamps and additionally log http requests to dev server, 3 = log info, warnings & errors, 2 = log warnings & errors, 1 = log errors, 0 = log nothing
|
||||
hmr: true, // Enable or disable HMR while watching
|
||||
hmrPort: 3003, // The port the HMR socket runs on, defaults to a random free port (0 in node.js resolves to a random free port)
|
||||
sourceMaps: true, // Enable or disable sourcemaps, defaults to enabled (minified builds currently always create sourcemaps)
|
||||
hmrHostname: '', // A hostname for hot module reload, default to ''
|
||||
detailedReport: false, // Prints a detailed report of the bundles, assets, filesizes and times, defaults to false, reports are only printed if watch is disabled
|
||||
private options: {
|
||||
from: string | string[],
|
||||
outputDir: string,
|
||||
outputFile: string
|
||||
} = {
|
||||
from: null,
|
||||
outputDir: null,
|
||||
outputFile: null,
|
||||
}
|
||||
private defaultOptions: ConstructorParameters<typeof plugins.parcel.Parcel>[ 0 ] = {
|
||||
defaultConfig: '@parcel/config-default',
|
||||
cacheDir: './.nogit/.parcelcache',
|
||||
defaultTargetOptions: {
|
||||
distDir: plugins.path.join(process.cwd(), './dist_watch'),
|
||||
publicUrl: '/',
|
||||
engines: {
|
||||
browsers: [ 'last 1 Chrome version' ]
|
||||
}
|
||||
},
|
||||
entries: './html/index.html',
|
||||
hmrOptions: {
|
||||
port: 3003
|
||||
},
|
||||
serveOptions: {
|
||||
port: 3002
|
||||
},
|
||||
shouldAutoInstall: true
|
||||
};
|
||||
public options: plugins.parcel.ParcelOptions;
|
||||
public entryFiles: string | string[] = plugins.path.join(process.cwd(), './html/index.html');
|
||||
|
||||
|
||||
public async createOptions() {
|
||||
const returnOptions: ConstructorParameters<typeof plugins.parcel.Parcel>[ 0 ] = {
|
||||
...this.defaultOptions,
|
||||
entries: this.options.from,
|
||||
defaultTargetOptions: {
|
||||
...this.defaultOptions.defaultTargetOptions,
|
||||
distDir: this.options.outputDir
|
||||
}
|
||||
}
|
||||
return returnOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* builds and serves
|
||||
*/
|
||||
public async start() {
|
||||
const bundler = new plugins.parcel(this.entryFiles, this.options);
|
||||
public async watchAndServe () {
|
||||
const bundler = new plugins.parcel.Parcel(await this.createOptions());
|
||||
|
||||
// Run the bundler, this returns the main bundle
|
||||
// Use the events if you're using watch mode as this promise will only trigger once and not for every rebuild
|
||||
const bundle = await bundler.serve(3002);
|
||||
let subscription = await bundler.watch((err, event) => {
|
||||
if (err) {
|
||||
// fatal error
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (event.type === 'buildSuccess') {
|
||||
let bundles = event.bundleGraph.getBundles();
|
||||
console.log(`✨ Built ${bundles.length} bundles in ${event.buildTime}ms!`);
|
||||
} else if (event.type === 'buildFailure') {
|
||||
console.log(event.diagnostics);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* just builds
|
||||
*/
|
||||
public async build() {
|
||||
const bundler = new plugins.parcel(this.entryFiles, {
|
||||
...this.options,
|
||||
watch: false
|
||||
});
|
||||
|
||||
// Run the bundler, this returns the main bundle
|
||||
// Use the events if you're using watch mode as this promise will only trigger once and not for every rebuild
|
||||
const bundle = await bundler.bundle();
|
||||
public async build () {
|
||||
let bundler = new plugins.parcel.Parcel(await this.createOptions());
|
||||
|
||||
try {
|
||||
let {bundleGraph, buildTime} = await bundler.run();
|
||||
let bundles = bundleGraph.getBundles();
|
||||
console.log(`✨ Built ${bundles.length} bundles in ${buildTime}ms!`);
|
||||
} catch (err: any) {
|
||||
console.log(err.diagnostics);
|
||||
}
|
||||
}
|
||||
|
||||
constructor(fromArg: string | string[], outputDirArg: string, outputFileArg: string) {
|
||||
this.entryFiles = fromArg;
|
||||
this.options = {
|
||||
...this.defaultOptions,
|
||||
outDir: outputDirArg,
|
||||
outFile: outputFileArg,
|
||||
from: fromArg,
|
||||
outputDir: outputDirArg,
|
||||
outputFile: outputFileArg
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ export { path };
|
||||
// @pushrocks scope
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
|
||||
export {
|
||||
smartpath
|
||||
};
|
||||
export { smartpath };
|
||||
|
||||
// third party scope
|
||||
import parcel from 'parcel-bundler';
|
||||
import * as parcel from '@parcel/core';
|
||||
|
||||
export { parcel };
|
||||
|
||||
Reference in New Issue
Block a user