From 2526b0460e017b5764a7accf7e6a45f457909438 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 26 Aug 2021 13:18:31 -0700 Subject: [PATCH] fix: node_modules resolutions --- api/js/etemplate/Et2Button/Et2Button.ts | 2 +- rollup.config.js | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Button/Et2Button.ts b/api/js/etemplate/Et2Button/Et2Button.ts index df9c4a4aa2..e14e282dc4 100644 --- a/api/js/etemplate/Et2Button/Et2Button.ts +++ b/api/js/etemplate/Et2Button/Et2Button.ts @@ -9,7 +9,7 @@ */ -import {css, html} from "../../../../node_modules/@lion/core/index.js"; +import {css, html} from "@lion/core"; import {LionButton} from "../../../../node_modules/@lion/button/index.js"; import {SlotMixin} from "../../../../node_modules/@lion/core/src/SlotMixin.js"; import {Et2InputWidget} from "../Et2InputWidget/Et2InputWidget"; diff --git a/rollup.config.js b/rollup.config.js index 8e243cc0fd..a9edd35e18 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -23,6 +23,18 @@ rimraf.sync('./chunks/'); // Turn on minification const do_minify = false; +function isBareSpecifier (id) { + if (id.startsWith("./") || id.startsWith("../") || id.startsWith("/")) + return false; + try { + new URL(id); + return false; + } + catch { + return true; + } +} + const config = { treeshake: false, input: { @@ -58,13 +70,18 @@ const config = { }, plugins: [{ resolveId (id, parentId) { + // Delegate bare specifiers to node_modules resolver + if (isBareSpecifier(id)) + { + return; + } if (!parentId || parentId.indexOf(path.sep + 'node_modules' + path.sep) !== -1) { return; } - if(id.endsWith(".js")) + if (id.endsWith(".js")) { - const tsPath =path.resolve(path.dirname(parentId), id.slice(0,-3) + '.ts'); + const tsPath = path.resolve(path.dirname(parentId), id.slice(0,-3) + '.ts'); try { readFileSync(tsPath); console.warn(id + " is a TS file loaded with wrong extension. Remove the extension on the import in " + parentId);