Skip to content

Commit

Permalink
add builtin optimize support (#1615)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott authored Nov 19, 2020
1 parent ccc28a6 commit 7ea9709
Show file tree
Hide file tree
Showing 11 changed files with 790 additions and 47 deletions.
2 changes: 1 addition & 1 deletion esinstall/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.3.3",
"cjs-module-lexer": "^0.5.0",
"cjs-module-lexer": "^1.0.0",
"es-module-lexer": "^0.3.24",
"is-builtin-module": "^3.0.0",
"kleur": "^4.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs';
import {Plugin} from 'rollup';
import {InstallTarget, AbstractLogger} from '../types';
import {getWebDependencyName} from '../util.js';
import parse from 'cjs-module-lexer';
const {parse} = require('cjs-module-lexer');

/**
* rollup-plugin-wrap-install-targets
Expand Down
6 changes: 4 additions & 2 deletions snowpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@
"dependencies": {
"@snowpack/plugin-build-script": "^2.0.11",
"@snowpack/plugin-run-script": "^2.2.0",
"@types/cheerio": "^0.22.22",
"cacache": "^15.0.0",
"cachedir": "^2.3.0",
"cheerio": "^1.0.0-rc.3",
"chokidar": "^3.4.0",
"compressible": "^2.0.18",
"cosmiconfig": "^7.0.0",
"css-modules-loader-core": "^1.1.0",
"deepmerge": "^4.2.2",
"detect-port": "^1.3.0",
"es-module-lexer": "^0.3.24",
"esbuild": "^0.8.0",
"esbuild": "^0.8.7",
"esinstall": "^0.3.7",
"etag": "^1.8.1",
"execa": "^4.0.3",
Expand All @@ -80,9 +82,9 @@
"resolve-from": "^5.0.0",
"rimraf": "^3.0.0",
"signal-exit": "^3.0.3",
"skypack": "^0.0.1",
"source-map": "^0.7.3",
"strip-ansi": "^6.0.0",
"skypack": "^0.0.1",
"strip-comments": "^2.0.1",
"validate-npm-package-name": "^3.0.0",
"ws": "^7.3.0",
Expand Down
7 changes: 3 additions & 4 deletions snowpack/src/build/import-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import fs from 'fs';
import path from 'path';
import url from 'url';
import {ImportMap, SnowpackConfig} from '../types/snowpack';
import {findMatchingAliasEntry, getExt, replaceExt} from '../util';
import {findMatchingAliasEntry, getExt, isRemoteSpecifier, replaceExt} from '../util';
import {getUrlForFile} from './file-urls';

const cwd = process.cwd();
Expand Down Expand Up @@ -57,7 +56,7 @@ export function createImportResolver({
}: ImportResolverOptions) {
return function importResolver(spec: string): string | false {
// Ignore "http://*" imports
if (url.parse(spec).protocol) {
if (isRemoteSpecifier(spec)) {
return spec;
}
// Ignore packages marked as external
Expand All @@ -67,7 +66,7 @@ export function createImportResolver({
// Support snowpack.lock.json entry
if (lockfile && lockfile.imports[spec]) {
const mappedImport = lockfile.imports[spec];
if (url.parse(mappedImport).protocol) {
if (isRemoteSpecifier(mappedImport)) {
return mappedImport;
}
throw new Error(
Expand Down
Loading

0 comments on commit 7ea9709

Please sign in to comment.