Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Commit

Permalink
⭐ new: Automatically insert node_modules as externals (#22) by @Crash…
Browse files Browse the repository at this point in the history
…yBang
  • Loading branch information
chopfitzroy authored and kazupon committed May 14, 2019
1 parent c2b268f commit c519d43
Show file tree
Hide file tree
Showing 2 changed files with 19,751 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/build/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const replace = require('rollup-plugin-replace')
const VuePlugin = require('rollup-plugin-vue')
const typescript = require('rollup-plugin-typescript2')
const { classify } = require('../utils')

// require.main cannot be used because this process is run externally (from vue-cli-service)
const { dependencies } = require(path.resolve(process.cwd(), 'package.json'))

function makeEntries (entryPath, destPath, moduleName, packageName, banner) {
const resolve = _path => path.resolve(destPath, _path)
return {
Expand Down Expand Up @@ -43,7 +45,11 @@ function makeEntries (entryPath, destPath, moduleName, packageName, banner) {

function buildinPlugins (version, env, langInfo) {
const plugins = [
node(),
node({
customResolveOptions: {
moduleDirectory: 'node_modules'
}
}),
cjs()
]

Expand Down Expand Up @@ -95,6 +101,8 @@ function generateConfig (options, moduleName, version, langInfo) {
banner: options.banner
// TODO: sourcemap: 'inline'
},
// https://github.com/rollup/rollup/issues/1514#issuecomment-320438924
external: Object.keys(dependencies),
plugins
}
}
Expand Down
Loading

0 comments on commit c519d43

Please sign in to comment.