Unverified Commit 41eaa9cf authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Run ncc on unistore to fix install warning (#6459)

ncc unistore to fix install warning
parent 88388f79
import createStore from 'unistore' import createStore from 'next/dist/compiled/unistore'
import { store, OutputState } from './store' import { store, OutputState } from './store'
import formatWebpackMessages from '../../client/dev-error-overlay/format-webpack-messages' import formatWebpackMessages from '../../client/dev-error-overlay/format-webpack-messages'
......
import chalk from 'chalk' import chalk from 'chalk'
import createStore from 'unistore' import createStore from 'next/dist/compiled/unistore'
import readline from 'readline' import readline from 'readline'
import { onExit } from './exit' import { onExit } from './exit'
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
"terser": "3.16.1", "terser": "3.16.1",
"tty-aware-progress": "1.0.3", "tty-aware-progress": "1.0.3",
"unfetch": "3.0.0", "unfetch": "3.0.0",
"unistore": "3.2.1",
"url": "0.11.0", "url": "0.11.0",
"webpack": "4.29.0", "webpack": "4.29.0",
"webpack-dev-middleware": "3.4.0", "webpack-dev-middleware": "3.4.0",
...@@ -117,7 +116,8 @@ ...@@ -117,7 +116,8 @@
"@types/rimraf": "2.0.2", "@types/rimraf": "2.0.2",
"@zeit/ncc": "0.15.2", "@zeit/ncc": "0.15.2",
"taskr": "1.1.0", "taskr": "1.1.0",
"typescript": "3.1.6" "typescript": "3.1.6",
"unistore": "3.2.1"
}, },
"engines": { "engines": {
"node": ">= 8.0.0" "node": ">= 8.0.0"
......
'use strict' 'use strict'
const ncc = require('@zeit/ncc') const ncc = require('@zeit/ncc')
const basename = require('path').basename const { existsSync, copyFileSync } = require('fs')
const dirname = require('path').dirname const { basename, dirname, extname, join, relative } = require('path')
const join = require('path').join
module.exports = function (task) { module.exports = function (task) {
task.plugin('ncc', {}, function * (file, options) { task.plugin('ncc', {}, function * (file, options) {
return ncc( return ncc(join(__dirname, file.dir, file.base), {
join(__dirname, file.dir, file.base), // cannot bundle
{ externals: ['chokidar'],
// cannot bundle ...options
externals: ['chokidar'], }).then(({ code, assets }) => {
...options Object.keys(assets).forEach(key =>
this._.files.push({
dir: join(file.dir, dirname(key)),
base: basename(key),
data: assets[key].source
})
)
if (options && options.packageName) {
writePackageManifest.call(this, options.packageName)
} }
).then(({ code, assets }) => {
Object.keys(assets).forEach((key) => this._.files.push({
dir: join(file.dir, dirname(key)),
base: basename(key),
data: assets[key].source
}))
file.data = Buffer.from(code, 'utf8') file.data = Buffer.from(code, 'utf8')
}) })
}) })
} }
// This function writes a minimal `package.json` file for a compiled package.
// It defines `name`, `main`, `author`, and `license`. It also defines `types`.
// n.b. types intended for development usage only.
function writePackageManifest (packageName) {
const packagePath = require.resolve(packageName + '/package.json')
let { name, main, author, license, types, typings } = require(packagePath)
if (!main) {
main = 'index.js'
}
let typesFile = types || typings
if (typesFile) {
typesFile = require.resolve(join(packageName, typesFile))
}
const compiledPackagePath = join(__dirname, `dist/compiled/${packageName}`)
const potentialLicensePath = join(dirname(packagePath), './LICENSE')
if (existsSync(potentialLicensePath)) {
copyFileSync(potentialLicensePath, join(compiledPackagePath, './LICENSE'))
}
this._.files.push({
dir: compiledPackagePath,
base: 'package.json',
data:
JSON.stringify(
Object.assign(
{},
{ name, main: `${basename(main, '.' + extname(main))}` },
author ? { author } : undefined,
license ? { license } : undefined,
typesFile
? {
types: relative(compiledPackagePath, typesFile)
}
: undefined
)
) + '\n'
})
}
const notifier = require('node-notifier') const notifier = require('node-notifier')
const relative = require('path').relative
const babelOpts = { const babelOpts = {
presets: [ presets: [
['@babel/preset-env', { ['@babel/preset-env', {
...@@ -18,6 +20,17 @@ const babelOpts = { ...@@ -18,6 +20,17 @@ const babelOpts = {
] ]
} }
export async function nccunistore (task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('unistore')))
.ncc({ packageName: 'unistore' })
.target('dist/compiled/unistore')
}
export async function precompile (task) {
await task.parallel(['nccunistore'])
}
export async function compile (task) { export async function compile (task) {
await task.parallel(['cli', 'bin', 'server', 'nextbuild', 'nextbuildstatic', 'pages', 'lib', 'client']) await task.parallel(['cli', 'bin', 'server', 'nextbuild', 'nextbuildstatic', 'pages', 'lib', 'client'])
} }
...@@ -63,7 +76,7 @@ export async function pages (task, opts) { ...@@ -63,7 +76,7 @@ export async function pages (task, opts) {
} }
export async function build (task) { export async function build (task) {
await task.serial(['compile']) await task.serial(['precompile', 'compile'])
} }
export default async function (task) { export default async function (task) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment